Merge pull request 'Docker_worker_enhance' (#155) from Docker_worker_enhance into Docker

Reviewed-on: SGD-Nord/konova#155
This commit is contained in:
mpeltriaux 2022-05-09 11:05:33 +02:00
commit a7b8752119
5 changed files with 29 additions and 71 deletions

View File

@ -1,17 +1,21 @@
FROM python:3.7-slim
FROM python:3.9-slim
ENV PYTHONUNBUFFERED 1
WORKDIR /konova
# Install some dependencies
RUN apt update
RUN apt install -y gdal-bin
RUN apt install -y gdal-bin redis-server nginx
# Copy requirements file into workspace
# Copy requirements file into workspace and install all dependencies
COPY ./requirements.txt /konova/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Remove nginx default configuration and replace with own configuration
RUN rm /etc/nginx/sites-enabled/default
COPY ./nginx.conf /etc/nginx/conf.d
# Copy rest of project into workspace
COPY . /konova/

View File

@ -1,75 +1,30 @@
version: '3.3'
services:
redis:
image: redis
container_name: "konova-redis-cache"
volumes:
- /redis/data:/bitnami/redis/data
environment:
- REDIS_PASSWORD=CHANGE_ME
konova:
external_links:
- postgis:db
- arnova-nginx-server:arnova
build: .
container_name: "konova-docker"
command: gunicorn konova.wsgi:application --bind 0.0.0.0:8000
command: ./docker-entrypoint.sh
restart: always
volumes:
- .:/konova
- konova_uploaded_files:/konova_uploaded_files
- static_file_volume:/konova/static # Point to the volume for static files. Shared with nginx service
expose:
- 8000
depends_on:
- redis
environment:
- POSTGRES_NAME=konova
- POSTGRES_PORT=5432
- POSTGRES_PASSWORD=CHANGE_ME
- POSTGRES_USER=konova
- POSTGRES_HOST=db
- REDIS_HOST=redis
- SSO_HOST=CHANGE_ME_TO_SSO_HOST_URL
- SMTP_HOST=172.17.0.1
- SMTP_PORT=25
- SMTP_REAL_REPLY_MAIL=ksp-servicestelle@sgdnord.rlp.de
# To provide a celery worker instance, we need to add the celery worker as an own service
celery_worker:
external_links:
- postgis:db
- arnova-nginx-server:arnova
build: .
container_name: "konova-worker-docker"
command: celery -A konova worker -l INFO
volumes:
- .:/konova
- konova_uploaded_files:/konova_uploaded_files
depends_on:
- konova
environment:
- POSTGRES_NAME=konova
- POSTGRES_PORT=5432
- POSTGRES_PASSWORD=CHANGE_ME
- POSTGRES_USER=konova
- POSTGRES_HOST=db
- REDIS_HOST=redis
- SSO_HOST=CHANGE_ME_TO_SSO_HOST_URL
- SMTP_HOST=172.17.0.1
- SMTP_PORT=25
- SMTP_REAL_REPLY_MAIL=ksp-servicestelle@sgdnord.rlp.de
nginx:
build: ./nginx
container_name: "konova-nginx-server"
- /data/apps/konova/uploaded_files:/konova_uploaded_files
ports:
- "1337:80"
depends_on:
- konova
volumes:
- static_file_volume:/konova/static # Point to the volume for static files. Shared with konova service
environment:
- POSTGRES_NAME=konova
- POSTGRES_PORT=5432
- POSTGRES_PASSWORD=CHANGE_ME
- POSTGRES_USER=konova
- POSTGRES_HOST=db
- REDIS_HOST=localhost
- SSO_HOST=CHANGE_ME_TO_SSO_HOST_URL
- SMTP_HOST=172.17.0.1
- SMTP_PORT=25
- SMTP_REAL_REPLY_MAIL=ksp-servicestelle@sgdnord.rlp.de
# 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
@ -77,7 +32,3 @@ networks:
default:
external:
name: postgis_nat_it_backend
volumes:
static_file_volume:
konova_uploaded_files:

7
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# Start all needed services once the container is fired up!
service nginx start
service redis-server start
celery -A konova worker --detach
# Rule of thumb: (2*CPU)+1 as worker_num -> Use 5 as default (matches a dual core)
gunicorn --workers=5 konova.wsgi:application --bind=0.0.0.0:8000

View File

@ -1,5 +1,5 @@
upstream konova {
server konova:8000;
server localhost:8000;
}
server {

View File

@ -1,4 +0,0 @@
FROM nginx:alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d