Skip to content

Commit

Permalink
feat: 배포를 위한 설정 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pasitoapasito committed Jul 18, 2022
1 parent c63c985 commit 959f8ef
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.9

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

WORKDIR /usr/src/app

COPY requirements.txt ./

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY . /usr/src/app
20 changes: 20 additions & 0 deletions config/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
upstream django-backend {
ip_hash;
server django-backend:8000;
}

server {
location / {
proxy_set_header X-Forwarded-Host localhost;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header Host $http_host;
proxy_pass http://django-backend/;
}

location /static {
alias /static;
}
listen 80;
server_name localhost;
}
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3"
services:
django-backend:
container_name: django-backend
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- "8000:8000"
env_file:
- .env
command:
- bash
- -c
- |
echo yes | python manage.py collectstatic
gunicorn ideaconcert.wsgi:application --bind 0.0.0.0:8000
volumes:
- .:/usr/src/app

nginx:
image: nginx:1.21
container_name: nginx
restart: always
volumes:
- ./config/nginx:/etc/nginx/conf.d
- ./static:/static
ports:
- "80:80"
depends_on:
- django-backend
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ django-cors-headers==3.13.0
django-extensions==3.2.0
ipython==8.4.0
python-dotenv==0.20.0
drf-yasg==1.20.0
drf-yasg==1.20.0
gunicorn==20.1.0

0 comments on commit 959f8ef

Please sign in to comment.