Skip to content

Commit

Permalink
🐳 [#4788] Docker compose setup for setup-configuration
Browse files Browse the repository at this point in the history
add a web-init container and the required scripts for setup_configuration. Example data has been added to docker/data/
  • Loading branch information
stevenbal committed Nov 12, 2024
1 parent c13d206 commit c52c208
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-reco
build-essential \
python3-dev \
libpq-dev \
# TODO should be removed
git \
shared-mime-info \
# lxml/xmlsec deps
zlib1g-dev \
Expand Down Expand Up @@ -86,6 +88,8 @@ COPY ./bin/celery_worker.sh /celery_worker.sh
COPY ./bin/celery_beat.sh /celery_beat.sh
COPY ./bin/celery_flower.sh /celery_flower.sh
COPY ./bin/dump_configuration.sh /dump_configuration.sh
COPY ./bin/wait_for_db.sh /wait_for_db.sh
COPY ./bin/setup_configuration.sh /setup_configuration.sh
RUN mkdir /app/bin /app/log /app/media /app/private_media /app/certifi_ca_bundle /app/tmp
COPY \
./bin/check_celery_worker_liveness.py \
Expand Down
13 changes: 2 additions & 11 deletions bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

set -ex

# Wait for the database container
# See: https://docs.docker.com/compose/startup-order/
export PGHOST=${DB_HOST:-db}
export PGPORT=${DB_PORT:-5432}

fixtures_dir=${FIXTURES_DIR:-/app/fixtures}

uwsgi_port=${UWSGI_PORT:-8000}
Expand All @@ -15,12 +10,8 @@ uwsgi_threads=${UWSGI_THREADS:-1}

mountpoint=${SUBPATH:-/}

until pg_isready; do
>&2 echo "Waiting for database connection..."
sleep 1
done

>&2 echo "Database is up."
# wait for required services
${SCRIPTPATH}/wait_for_db.sh

# Apply database migrations
>&2 echo "Apply database migrations"
Expand Down
12 changes: 12 additions & 0 deletions bin/setup_configuration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# setup initial configuration using environment variables
# Run this script from the root of the repository

set -e

# wait for required services
${SCRIPTPATH}/wait_for_db.sh

src/manage.py migrate
src/manage.py setup_configuration --no-selftest --yaml-file data/services.yaml
15 changes: 15 additions & 0 deletions bin/wait_for_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

# Wait for the database container
# See: https://docs.docker.com/compose/startup-order/
export PGHOST=${DB_HOST:-db}
export PGPORT=${DB_PORT:-5432}

until pg_isready; do
>&2 echo "Waiting for database connection..."
sleep 1
done

>&2 echo "Database is up."
24 changes: 22 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,35 @@ services:
volumes: &web_volumes
- media:/app/media
- private_media:/app/private_media
- ./docker/data:/app/data
# TODO should be removed
- ./bin/setup_configuration.sh:/setup_configuration.sh
- log:/app/log
- certifi_ca_bundle:/app/certifi_ca_bundle
ports:
- 8000:8000
depends_on:
db:
condition: service_started
redis:
condition: service_started
smtp:
condition: service_started
clamav:
condition: service_started
web-init:
condition: service_completed_successfully
networks:
- open-forms-dev

web-init:
build: .
environment: *web_env
command: /setup_configuration.sh
volumes: *web_volumes
depends_on:
- db
- redis
- smtp
- clamav
networks:
- open-forms-dev

Expand Down
17 changes: 17 additions & 0 deletions docker/data/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ZGW_CONSUMERS_CONFIG_ENABLE: True
ZGW_CONSUMERS:
services:
- slug: objecttypen-test
label: Objecttypen API test
api_root: https://httpstat.us/404
api_type: orc
auth_type: api_key
header_key: Authorization
header_value: Token foo
- slug: objecten-test
label: Objecten API test
api_root: https://httpstat.us/403
api_type: orc
auth_type: api_key
header_key: Authorization
header_value: Token bar

0 comments on commit c52c208

Please sign in to comment.