Skip to content

Commit 86dfa87

Browse files
committed
add docker-compose deployment
1 parent 50a9b93 commit 86dfa87

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DEBUG=0
2+
SECRET_KEY="seeeecret"
3+
DJANGO_SETTINGS_MODULE="qr_service.settings.production"

Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.7
2+
3+
RUN mkdir /app
4+
WORKDIR /app
5+
6+
COPY requirements.txt ./
7+
RUN pip install --no-cache-dir -r requirements.txt
8+
COPY . .

docker-compose.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3'
2+
services:
3+
web:
4+
build: .
5+
container_name: qr_service
6+
volumes:
7+
- .:/app
8+
expose:
9+
- 8000
10+
env_file:
11+
- .env
12+
command: bash -c "gunicorn --workers=3 qr_service.wsgi -b 0.0.0.0:8000"
13+
nginx:
14+
restart: always
15+
build: ./nginx/
16+
volumes:
17+
- ./nginx/:/etc/nginx/conf.d
18+
- ./logs/:/app/logs
19+
ports:
20+
- 1337:80
21+
depends_on:
22+
- web
23+
links:
24+
- web

nginx/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
COPY qr_service.conf /etc/nginx/conf.d

nginx/qr_service.conf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
upstream qr_service {
2+
server web:8000;
3+
}
4+
5+
server {
6+
7+
listen 80;
8+
9+
location / {
10+
proxy_pass http://qr_service;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
proxy_set_header Host $host;
13+
proxy_redirect off;
14+
}
15+
16+
}

0 commit comments

Comments
 (0)