Skip to content

Commit 238b64d

Browse files
Base Devcontainer on CI Image (#873)
* Base devcontainer on ci image * Build arm image on main * Fix syntax --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 8ebe9a3 commit 238b64d

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

.devcontainer/Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
ARG IMAGE=ghcr.io/newrelic-experimental/pyenv-devcontainer:latest
2-
31
# To target other architectures, change the --platform directive in the Dockerfile.
4-
FROM --platform=linux/amd64 ${IMAGE}
2+
ARG IMAGE_TAG=latest
3+
FROM ghcr.io/newrelic/newrelic-python-agent-ci:${IMAGE_TAG}
4+
5+
# Setup non-root user
6+
USER root
7+
ARG UID=1000
8+
ARG GID=$UID
9+
ENV HOME /home/vscode
10+
RUN mkdir -p ${HOME} && \
11+
groupadd --gid ${GID} vscode && \
12+
useradd --uid ${UID} --gid ${GID} --home ${HOME} vscode && \
13+
chown -R ${UID}:${GID} /home/vscode
14+
USER ${UID}:${GID}

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// To target other architectures, change the --platform directive in the Dockerfile.
66
"dockerfile": "Dockerfile",
77
"args": {
8-
"IMAGE": "ghcr.io/newrelic-experimental/pyenv-devcontainer:latest"
8+
"IMAGE_TAG": "latest"
99
}
1010
},
1111
"remoteUser": "vscode",

.github/containers/Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
2323
build-essential \
2424
curl \
2525
expat \
26+
fish \
27+
fontconfig \
2628
freetds-common \
2729
freetds-dev \
2830
gcc \
@@ -46,13 +48,16 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
4648
python2-dev \
4749
python3-dev \
4850
python3-pip \
51+
sudo \
4952
tzdata \
5053
unixodbc-dev \
5154
unzip \
55+
vim \
5256
wget \
5357
zip \
5458
zlib1g \
55-
zlib1g-dev && \
59+
zlib1g-dev \
60+
zsh && \
5661
rm -rf /var/lib/apt/lists/*
5762

5863
# Build librdkafka from source
@@ -93,6 +98,10 @@ RUN echo 'eval "$(pyenv init -)"' >>$HOME/.bashrc && \
9398
# Install Python
9499
ARG PYTHON_VERSIONS="3.10 3.9 3.8 3.7 3.11 2.7 pypy2.7-7.3.12 pypy3.8-7.3.11"
95100
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
96-
COPY ./requirements.txt /requirements.txt
97101
RUN /tmp/install-python.sh && \
98102
rm /tmp/install-python.sh
103+
104+
# Install dependencies for main python installation
105+
COPY ./requirements.txt /tmp/requirements.txt
106+
RUN pyenv exec pip install --upgrade -r /tmp/requirements.txt && \
107+
rm /tmp/requirements.txt

.github/containers/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ REPO_ROOT:=$(realpath $(MAKEFILE_DIR)../../)
1919
.PHONY: default
2020
default: test
2121

22+
# Perform a shortened build for testing
2223
.PHONY: build
2324
build:
24-
@# Perform a shortened build for testing
2525
@docker build $(MAKEFILE_DIR) \
2626
-t ghcr.io/newrelic/newrelic-python-agent-ci:local \
2727
--build-arg='PYTHON_VERSIONS=3.10 2.7'
2828

29+
# Ensure python versions are usable
2930
.PHONY: test
3031
test: build
31-
@# Ensure python versions are usable
3232
@docker run --rm ghcr.io/newrelic/python-agent-ci:local /bin/bash -c '\
3333
python3.10 --version && \
3434
python2.7 --version && \

.github/containers/install-python.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ main() {
4545

4646
# Set all installed versions as globally accessible
4747
pyenv global ${PYENV_VERSIONS[@]}
48-
49-
# Install dependencies for main python installation
50-
pyenv exec pip install --upgrade -r /requirements.txt
5148
}
5249

5350
main
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
bandit
2+
black
3+
flake8
4+
isort
15
pip
26
setuptools
3-
wheel
7+
tox
48
virtualenv<20.22.0
5-
tox
9+
wheel

.github/workflows/build-ci-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ jobs:
6363
with:
6464
push: ${{ github.event_name != 'pull_request' }}
6565
context: .github/containers
66-
platforms: linux/amd64
66+
platforms: ${{ (github.ref == 'refs/head/main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
6767
tags: ${{ steps.meta.outputs.tags }}
6868
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)