-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐳 [maykinmedia/django-setup-configuration#1] add setup_configuration …
…into docker
- Loading branch information
1 parent
2c97b69
commit 5ec9046
Showing
7 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# setup initial configuration using environment variables | ||
# Run this script from the root of the repository | ||
|
||
#set -e | ||
${SCRIPTPATH}/wait_for_db.sh | ||
|
||
src/manage.py migrate | ||
|
||
src/manage.py setup_configuration --no-selftest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,37 @@ version: '3' | |
|
||
services: | ||
db: | ||
# NOTE: No persistance storage configured. | ||
# See: https://hub.docker.com/_/postgres/ | ||
image: postgres | ||
image: postgres:11-alpine | ||
environment: | ||
- POSTGRES_USER=${DB_USER:-objecttypes} | ||
- POSTGRES_PASSWORD=${DB_PASSWORD:-objecttypes} | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
volumes: | ||
- ./docker-init-db.sql:/docker-entrypoint-initdb.d/init_db.sql | ||
# - db:/var/lib/postgresql/data | ||
command: postgres -c max_connections=300 -c log_min_messages=LOG | ||
|
||
web: | ||
build: . | ||
environment: | ||
environment: &app-env | ||
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker | ||
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d} | ||
- ALLOWED_HOSTS=* | ||
- TWO_FACTOR_FORCE_OTP_ADMIN=no | ||
- TWO_FACTOR_PATCH_ADMIN=no | ||
# setup_configuration env vars | ||
- OBJECTTYPES_DOMAIN=web:8000 | ||
- OBJECTTYPES_ORGANIZATION=ObjectTypes | ||
- OBJECTS_OBJECTTYPES_TOKEN=some-random-string | ||
- OBJECTS_OBJECTTYPES_PERSON=Some Person | ||
- [email protected] | ||
ports: | ||
- 8000:8000 | ||
depends_on: | ||
- db | ||
web-init: | ||
condition: service_completed_successfully | ||
|
||
web-init: | ||
build: . | ||
environment: *app-env | ||
command: /setup_configuration.sh | ||
depends_on: | ||
- db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE USER objecttypes; | ||
CREATE DATABASE objecttypes; | ||
GRANT ALL PRIVILEGES ON DATABASE objecttypes TO objecttypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters