Last active
April 13, 2017 15:09
-
-
Save kinnou02/9309002eb3f3f3988b86bf45fd059162 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
version: '2' | |
services: | |
instances_configurator: | |
build: ./instances_configurator | |
volumes_from: | |
- tyr_beat | |
- tyr_worker | |
- jormungandr | |
volumes: | |
- kraken_instance_conf:/srv/kraken | |
database: | |
environment: | |
- POSTGRES_USER=navitia | |
- POSTGRES_PASSWORD=navitia | |
- POSTGRES_DB=jormungandr | |
image: mdillon/postgis:9.1 | |
rabbitmq: | |
image: rabbitmq:management | |
redis: | |
image: redis:3-alpine | |
kraken-default: | |
image: navitia/kraken:latest | |
environment: | |
- KRAKEN_GENERAL_instance_name=default | |
- KRAKEN_GENERAL_database=/srv/ed/output/default.nav.lz4 | |
- KRAKEN_BROKER_host=rabbitmq | |
volumes_from: | |
- tyr_beat:ro | |
expose: | |
- "30000" | |
kraken-fr-ne: | |
image: navitia/kraken:latest | |
environment: | |
- KRAKEN_GENERAL_instance_name=fr-ne | |
- KRAKEN_GENERAL_database=/srv/ed/output/fr-ne.nav.lz4 | |
- KRAKEN_BROKER_host=rabbitmq | |
volumes_from: | |
- tyr_beat:ro | |
expose: | |
- "30000" | |
jormungandr: | |
image: navitia/jormungandr:latest | |
environment: | |
- JORMUNGANDR_SQLALCHEMY_DATABASE_URI=postgresql://navitia:navitia@database/jormungandr | |
- JORMUNGANDR_INSTANCE_DEFAULT={"key":"default","zmq_socket":"tcp://kraken-default:30000"} | |
- JORMUNGANDR_INSTANCE_FR_NE={"key":"fr-ne","zmq_socket":"tcp://kraken-fr-ne:30000"} | |
ports: | |
- "9191:80" | |
tyr_worker: | |
image: navitia/tyr-worker:latest | |
volumes: | |
# TODO this is not necessary, it's just by convenience, remove this to import it directly in instances_configurator | |
- ed_migration:/usr/share/navitia/ed | |
volumes_from: | |
- tyr_beat | |
tyr_beat: | |
image: navitia/tyr-beat:latest | |
volumes: | |
- tyr_data:/srv/ed | |
- tyr_instance_conf:/etc/tyr.d | |
tyr_web: | |
image: navitia/tyr-web:latest | |
volumes_from: | |
- tyr_beat | |
ports: | |
- '9898:80' | |
volumes: | |
tyr_data: | |
tyr_instance_conf: | |
jormungandr_instance_conf: | |
kraken_instance_conf: | |
ed_migration: |
This file contains hidden or 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
#!/bin/bash | |
tyr_config() { | |
instance_name=$1 | |
INSTANCE=$instance_name envsubst < templates/tyr_instance.ini > /etc/tyr.d/$instance_name.ini | |
mkdir -p /srv/ed/$instance_name | |
mkdir -p /srv/ed/output | |
mkdir -p /srv/ed/input/$instance_name | |
} | |
db_config() { | |
instance_name=$1 | |
# wait for db ready | |
while ! pg_isready --host=database; do | |
echo "waiting for postgres to be ready" | |
sleep 1; | |
done | |
# database creation | |
PGPASSWORD=navitia createdb --host database -U navitia $instance_name | |
PGPASSWORD=navitia psql -c 'CREATE EXTENSION postgis;' --host database $instance_name navitia | |
# database schema migration | |
alembic_file=/srv/ed/$instance_name/ed_migration.ini | |
INSTANCE=$instance_name envsubst < templates/ed_migration.ini > $alembic_file | |
alembic -c $alembic_file upgrade head | |
} | |
add_instance() { | |
instance_name=$1 | |
# tyr configuration | |
tyr_config $instance_name | |
# db creation and migration | |
db_config $instance_name | |
} | |
# TODO discover the instance automaticaly | |
add_instance 'default' | |
add_instance 'fr-ne' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment