From 567a765f949ee9dd391bbe1d6e594785527431ff Mon Sep 17 00:00:00 2001 From: Gabriel Matte Date: Sat, 7 Dec 2024 14:58:15 -0500 Subject: [PATCH] fixed nginx --- client/Dockerfile | 5 +++-- docker-compose.local.yaml | 30 +++++++++++++++++++++--------- nginx/Dockerfile | 3 ++- server/Dockerfile | 3 ++- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index de13cac..32d487b 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -12,9 +12,10 @@ RUN npm install RUN npm run build -EXPOSE 5173 +ENV PORT=5173 +EXPOSE ${PORT} HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ - CMD curl -f http://localhost:5173 || exit 1 + CMD curl -f http://localhost:${PORT} || exit 1 CMD [ "npm", "run", "preview" ] \ No newline at end of file diff --git a/docker-compose.local.yaml b/docker-compose.local.yaml index 7f1fba5..62de779 100644 --- a/docker-compose.local.yaml +++ b/docker-compose.local.yaml @@ -3,21 +3,29 @@ version: '3' services: frontend: + container_name: frontend build: context: ./client dockerfile: Dockerfile - container_name: frontend ports: - "5173:5173" networks: - quiz_network restart: always + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:$${PORT} || exit 1"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 backend: build: context: ./server dockerfile: Dockerfile container_name: backend + networks: + - quiz_network ports: - "3000:3000" volumes: @@ -30,14 +38,12 @@ services: SENDER_EMAIL: infoevaluetonsavoir@gmail.com EMAIL_PSW: 'vvml wmfr dkzb vjzb' JWT_SECRET: haQdgd2jp09qb897GeBZyJetC8ECSpbFJe - FRONTEND_URL: "http://localhost:5173" - #QUIZROOM_IMAGE: ghcr.io/ets-cfuhrman-pfe/evaluetonsavoir-quizroom:latest - depends_on: - mongo: - condition: service_healthy - networks: - - quiz_network - restart: always + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:$${PORT}/health || exit 1"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 quizroom: # Forces image to update build: @@ -49,6 +55,12 @@ services: networks: - quiz_network restart: always + healthcheck: + test: ["CMD", "/usr/src/app/healthcheck.sh"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 nginx: build: diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 3fc92ad..ba9252e 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -85,4 +85,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD wget -q --spider http://0.0.0.0:${PORT}/health || exit 1 # Start Nginx using entrypoint script -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +# CMD [ "/bin/sh","-c","sleep 3600" ] # For debugging +ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile index 12713de..8dbd6ff 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -8,7 +8,8 @@ RUN npm install COPY ./ . -EXPOSE 4400 +ENV PORT=3000 +EXPOSE ${PORT} HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:${PORT}/health || exit 1