diff --git a/infra/prod/Dockerfile b/infra/prod/Dockerfile index 878e97d..654cda3 100644 --- a/infra/prod/Dockerfile +++ b/infra/prod/Dockerfile @@ -61,6 +61,7 @@ RUN rm -f /etc/nginx/sites-enabled/default # Configs COPY infra/prod/supervisord.conf /etc/supervisor/conf.d/app.conf COPY infra/prod/nginx.conf /etc/nginx/sites-enabled/lesstime.conf +COPY infra/prod/maintenance.html /var/www/html/public/maintenance.html # Backend from stage 1 COPY --from=backend-build /app /var/www/html diff --git a/infra/prod/deploy.sh b/infra/prod/deploy.sh index 7ae8a77..2b1eb16 100755 --- a/infra/prod/deploy.sh +++ b/infra/prod/deploy.sh @@ -8,6 +8,9 @@ export LESSTIME_IMAGE_TAG="$TAG" echo "==> Deploying lesstime:${TAG}..." +echo "==> Enabling maintenance mode..." +touch maintenance.on + echo "==> Pulling image..." sudo docker compose pull @@ -24,5 +27,8 @@ echo "==> Clearing cache..." sudo docker compose exec -T -u www-data app php bin/console cache:clear --env=prod sudo docker compose exec -T -u www-data app php bin/console cache:warmup --env=prod +echo "==> Disabling maintenance mode..." +rm -f maintenance.on + VERSION=$(sudo docker compose exec -T app cat config/version.yaml | grep 'app.version' | awk -F"'" '{print $2}') echo "==> Deployed v${VERSION}" diff --git a/infra/prod/maintenance.html b/infra/prod/maintenance.html new file mode 100644 index 0000000..c8ef615 --- /dev/null +++ b/infra/prod/maintenance.html @@ -0,0 +1,49 @@ + + + + + + Maintenance en cours + + + +
+
🛠
+

Maintenance en cours

+

L'application est temporairement indisponible pour mise à jour. Elle sera de retour dans quelques instants.

+
+ + diff --git a/infra/prod/nginx.conf b/infra/prod/nginx.conf index e058faf..afe9182 100644 --- a/infra/prod/nginx.conf +++ b/infra/prod/nginx.conf @@ -2,6 +2,23 @@ server { listen 80; server_name _; + # Maintenance mode + if (-f /var/www/html/maintenance.on) { + return 503; + } + + error_page 503 @maintenance; + + location @maintenance { + root /var/www/html/public; + rewrite ^(.*)$ /maintenance.html break; + } + + location = /maintenance.html { + root /var/www/html/public; + internal; + } + root /var/www/html/frontend/.output/public; index index.html;