# Docker Production
* adds further settings to create a production-ready docker configuration
This commit is contained in:
parent
670a81c3f5
commit
77855b40ee
@ -15,3 +15,6 @@ RUN pip install -r requirements.txt
|
|||||||
# Copy rest of project into workspace
|
# Copy rest of project into workspace
|
||||||
COPY . /konova/
|
COPY . /konova/
|
||||||
|
|
||||||
|
# Move static files in designated folder
|
||||||
|
RUN python manage.py collectstatic --noinput
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ version: '3.3'
|
|||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
|
container_name: "konova-redis-cache"
|
||||||
volumes:
|
volumes:
|
||||||
- /redis/data:/bitnami/redis/data
|
- /redis/data:/bitnami/redis/data
|
||||||
environment:
|
environment:
|
||||||
@ -13,11 +14,12 @@ services:
|
|||||||
- postgis:db
|
- postgis:db
|
||||||
build: .
|
build: .
|
||||||
container_name: "konova-docker"
|
container_name: "konova-docker"
|
||||||
command: python manage.py runserver 0.0.0.0:8000
|
command: gunicorn konova.wsgi:application --bind 0.0.0.0:8000
|
||||||
volumes:
|
volumes:
|
||||||
- .:/konova
|
- .:/konova
|
||||||
ports:
|
- static_file_volume:/konova/static # Point to the volume for static files. Shared with nginx service
|
||||||
- "8001:8000"
|
expose:
|
||||||
|
- 8000
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
@ -47,9 +49,22 @@ services:
|
|||||||
- POSTGRES_HOST=db
|
- POSTGRES_HOST=db
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
build: ./nginx
|
||||||
|
container_name: "konova-nginx-server"
|
||||||
|
ports:
|
||||||
|
- "1337:80"
|
||||||
|
depends_on:
|
||||||
|
- konova
|
||||||
|
volumes:
|
||||||
|
- static_file_volume:/konova/static # Point to the volume for static files. Shared with konova service
|
||||||
|
|
||||||
# Instead of an own, new network, we need to connect to the existing one, which is provided by the postgis container
|
# Instead of an own, new network, we need to connect to the existing one, which is provided by the postgis container
|
||||||
# NOTE: THIS NETWORK MUST EXIST
|
# NOTE: THIS NETWORK MUST EXIST
|
||||||
networks:
|
networks:
|
||||||
default:
|
default:
|
||||||
external:
|
external:
|
||||||
name: postgis_nat_it_backend
|
name: postgis_nat_it_backend
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
static_file_volume:
|
@ -30,7 +30,7 @@ BASE_DIR = os.path.dirname(
|
|||||||
SECRET_KEY = '5=9-)2)h$u9=!zrhia9=lj-2#cpcb8=#$7y+)l$5tto$3q(n_+'
|
SECRET_KEY = '5=9-)2)h$u9=!zrhia9=lj-2#cpcb8=#$7y+)l$5tto$3q(n_+'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = False
|
||||||
|
|
||||||
ALLOWED_HOSTS = [
|
ALLOWED_HOSTS = [
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
|
4
nginx/Dockerfile
Normal file
4
nginx/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d
|
20
nginx/nginx.conf
Normal file
20
nginx/nginx.conf
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
upstream konova {
|
||||||
|
server konova:8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://konova;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /konova/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -48,3 +48,4 @@ webservices==0.7
|
|||||||
wrapt==1.13.3
|
wrapt==1.13.3
|
||||||
xmltodict==0.12.0
|
xmltodict==0.12.0
|
||||||
zipp==3.4.1
|
zipp==3.4.1
|
||||||
|
gunicorn==20.1.0
|
Loading…
Reference in New Issue
Block a user