diff --git a/Dockerfile b/Dockerfile index 7093411..aab81cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,6 @@ ENV DB_HOST=${DB_HOST} ENV DB_PORT=${DB_PORT} ENV DB_NAME=${DB_NAME} ENV RIOT_TOKEN=${RIOT_TOKEN} -EXPOSE 80 +EXPOSE 8000 COPY . /app -CMD python -m alembic upgrade head && gunicorn -w 4 -b 0.0.0.0:80 -k uvicorn.workers.UvicornWorker app.main:app \ No newline at end of file +CMD python -m alembic upgrade head && gunicorn -w 4 -b 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker app.main:app \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 53fbdfe..8844d32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,8 +24,17 @@ services: - DB_NAME=${DB_NAME} - RIOT_TOKEN=${RIOT_TOKEN} restart: always + ports: + - 8000:8000 + + nginx: + image: nginx:stable-alpine + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf ports: - 80:80 + depends_on: + - app volumes: db_data: \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..fed0dae --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ +user nginx; +worker_processes 4; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + + upstream 15gg-app { + server app:8000; + } + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://15gg-app; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } + + 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; + include /etc/nginx/conf.d/*.conf; +}