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

@ -1,17 +1,9 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Dockerfile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/06/12 16:42:38 by maiboyer #+# #+# #
# Updated: 2025/07/29 13:58:39 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
FROM frontend AS frontend-files
FROM nginx:stable-alpine
ENV NGINX_DOMAIN "local.maix.me"
RUN \
mkdir -p /volumes/ && \
mkdir -p /etc/nginx/ && \
@ -21,15 +13,17 @@ RUN \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/nginx-selfsigned.key \
-out /etc/ssl/certs/nginx-selfsigned.crt \
-subj "/C=FR/OU=student/CN=${NGINX_DOMAIN}"
-subj "/C=FR/OU=student/CN=${NGINX_DOMAIN}";
COPY ./15-local-resolvers.envsh /docker-entrypoint.d/
COPY ./17-add-template-prefix.sh /docker-entrypoint.d/
COPY ./15-local-resolvers.envsh /docker-entrypoint.d/
COPY ./17-add-template-prefix.sh /docker-entrypoint.d/
COPY ./conf /etc/nginx/templates
COPY ./conf /etc/nginx/templates
COPY ./monitoring.index.html /var/share/www/monitoring/
COPY ./monitoring.index.html /var/share/www/monitoring/
COPY --from=frontend-files /src/dist /var/share/www/static/
RUN chmod -R +r /var/share/www/monitoring/;
RUN chmod -R +r /var/share/www/static/;
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f -s http://localhost:8080/ok?docker || exit 1;
CMD curl -f -s http://localhost:8080/ok?docker || exit 1;