Skip to content

Commit

Permalink
feat: [OD15-13] Set up NGINX container
Browse files Browse the repository at this point in the history
  • Loading branch information
therealjamesjung committed Oct 12, 2022
1 parent 696b214 commit 9eac7c9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD python -m alembic upgrade head && gunicorn -w 4 -b 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker app.main:app
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
36 changes: 36 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 9eac7c9

Please sign in to comment.