Skip to content

Commit

Permalink
Merge pull request #226 from kit-data-manager/docker-compose
Browse files Browse the repository at this point in the history
Restructure docker compose files
  • Loading branch information
FelixFrizzy authored Dec 16, 2024
2 parents a3cc6b2 + 701bd1d commit 363a729
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 56 deletions.
13 changes: 7 additions & 6 deletions .example.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
INSTANCE_NAME=
EVOKS_PORT=
SKOSMOS_DEV_PORT=
SKOSMOS_LIVE_PORT=
PROXY_PORT=
PUBLICURL=
EVOKS_MAIL=
FUSEKI_PASSWORD=
POSTGRES_USER=
POSTGRES_PASSWORD=
# example evoks_url for reverse-proxy: /evoks
# example EVOKS_URL for reverse-proxy: /evoks
EVOKS_URL=
# all following only needed for development:
# all following only needed for development and or for running without proxy:
POSTGRES_PORT=
FUSEKI_DEV_PORT=
FUSEKI_LIVE_PORT=
FUSEKI_LIVE_PORT=
EVOKS_PORT=
SKOSMOS_DEV_PORT=
SKOSMOS_LIVE_PORT=
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ RUN apt-get update \
&& apt-get install -y build-essential curl git \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs --no-install-recommends \
&& apt-get install -y gettext-base \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean


COPY requirements*.txt ./

RUN pip install -r requirements.txt
Expand Down
28 changes: 14 additions & 14 deletions docker-compose.custom-test.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
services:
proxy:
container_name: evokstest_proxy
restart: "no"

postgres:
container_name: evokstest_postgres
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'changeme'
restart: no
restart: "no"

web:
container_name: evokstest_testrunner
command: >
entrypoint: >
sh -c "set -e &&
export BASEHREF &&
envsubst '$$BASEHREF' < /code/skosmos-dev/config-template.ttl > /code/skosmos-dev/config.ttl &&
envsubst '$$BASEHREF' < /code/skosmos-live/config-template.ttl > /code/skosmos-live/config.ttl &&
cd ./evoks &&
python manage.py migrate &&
coverage run manage.py test -v 3 tests/model/ tests/migration/ tests/skosmos/ tests/fuseki/ tests/views/ tests/evoks &&
coverage report &&
coverage xml"
restart: no
restart: "no"

fuseki-dev:
container_name: evokstest_fuseki-dev
environment:
ADMIN_PASSWORD: 'fuseki_password'
restart: no
restart: "no"

fuseki-live:
container_name: evokstest_fuseki-live
environment:
ADMIN_PASSWORD: 'fuseki_password'
restart: no
restart: "no"

skosmos-dev:
container_name: evokstest_skosmos-dev
restart: no
restart: "no"

skosmos-live:
container_name: evokstest_skosmos-live
restart: no
restart: "no"
21 changes: 21 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,30 @@ services:
postgres:
ports:
- "${POSTGRES_PORT:-8005}:5432"
web:
command: >
sh -c "python ./evoks/manage.py migrate &&
python ./evoks/manage.py runserver 0.0.0.0:8000"
entrypoint: []
# entrypoint: >
# sh -c "python ./evoks/manage.py migrate && python ./evoks/manage.py collectstatic --noinput --verbosity 0 && gunicorn evoks.wsgi:application --bind 0.0.0.0:8000 --chdir evoks --log-level debug"
ports:
- "${EVOKS_PORT:-8000}:8000"
environment:
- DJANGO_DEBUG=True # This will set the DEBUG flag to True

skosmos-dev:
ports:
- "${SKOSMOS_DEV_PORT:-8001}:80"

skosmos-live:
ports:
- "${SKOSMOS_LIVE_PORT:-8002}:80"

fuseki-dev:
ports:
- "${FUSEKI_DEV_PORT:-8003}:3030"

fuseki-live:
ports:
- "${FUSEKI_LIVE_PORT:-8004}:3030"
5 changes: 5 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
services:
proxy:
container_name: evokstest_proxy
depends_on:
- web
restart: "no"

postgres:
Expand All @@ -11,6 +13,9 @@ services:
container_name: evokstest_testrunner
entrypoint: >
sh -c "set -e &&
export BASEHREF &&
envsubst '$$BASEHREF' < /code/skosmos-dev/config-template.ttl > /code/skosmos-dev/config.ttl &&
envsubst '$$BASEHREF' < /code/skosmos-live/config-template.ttl > /code/skosmos-live/config.ttl &&
cd ./evoks &&
python manage.py migrate &&
coverage run manage.py test -v 3 tests/model/ tests/migration/ tests/skosmos/ tests/fuseki/ tests/views/ tests/evoks &&
Expand Down
64 changes: 33 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ services:
context: ./proxy
container_name: evoks_${INSTANCE_NAME:-defaultinstance}_proxy
ports:
- 9000:80
- "${PROXY_PORT:-9000}:80"
depends_on:
- web
web:
condition: service_healthy
restart: always
networks:
- frontnet
Expand Down Expand Up @@ -38,28 +39,18 @@ services:
start_period: 2m

change-vol-ownership:
# Fix Ownership of Build Directory
# Thanks to Bug in Docker itself
# We need to use steps like this
# Because by default, the volume directory
# Is owned by Root
# So this helps correct it
# We can use any image we want as long as we can chown
# By default, the volume directory is owned by root
# This would result in permissions errors when other services try to write to the volume
# Solution: change permissions of volume
image: ubuntu
# Need a user priviliged enough to chown
# user: "root"
# Specify the group in question
# group_add:
# - '${GROUP_ID}'
volumes:
# The volume to chown
# The volumes to chown
- fuseki-dev-backup:/tmp/change-ownership-fuseki-dev
- fuseki-live-backup:/tmp/change-ownership-fuseki-live
# execute chmod to enable writing to the volume by other containers
# write exit status to file
# only exit status of last command is used, but thats ok since either both or none should fail
# keep container running to enable abort-on-container-exit for testrunner container
# abort-on-container-exit is a prerequisite for using
command: >
sh -c "(chmod -R 777 /tmp/change-ownership-fuseki-dev && chmod -R 777 /tmp/change-ownership-fuseki-live ; echo $? > /tmp/chmod_exit_status) ; tail -f /dev/null"
healthcheck:
Expand All @@ -71,15 +62,15 @@ services:
container_name: evoks_${INSTANCE_NAME:-defaultinstance}_web
build:
context: "."
# caution, don't change this port since it is the one used within the container
# to change port, use the "ports:" section
# command: >
# sh -c "python ./evoks/manage.py migrate &&
# python ./evoks/manage.py runserver 0.0.0.0:8000"
environment:
- BASEHREF="${PUBLICURL:-http://localhost}:${PROXY_PORT:-9000}/skosmos-dev/"
entrypoint: >
sh -c "python ./evoks/manage.py migrate && python ./evoks/manage.py collectstatic --noinput --verbosity 0 && gunicorn evoks.wsgi:application --bind 0.0.0.0:8000 --chdir evoks --log-level debug"
ports:
- "${EVOKS_PORT:-8000}:8000"
sh -c "export BASEHREF &&
envsubst '$$BASEHREF' < /code/skosmos-dev/config-template.ttl > /code/skosmos-dev/config.ttl &&
envsubst '$$BASEHREF' < /code/skosmos-live/config-template.ttl > /code/skosmos-live/config.ttl &&
python ./evoks/manage.py migrate &&
python ./evoks/manage.py collectstatic --noinput --verbosity 0 &&
gunicorn evoks.wsgi:application --bind 0.0.0.0:8000 --chdir evoks"
depends_on:
postgres:
condition: service_healthy
Expand All @@ -100,13 +91,15 @@ services:
- frontnet
volumes:
- .:/code
- ./skosmos-dev/config-template.ttl:/code/skosmos-dev/config-template.ttl
- ./skosmos-live/config-template.ttl:/code/skosmos-live/config-template.ttl
- ./skosmos-dev/config.ttl:/code/skosmos-dev/config.ttl
- ./skosmos-live/config.ttl:/code/skosmos-live/config.ttl
- fuseki-dev-backup:/code/fuseki-dev/backup
- fuseki-live-backup:/code/fuseki-live/backup
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000 || exit 1"]
test: ["CMD-SHELL", "curl -f http://localhost:8000/login || exit 1"]
interval: 20s
timeout: 10s
retries: 5
Expand Down Expand Up @@ -163,18 +156,23 @@ services:
build:
context: https://github.com/NatLibFi/Skosmos.git#v2.17
dockerfile: dockerfiles/Dockerfile.ubuntu
ports:
- "${SKOSMOS_DEV_PORT:-8001}:80"
# to change port here, use .env file
hostname: skosmos-dev
# environment:
# - BASEHREF="${PUBLICURL:-http://localhost}:${PROXY_PORT:-9000}/skosmos-dev/"
depends_on:
- fuseki-dev
networks:
- fuseki-dev
- frontnet
volumes:
- ./skosmos-dev/config.ttl:/var/www/html/config.ttl
# - ./skosmos-dev/config-template.ttl:/var/www/html/config-template.ttl
- static-skosmos-dev:/var/www/html/resource
restart: unless-stopped
# command: >
# /bin/bash -c "export BASEHREF &&
# envsubst '$$BASEHREF' < /var/www/html/config-template.ttl > /var/www/html/config.ttl && cat /var/www/html/config.ttl &&
# /usr/sbin/apache2ctl -D FOREGROUND"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:80 || exit 1"]
interval: 20s
Expand All @@ -187,18 +185,22 @@ services:
build:
context: https://github.com/NatLibFi/Skosmos.git#v2.17
dockerfile: dockerfiles/Dockerfile.ubuntu
ports:
- "${SKOSMOS_LIVE_PORT:-8002}:80"
hostname: skosmos-live
environment:
- BASEHREF="${PUBLICURL:-http://localhost}:${PROXY_PORT:-9000}/skosmos-live/"
depends_on:
- fuseki-live
networks:
- fuseki-live
- frontnet
volumes:
- ./skosmos-live/config.ttl:/var/www/html/config.ttl
- ./skosmos-live/config-template.ttl:/var/www/html/config-template.ttl
- static-skosmos-live:/var/www/html/resource
restart: unless-stopped
command: >
/bin/bash -c "export BASEHREF &&
envsubst '$$BASEHREF' < /var/www/html/config-template.ttl > /var/www/html/config.ttl &&
/usr/sbin/apache2ctl -D FOREGROUND"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:80 || exit 1"]
interval: 20s
Expand Down
5 changes: 3 additions & 2 deletions evoks/evoks/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def get_env(key, fallback):
SECRET_KEY = 'django-insecure-_91@mjc8g-&q_f9io$jmicovci2bilh#)ud3$^iqhj1wnccr%t'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

# convert DJANGO_DEBUG value into boolean
# default is 'False', only True when env var is set to 'True'
DEBUG = get_env('DJANGO_DEBUG', 'False') == 'True'

# set to False to disable Browser-sync
TAILWIND_DEV_MODE = False
Expand Down
51 changes: 51 additions & 0 deletions skosmos-dev/config-template.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@prefix : <file:///code/evoks/tests/skosmos/config.ttl#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skosmos: <http://purl.org/net/skosmos#> .
@prefix void: <http://rdfs.org/ns/void#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:config a skosmos:Configuration ;
skosmos:baseHref ${BASEHREF} ;
skosmos:customCss "resource/css/stylesheet.css" ;
skosmos:feedbackAddress "" ;
skosmos:feedbackEnvelopeSender "" ;
skosmos:feedbackSender "" ;
skosmos:globalPlugins () ;
skosmos:httpTimeout 5 ;
skosmos:languages ( [ rdfs:label "en" ;
rdf:value "ar_AE.utf8" ] [ rdfs:label "da" ;
rdf:value "da_DK.utf8" ] [ rdfs:label "de" ;
rdf:value "de_DE.utf8" ] [ rdfs:label "en" ;
rdf:value "en_GB.utf8" ] [ rdfs:label "en_US" ;
rdf:value "en_US.utf8" ] [ rdfs:label "es" ;
rdf:value "es_ES.utf8" ] [ rdfs:label "fa" ;
rdf:value "fa_IR.utf8" ] [ rdfs:label "fi" ;
rdf:value "fi_FI.utf8" ] [ rdfs:label "fr" ;
rdf:value "fr_FR.utf8" ] [ rdfs:label "it" ;
rdf:value "it_IT.utf8" ] [ rdfs:label "nb" ;
rdf:value "nb_NO.utf8" ] [ rdfs:label "nl" ;
rdf:value "nl_NL.utf8" ] [ rdfs:label "nn" ;
rdf:value "nn_NO.utf8" ] [ rdfs:label "pl" ;
rdf:value "pl_PL.utf8" ] [ rdfs:label "pt" ;
rdf:value "pt_PT.utf8" ] [ rdfs:label "pt_BR" ;
rdf:value "pt_BR.utf8" ] [ rdfs:label "ru" ;
rdf:value "ru_RU.utf8" ] [ rdfs:label "sv" ;
rdf:value "sv_SE.utf8" ] [ rdfs:label "zh" ;
rdf:value "zh_CN.utf8" ] ) ;
skosmos:logBrowserConsole true ;
skosmos:logCaughtExceptions true ;
skosmos:searchResultsSize 20 ;
skosmos:serviceName "Skosmos" ;
skosmos:sparqlCollationEnabled false ;
skosmos:sparqlDialect "JenaText" ;
skosmos:sparqlEndpoint <http://fuseki-dev:3030/> ;
skosmos:sparqlTimeout 20 ;
skosmos:templateCache "/tmp/skosmos-template-cache" ;
skosmos:transitiveLimit 1000 ;
skosmos:uiHoneypotEnabled true ;
skosmos:uiHoneypotTime 5 ;
skosmos:uiLanguageDropdown true .


2 changes: 1 addition & 1 deletion skosmos-dev/config.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:config a skosmos:Configuration ;
skosmos:baseHref "http://localhost:9000/skosmos-dev/" ;
skosmos:baseHref ${BASEHREF} ;
skosmos:customCss "resource/css/stylesheet.css" ;
skosmos:feedbackAddress "" ;
skosmos:feedbackEnvelopeSender "" ;
Expand Down
Loading

0 comments on commit 363a729

Please sign in to comment.