diff --git a/backend/Dockerfile b/backend/Dockerfile index 0000881..1cb3f4c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -19,4 +19,6 @@ ENV ENABLE_CIRCUITBREAKER=true RUN python setup.py install +EXPOSE 8080 + CMD /bin/sh entrypoint.sh diff --git a/contrib/nginx.conf b/contrib/nginx.conf index 9814509..54fa3b3 100644 --- a/contrib/nginx.conf +++ b/contrib/nginx.conf @@ -1,52 +1,38 @@ -user nginx; -worker_processes 1; -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; events { - worker_connections 1024; + worker_connections 1024; } - http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; - sendfile on; - keepalive_timeout 65; - map $http_upgrade $connection_upgrade { - default upgrade; - '' close; - } - + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; server { - listen 80; - root /usr/share/nginx/html; - - client_max_body_size 0; - proxy_request_buffering off; - proxy_read_timeout 7200; - - resolver 127.0.0.11 valid=5s; - set $backend_upstream backend; - set $frontend_upstream frontend; - + listen 80; + server_name localhost; + resolver 127.0.0.11; + location / { + set $frontend_upstream frontend; + proxy_pass http://$frontend_upstream:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP ip_address; + } location /api { + set $backend_upstream backend; proxy_pass http://$backend_upstream:8080; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - proxy_read_timeout 3600s; + proxy_set_header Host $host; + proxy_set_header X-Real-IP ip_address; } - - location / { - proxy_pass http://$frontend_upstream:8000/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - proxy_read_timeout 3600s; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; } } -} +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 37ffe70..4c23d66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,11 @@ -# - +--- version: "3.7" services: nginx: image: nginx:stable-alpine ports: - - "80:80" + - "8081:80" volumes: - ./contrib/nginx.conf:/etc/nginx/nginx.conf networks: @@ -14,15 +13,13 @@ services: frontend: build: ./frontend - image: magfest/tuber:latest-frontend - ports: - - "8000:8000" + image: ghcr.io/claughinghouse/tuber-frontend:latest networks: - tuber backend: build: ./backend - image: magfest/tuber:latest-backend + image: ghcr.io/claughinghouse/tuber-backend:latest depends_on: - postgres - redis @@ -33,16 +30,16 @@ services: FLASK_ENV: production WORKERS: 4 CIRCUITBREAKER_THREADS: 4 - scale: 1 + # scale: 1 networks: - tuber postgres: - image: postgres:10.4 + image: postgres:alpine environment: - POSTGRES_PASSWORD: tuber - POSTGRES_USER: tuber - POSTGRES_DB: tuber + - POSTGRES_PASSWORD=tuber + - POSTGRES_USER=tuber + - POSTGRES_DB=tuber ports: - "5432" volumes: diff --git a/frontend/.dockerignore b/frontend/.dockerignore index 40b878d..569ce53 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +**/node_modules +**/dist \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d4f5eae..d197459 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,21 +1,11 @@ -# build stage -FROM node:lts-alpine as build-stage - +FROM node:alpine as build-stage WORKDIR /app - COPY package*.json ./ - RUN npm install - -COPY . . - +COPY ./ . RUN npm run build -# production stage -FROM nginx:stable-alpine as production-stage - -COPY --from=build-stage /app/dist /usr/share/nginx/html - -EXPOSE 80 - -CMD ["nginx", "-g", "daemon off;"] +FROM nginx:alpine as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /app +COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/frontend/nginx.conf b/frontend/nginx.conf index f047b21..385df25 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -1,10 +1,30 @@ -server { - listen ${PORT}; - server_name ${SERVER_NAME}; - root /var/www/; - index index.html; - +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; location / { - try_files $uri /index.html; + root /app; + index index.html; + try_files $uri $uri/ /index.html; } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } } \ No newline at end of file