From a2ff33663b437b69bf7a74bdeb554001451764a3 Mon Sep 17 00:00:00 2001 From: Lebaud Antoine Date: Thu, 14 Mar 2024 17:56:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A(docker)=20make=20images=20naming?= =?UTF-8?q?=20consistent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was quite confusing having development, production and frontend images' names in the same Docker file. New comers to the project would have some difficuluties when differentiating frontend from backend images. Try to make these naming more explicit and consistent. Thanks @rouja for your recommendation. --- .github/workflows/docker-hub.yml | 4 ++-- Dockerfile | 6 +++--- docker-compose.yml | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-hub.yml b/.github/workflows/docker-hub.yml index f4381cc..bbb53bf 100644 --- a/.github/workflows/docker-hub.yml +++ b/.github/workflows/docker-hub.yml @@ -42,7 +42,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - target: production + target: backend-production build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} @@ -75,7 +75,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - target: frontend + target: frontend-production build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index eb4c4f5..4d39a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ RUN yarn build # ---- Front-end image ---- -FROM nginxinc/nginx-unprivileged:1.25 as frontend +FROM nginxinc/nginx-unprivileged:1.25 as frontend-production # Un-privileged user running the application ARG DOCKER_USER @@ -147,7 +147,7 @@ WORKDIR /app ENTRYPOINT [ "/usr/local/bin/entrypoint" ] # ---- Development image ---- -FROM core as development +FROM core as backend-development # Switch back to the root user to install development dependencies USER root:root @@ -175,7 +175,7 @@ ENV DB_HOST=postgresql \ CMD python manage.py runserver 0.0.0.0:8000 # ---- Production image ---- -FROM core as production +FROM core as backend-production ARG PEOPLE_STATIC_ROOT=/data/static diff --git a/docker-compose.yml b/docker-compose.yml index 3e6329c..536de6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,11 +19,11 @@ services: app-dev: build: context: . - target: development + target: backend-development args: DOCKER_USER: ${DOCKER_USER:-1000} user: ${DOCKER_USER:-1000} - image: people:development + image: people:backend-development environment: - PYLINTHOME=/app/.pylint.d - DJANGO_CONFIGURATION=Development @@ -43,7 +43,7 @@ services: celery-dev: user: ${DOCKER_USER:-1000} - image: people:development + image: people:backend-development command: ["celery", "-A", "people.celery_app", "worker", "-l", "DEBUG"] environment: - DJANGO_CONFIGURATION=Development @@ -60,11 +60,11 @@ services: app: build: context: . - target: production + target: backend-production args: DOCKER_USER: ${DOCKER_USER:-1000} user: ${DOCKER_USER:-1000} - image: people:production + image: people:backend-production environment: - DJANGO_CONFIGURATION=Demo env_file: @@ -78,7 +78,7 @@ services: celery: user: ${DOCKER_USER:-1000} - image: people:production + image: people:backend-production command: ["celery", "-A", "people.celery_app", "worker", "-l", "INFO"] environment: - DJANGO_CONFIGURATION=Demo