Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base Devcontainer on CI Image #873

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
ARG IMAGE=ghcr.io/newrelic-experimental/pyenv-devcontainer:latest

# To target other architectures, change the --platform directive in the Dockerfile.
FROM --platform=linux/amd64 ${IMAGE}
ARG IMAGE_TAG=latest
FROM ghcr.io/newrelic/newrelic-python-agent-ci:${IMAGE_TAG}

# Setup non-root user
USER root
ARG UID=1000
ARG GID=$UID
ENV HOME /home/vscode
RUN mkdir -p ${HOME} && \
groupadd --gid ${GID} vscode && \
useradd --uid ${UID} --gid ${GID} --home ${HOME} vscode && \
chown -R ${UID}:${GID} /home/vscode
USER ${UID}:${GID}
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// To target other architectures, change the --platform directive in the Dockerfile.
"dockerfile": "Dockerfile",
"args": {
"IMAGE": "ghcr.io/newrelic-experimental/pyenv-devcontainer:latest"
"IMAGE_TAG": "latest"
}
},
"remoteUser": "vscode",
Expand Down
13 changes: 11 additions & 2 deletions .github/containers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
build-essential \
curl \
expat \
fish \
fontconfig \
freetds-common \
freetds-dev \
gcc \
Expand All @@ -46,13 +48,16 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
python2-dev \
python3-dev \
python3-pip \
sudo \
tzdata \
unixodbc-dev \
unzip \
vim \
wget \
zip \
zlib1g \
zlib1g-dev && \
zlib1g-dev \
zsh && \
rm -rf /var/lib/apt/lists/*

# Build librdkafka from source
Expand Down Expand Up @@ -93,6 +98,10 @@ RUN echo 'eval "$(pyenv init -)"' >>$HOME/.bashrc && \
# Install Python
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"
COPY --chown=1000:1000 --chmod=+x ./install-python.sh /tmp/install-python.sh
COPY ./requirements.txt /requirements.txt
RUN /tmp/install-python.sh && \
rm /tmp/install-python.sh

# Install dependencies for main python installation
COPY ./requirements.txt /tmp/requirements.txt
RUN pyenv exec pip install --upgrade -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
4 changes: 2 additions & 2 deletions .github/containers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ REPO_ROOT:=$(realpath $(MAKEFILE_DIR)../../)
.PHONY: default
default: test

# Perform a shortened build for testing
.PHONY: build
build:
@# Perform a shortened build for testing
@docker build $(MAKEFILE_DIR) \
-t ghcr.io/newrelic/newrelic-python-agent-ci:local \
--build-arg='PYTHON_VERSIONS=3.10 2.7'

# Ensure python versions are usable
.PHONY: test
test: build
@# Ensure python versions are usable
@docker run --rm ghcr.io/newrelic/python-agent-ci:local /bin/bash -c '\
python3.10 --version && \
python2.7 --version && \
Expand Down
3 changes: 0 additions & 3 deletions .github/containers/install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ main() {

# Set all installed versions as globally accessible
pyenv global ${PYENV_VERSIONS[@]}

# Install dependencies for main python installation
pyenv exec pip install --upgrade -r /requirements.txt
}

main
8 changes: 6 additions & 2 deletions .github/containers/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
bandit
black
flake8
isort
pip
setuptools
wheel
tox
virtualenv<20.22.0
tox
wheel
2 changes: 1 addition & 1 deletion .github/workflows/build-ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ jobs:
with:
push: ${{ github.event_name != 'pull_request' }}
context: .github/containers
platforms: linux/amd64
platforms: ${{ (github.ref == 'refs/head/main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}