Skip to content

Commit 936f4bd

Browse files
committed
Update Docker layer & Dependencies
1 parent 51c6503 commit 936f4bd

File tree

5 files changed

+68
-24
lines changed

5 files changed

+68
-24
lines changed

Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
FROM python:3.9.5-slim-buster
2-
3-
WORKDIR /usr/src/app
1+
FROM python:3.9
42

3+
# set environment variables
54
ENV PYTHONDONTWRITEBYTECODE 1
65
ENV PYTHONUNBUFFERED 1
76

8-
RUN apt-get update \
9-
&& apt-get -y install netcat gcc \
10-
&& apt-get clean
11-
7+
COPY requirements.txt .
8+
# install python dependencies
129
RUN pip install --upgrade pip
13-
COPY ./requirements.txt .
14-
RUN pip install -r requirements.txt
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
12+
COPY . .
13+
14+
# running migrations
15+
RUN python manage.py migrate
16+
17+
# gunicorn
18+
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]

docker-compose.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
version: '3.8'
2-
32
services:
4-
app-server-django:
5-
build: ./
6-
command: >
7-
sh -c "python manage.py flush --no-input &&
8-
python manage.py migrate &&
9-
python manage.py runserver 0.0.0.0:8000"
10-
volumes:
11-
- ./:/usr/src/app/
3+
appseed-app:
4+
container_name: appseed_app
5+
restart: always
6+
env_file: .env
7+
build: .
8+
networks:
9+
- db_network
10+
- web_network
11+
nginx:
12+
container_name: nginx
13+
restart: always
14+
image: "nginx:latest"
1215
ports:
13-
- 5000:8000
14-
env_file:
15-
- ./.env
16+
- "5000:5000"
17+
volumes:
18+
- ./nginx:/etc/nginx/conf.d
19+
networks:
20+
- web_network
21+
depends_on:
22+
- appseed-app
23+
networks:
24+
db_network:
25+
driver: bridge
26+
web_network:
27+
driver: bridge
28+

gunicorn-cfg.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
bind = '0.0.0.0:5005'
7+
workers = 1
8+
accesslog = '-'
9+
loglevel = 'debug'
10+
capture_output = True
11+
enable_stdio_inheritance = True

nginx/appseed-app.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
upstream webapp {
2+
server appseed_app:5005;
3+
}
4+
5+
server {
6+
listen 5000;
7+
server_name localhost;
8+
9+
location / {
10+
proxy_pass http://webapp;
11+
proxy_set_header Host $host;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
}
14+
15+
}

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Django==4.0.1
1+
Django==3.2.13
22
djangorestframework==3.13.1
3-
PyJWT==2.3.0
4-
django-cors-headers==3.11.0
3+
PyJWT==2.4.0
4+
django-cors-headers==3.13.0
5+
gunicorn==20.1.0

0 commit comments

Comments
 (0)