aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/lint-test-build-push.yaml7
-rw-r--r--Dockerfile17
2 files changed, 15 insertions, 9 deletions
diff --git a/.github/workflows/lint-test-build-push.yaml b/.github/workflows/lint-test-build-push.yaml
index a76354b..e86096f 100644
--- a/.github/workflows/lint-test-build-push.yaml
+++ b/.github/workflows/lint-test-build-push.yaml
@@ -73,6 +73,7 @@ jobs:
push: false
load: true
target: venv
+ build-args: DEV=1
cache-from: |
type=local,src=/tmp/.buildx-cache
ghcr.io/python-discord/snekbox-base:latest
@@ -85,12 +86,6 @@ jobs:
export IMAGE_SUFFIX='-venv:${{ steps.sha_tag.outputs.tag }}'
docker-compose up --no-build -d
- # One of the unit tests needs to import numpy.
- - name: Install dependencies
- run: >-
- docker exec snekbox_dev /bin/bash -c
- 'pipenv install --system --deploy --dev && pip install numpy'
-
# Required by pre-commit.
- name: Install git
run: >-
diff --git a/Dockerfile b/Dockerfile
index 2aee11b..7e8d4ba 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -44,13 +44,24 @@ RUN chmod +x /usr/sbin/nsjail
# ------------------------------------------------------------------------------
FROM base as venv
-ARG DEV
COPY Pipfile Pipfile.lock /snekbox/
WORKDIR /snekbox
-# Install to the default user site since PIP_USER is set.
-RUN pipenv install --deploy --system ${DEV:+--dev}
+# Pipenv installs to the default user site since PIP_USER is set.
+RUN pipenv install --deploy --system
+
+# This must come after the first pipenv command! From the docs:
+# All RUN instructions following an ARG instruction use the ARG variable
+# implicitly (as an environment variable), thus can cause a cache miss.
+ARG DEV
+
+# Install numpy when in dev mode; one of the unit tests needs it.
+RUN if [ -n "${DEV}" ]; \
+ then \
+ pipenv install --deploy --system --dev \
+ && PYTHONUSERBASE=/snekbox/user_base pip install numpy~=1.19; \
+ fi
# At the end to avoid re-installing dependencies when only a config changes.
# It's in the venv image because the final image is not used during development.