feat(docker): Multi stage docker now fetch deps once

Split dockerfile into three different dockerfiles such that dependencies
are only downloaded once

This allows the build to be a bit faster, since all deps are downloaded
once at the start.

This also makes it so the frontend container no longer needs to be ran,
as its files are directly embedded into the nginx container

This also remove the extra files, since bind mounts do work
it also remove the entrypoint.sh file, as you should prefer to not use
it
This commit is contained in:
Maieul BOYER 2025-12-30 17:28:06 +01:00 committed by Maix0
parent af13395f2f
commit 2ed524872b
17 changed files with 93 additions and 128 deletions

View file

@ -5,22 +5,41 @@ networks:
driver: bridge
services:
##########
# DEPS #
##########
pnpm_base:
build:
context: ./src
dockerfile: '@dockerfiles/pnpm.Dockerfile'
restart: on-failure:3
pnpm_deps:
build:
context: ./src
dockerfile: '@dockerfiles/deps.Dockerfile'
additional_contexts:
pnpm_base: "service:pnpm_base"
restart: on-failure:3
frontend:
build: ./frontend
build:
context: ./frontend
additional_contexts:
pnpm_base: "service:pnpm_base"
container_name: app-frontend
restart: on-failure:3
networks:
- app
volumes:
- static-volume:/volumes/static
logging:
driver: gelf
options:
gelf-address: "udp://127.0.0.1:12201"
tag: "{{.Name}}"
############
# SERVICES #
############
nginx:
build: ./nginx
build:
context: ./nginx
additional_contexts:
frontend: "service:frontend"
container_name: app-nginx
restart: always
networks:
@ -41,15 +60,14 @@ services:
gelf-address: "udp://127.0.0.1:12201"
tag: "{{.Name}}"
###############
# SERVICE #
###############
auth:
build:
context: ./src/
args:
- SERVICE=auth
additional_contexts:
pnpm_base: "service:pnpm_base"
pnpm_deps: "service:pnpm_deps"
container_name: app-auth
restart: always
networks:
@ -74,6 +92,9 @@ services:
context: ./src/
args:
- SERVICE=tic-tac-toe
additional_contexts:
pnpm_base: "service:pnpm_base"
pnpm_deps: "service:pnpm_deps"
container_name: app-tic-tac-toe
restart: always
networks:
@ -97,6 +118,9 @@ services:
context: ./src/
args:
- SERVICE=chat
additional_contexts:
pnpm_base: "service:pnpm_base"
pnpm_deps: "service:pnpm_deps"
container_name: app-chat
restart: always
networks:
@ -119,6 +143,9 @@ services:
context: ./src/
args:
- SERVICE=user
additional_contexts:
pnpm_base: "service:pnpm_base"
pnpm_deps: "service:pnpm_deps"
container_name: app-user
restart: always
networks: