commit 0767ee6530fc80031d398ae15aefddeed3661847 Author: adb-sh Date: Fri Sep 30 20:59:08 2022 +0200 add project files diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8490bf3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: '3' + +services: + redis: + image: redis:alpine + expose: + - 6379 + restart: always + environment: + - REDIS_REPLICATION_MODE=master + + backend: + image: node:alpine + restart: always + expose: + - 3000 + volumes: + - ./backend/:/home/node/app/backend/ + - ./helpers/:/home/node/app/helpers/ + working_dir: /home/node/app/backend + environment: + - NODE_ENV=production + command: sh -c 'npm i && nodejs index.mjs' + links: + - redis + depends_on: + - redis + + frontend: + image: node:alpine + volumes: + - ./frontend/:/home/node/app/frontend/ + working_dir: /home/node/app/frontend + command: sh -c 'npm i --also=dev && npm run build' + + nginx: + image: nginx:alpine + restart: always + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./frontend/dist/:/var/www/html/ + ports: + - "8083:8080" + links: + - backend + depends_on: + - backend diff --git a/docker-compose.yml.example b/docker-compose.yml.example new file mode 100644 index 0000000..eded188 --- /dev/null +++ b/docker-compose.yml.example @@ -0,0 +1,47 @@ +version: '3' + +services: + redis: + image: redis:alpine + expose: + - 6379 + restart: always + environment: + - REDIS_REPLICATION_MODE=master + + backend: + image: node:alpine + restart: always + expose: + - 3000 + volumes: + - ./backend/:/home/node/app/backend/ + - ./helpers/:/home/node/app/helpers/ + working_dir: /home/node/app/backend + environment: + - NODE_ENV=production + command: sh -c 'npm i && nodejs index.mjs' + links: + - redis + depends_on: + - redis + + frontend: + image: node:alpine + volumes: + - ./frontend/:/home/node/app/frontend/ + working_dir: /home/node/app/frontend + command: sh -c 'npm i --also=dev && npm run build' + + nginx: + image: nginx:alpine + restart: always + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./frontend/dist/:/var/www/html/ + ports: + - "8080:8080" + links: + - backend + depends_on: + - backend diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..5585524 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,91 @@ +worker_processes auto; +worker_cpu_affinity auto; + +error_log /var/log/nginx/error.log; +pid /var/run/nginx.pid; + +#daemon off; +events { + worker_connections 1024; +} + +http { +# rewrite_log on; + include mime.types; + default_type application/json; + access_log /var/log/nginx/access.log; + sendfile on; +# tcp_nopush on; + keepalive_timeout 3; +# tcp_nodelay on; +# gzip on; + client_max_body_size 1m; + + server { + listen 8080 default_server; + server_name _; + + error_page 400 = @400; + location @400 { return 400 '{"status":400,"message":"Bad request"}\n'; } + + error_page 401 = @401; + location @401 { return 401 '{"status":401,"message":"Unauthorized"}\n'; } + + error_page 403 = @403; + location @403 { return 403 '{"status":403,"message":"Forbidden"}\n'; } + + error_page 404 = @404; + location @404 { return 404 '{"status":404,"message":"Resource not found"}\n'; } + + error_page 405 = @405; + location @405 { return 405 '{"status":405,"message":"Method not allowed"}\n'; } + + error_page 408 = @408; + location @408 { return 408 '{"status":408,"message":"Request timeout"}\n'; } + + error_page 413 = @413; + location @413 { return 413 '{"status":413,"message":"Payload too large"}\n'; } + + error_page 414 = @414; + location @414 { return 414 '{"status":414,"message":"Request URI too large"}\n'; } + + error_page 415 = @415; + location @415 { return 415 '{"status":415,"message":"Unsupported media type"}\n'; } + + error_page 426 = @426; + location @426 { return 426 '{"status":426,"message":"HTTP request was sent to HTTPS port"}\n'; } + + error_page 429 = @429; + location @429 { return 429 '{"status":429,"message":"API rate limit exceeded"}\n'; } + + error_page 495 = @495; + location @495 { return 495 '{"status":495,"message":"Client certificate authentication error"}\n'; } + + error_page 496 = @496; + location @496 { return 496 '{"status":496,"message":"Client certificate not presented"}\n'; } + + error_page 497 = @497; + location @497 { return 497 '{"status":497,"message":"HTTP request was sent to mutual TLS port"}\n'; } + + error_page 500 = @500; + location @500 { return 500 '{"status":500,"message":"Server error"}\n'; } + + error_page 501 = @501; + location @501 { return 501 '{"status":501,"message":"Not implemented"}\n'; } + + error_page 502 = @502; + location @502 { return 502 '{"status":502,"message":"Bad gateway"}\n'; } + + + location / { + index index.html; + root /var/www/html; + try_files $uri $uri/ /index.html; + } + + location /api { + default_type application/json; + proxy_pass http://backend:3000; + } + } +}