diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f95dc1fe5e..69cf96d616 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -44,3 +44,4 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + target: django-web-prod diff --git a/.github/workflows/docker-test-build.yml b/.github/workflows/docker-test-build.yml index d50a34594f..24631a3168 100644 --- a/.github/workflows/docker-test-build.yml +++ b/.github/workflows/docker-test-build.yml @@ -35,3 +35,4 @@ jobs: push: false build-args: | REQ_FILE=requirements/${{ matrix.req_file }} + target: django-web-dev diff --git a/Dockerfile b/Dockerfile index 19a42f83e8..7741b96db5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # pull official base image -FROM python:3.12-slim-bookworm +FROM python:3.12-slim-bookworm AS django-web-base # set work directory WORKDIR /usr/src/app @@ -33,13 +33,10 @@ RUN apt-get update \ libc6-dev \ libpq-dev \ zlib1g-dev \ - && python3 -m pip install --no-cache-dir -r ${REQ_FILE} \ - && apt-get purge --assume-yes --auto-remove \ - gcc \ - libc6-dev \ - libpq-dev \ - zlib1g-dev \ - && rm -rf /var/lib/apt/lists/* + && python3 -m pip install --no-cache-dir -r ${REQ_FILE} + + +FROM django-web-base AS django-web-dev # install node dependencies COPY ./package.json ./package.json @@ -48,5 +45,15 @@ RUN npm install # copy project COPY . . + +FROM django-web-dev AS django-web-prod + +RUN apt-get purge --assume-yes --auto-remove \ + gcc \ + libc6-dev \ + libpq-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + # ENTRYPOINT is specified only in the local docker-compose.yml to avoid # accidentally running it in deployed environments. diff --git a/docker-compose.yml b/docker-compose.yml index 8f875e2b52..e7daec801f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: build: context: ./ dockerfile: Dockerfile + target: django-web-dev args: - REQ_FILE=requirements/tests.txt entrypoint: ./docker-entrypoint.dev.sh