diff --git a/Dockerfile b/Dockerfile index d4796bef9a9e21c0477003590cba303732eac90c..0086ad4694357a552d650c06aef28dad434e7733 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,6 @@ RUN npm run build FROM nginx:1.16 COPY --from=build-stage /app/build/ /usr/share/nginx/html COPY ./nginx/nginx.conf /etc/nginx/nginx.conf -COPY ./nginx/site.pro.conf /etc/nginx/conf.d/default.conf +COPY ./nginx/site.prod.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 7d966d379a2f0381d8de14b1c987e2c2117a8a62..66b922b352b4291e0e9f7db7f68cbdded6fba737 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -6,13 +6,14 @@ services: volumes: - ./nginx/site.conf:/etc/nginx/conf.d/default.conf - ./nginx/nginx.conf:/etc/nginx/nginx.conf - command: ["nginx", "-g", "daemon off;"] + - ./cert.pem:/etc/nginx/cert.pem + - ./key.pem:/etc/nginx/key.pem + command: ['nginx', '-g', 'daemon off;'] ports: - - 8081:8080 - networks: - backoffice: - depends_on: - - front + - 8080:8080 + # depends_on: + # front: + # condition: service_healthy links: - front @@ -23,10 +24,52 @@ services: - ./:/usr/app working_dir: /usr/app ports: - - 3000:3000 - networks: - backoffice: + - 3000:3000 + healthcheck: + test: curl localhost:3000 + interval: 5s + timeout: 10s + retries: 60 + + database: + image: mysql:5 + ports: + - 3306:3306 + environment: + MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} + MYSQL_DATABASE: ${DATABASE_NAME} + healthcheck: + test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD + interval: 5s + timeout: 10s + retries: 60 -networks: - backoffice: - \ No newline at end of file + backend: + image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev + depends_on: + database: + condition: service_healthy + restart: unless-stopped + volumes: + - /etc/localtime:/etc/localtime:ro + - ./configs:/app/configs + - ./letsencrypt_cache:/app/letsencrypt_cache + - ./data:/app/data + ports: + - ${HTTPS_PORT}:${HTTPS_PORT} + - 8090:8090 + environment: + - HOSTNAME=${HOSTNAME} + - HTTPS_PORT=${HTTPS_PORT} + - ADMIN_ROLE=${ADMIN_ROLE} + - REDIRECT_URL=${REDIRECT_URL} + - CLIENT_ID=${CLIENT_ID} + - CLIENT_SECRET=${CLIENT_SECRET} + - AUTH_URL=${AUTH_URL} + - TOKEN_URL=${TOKEN_URL} + - USERINFO_URL=${USERINFO_URL} + - DEBUG_MODE=${DEBUG_MODE} + - DATABASE_USER=${DATABASE_USER} + - DATABASE_NAME=${DATABASE_NAME} + - DATABASE_PASSWORD=${DATABASE_PASSWORD} + - DATABASE_HOST=database diff --git a/docker-compose.yml b/docker-compose.yml index 9c6be0459f98bd34b941f05bae45a68b57a1286f..1c8ceab2e59f0fa9f3dcac704113ba6b0196f2ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,14 @@ version: '3.7' services: nginx: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:latest + image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:dev restart: unless-stopped ports: - 443:443 networks: backoffice: volumes: - - ./nginx/site.conf:/etc/nginx/conf.d/default.conf + - ./nginx/site.prod.conf:/etc/nginx/conf.d/default.conf - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./cert.pem:/etc/nginx/cert.pem - ./key.pem:/etc/nginx/key.pem @@ -29,7 +29,7 @@ services: retries: 60 backend: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:latest + image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev networks: backoffice: depends_on: diff --git a/nginx/site.conf b/nginx/site.conf index e6d27c771cb85e336cc864e81228305a257148c7..913c94c852524a6c96472b1e10c4a86ed11820f2 100644 --- a/nginx/site.conf +++ b/nginx/site.conf @@ -1,15 +1,15 @@ server { - listen 443 ssl; + listen 8080 ; server_name localhost; - ssl_certificate /etc/nginx/cert.pem; - ssl_certificate_key /etc/nginx/key.pem; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - ssl_ciphers HIGH:!aNULL:!MD5; location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; + proxy_pass https://front:3000; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /api { proxy_pass https://backend:1443/api; diff --git a/nginx/site.pro.conf b/nginx/site.pro.conf deleted file mode 100644 index a99902a9abb68c1a43c70f34626108233e4854c0..0000000000000000000000000000000000000000 --- a/nginx/site.pro.conf +++ /dev/null @@ -1,10 +0,0 @@ -server { - listen 80; - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; - } -} diff --git a/nginx/site.prod.conf b/nginx/site.prod.conf new file mode 100644 index 0000000000000000000000000000000000000000..e6d27c771cb85e336cc864e81228305a257148c7 --- /dev/null +++ b/nginx/site.prod.conf @@ -0,0 +1,26 @@ +server { + listen 443 ssl; + server_name localhost; + ssl_certificate /etc/nginx/cert.pem; + ssl_certificate_key /etc/nginx/key.pem; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers HIGH:!aNULL:!MD5; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } + location /api { + proxy_pass https://backend:1443/api; + } + location /OAuth2Login { + proxy_pass https://backend:1443/OAuth2Login; + } + location /OAuth2Callback { + proxy_pass https://backend:1443/OAuth2Callback; + } + location /Logout { + proxy_pass https://backend:1443/Logout; + } +}