diff --git a/Dockerfile b/Dockerfile index aad14222..6e35526c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ diff --git a/docker-compose.yml b/docker-compose.yml index a67fb2ff..c7bd3f4b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..e9f2cea2 --- /dev/null +++ b/docker-entrypoint.sh @@ -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 \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx.conf similarity index 91% rename from nginx/nginx.conf rename to nginx.conf index 26b326ca..373393a2 100644 --- a/nginx/nginx.conf +++ b/nginx.conf @@ -1,5 +1,5 @@ upstream konova { - server konova:8000; + server localhost:8000; } server { diff --git a/nginx/Dockerfile b/nginx/Dockerfile deleted file mode 100644 index 4c49d2ee..00000000 --- a/nginx/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM nginx:alpine - -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d \ No newline at end of file