diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc4e370 --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/config/nginx/nginx.conf b/config/nginx/nginx.conf new file mode 100644 index 0000000..97b2cb7 --- /dev/null +++ b/config/nginx/nginx.conf @@ -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; +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bfb4bb7 --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d33e348..5824c9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +drf-yasg==1.20.0 +gunicorn==20.1.0 \ No newline at end of file