diff --git a/config/nginx/proxy.conf b/config/nginx/proxy.conf index e69de29..82b0fad 100644 --- a/config/nginx/proxy.conf +++ b/config/nginx/proxy.conf @@ -0,0 +1,49 @@ +server { + listen 80; + + resolver 127.0.0.11 ipv6=off valid=10s; + + # . files + location ~ /\.(?!well-known) { + deny all; + } + + # logging + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log warn; + + # reverse proxy + location / { + proxy_pass http://app:3000$request_uri; + proxy_set_header Host $host; + proxy_http_version 1.1; + + # proxy headers + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + + # proxy timeouts + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + } + + # favicon.ico + location = /favicon.ico { + log_not_found off; + } + + # robots.txt + location = /robots.txt { + log_not_found off; + } + + # gzip + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; +} diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..2e9ade6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +version: '3' + +services: + + proxy: + container_name: proxy + image: nginx:latest + ports: + - '${PROXY_PORT:-80}:80' + - '${PROXY_PORT_SSL:-443}:443' + volumes: + - './config/nginx/proxy.conf:/etc/nginx/conf.d/default.conf' + networks: + - c3d_net + depends_on: + - app + + app: + container_name: app + build: + context: . + dockerfile: Dockerfile + ports: + - '${FORWARD_APP_PORT:-3000}:3000' + networks: + - c3d_net + depends_on: + - db + + db: + container_name: db + image: 'postgres:latest' + ports: + - '${FORWARD_DB_PORT:-5432}:5432' + environment: + PGPASSWORD: '${DB_PASSWORD:-secret}' + POSTGRES_DB: '${DB_DATABASE}' + POSTGRES_USER: '${DB_USERNAME}' + POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' + volumes: + - 'c3d_vol:/var/lib/postgresql/data' + networks: + - c3d_net + healthcheck: + test: [ "CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}" ] + retries: 3 + timeout: 5s + +volumes: + c3d_vol: + driver: local + +networks: + c3d_net: + driver: bridge