Package Exports
- @contiamo/dev
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@contiamo/dev) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Contiamo Local Dev Environment
Get the dev environment fast!
Quick overview
Get started:
make docker-authmake pull
Get the latest versions:
git pullmake pull
Start everything in normal mode:
make start
Stop everything:
make stop
Stop everything and clean up:
make clean
Prepare for Pantheon-external mode (only do this once):
make buildsudo bash -c 'echo "127.0.0.1 metadb" >> /etc/hosts'
Start everything in Pantheon-external mode:
make pantheon-start- (In Pantheon directory)
env METADB_URL="jdbc:postgresql://localhost:5433/pantheon?user=pantheon&password=test" DATASTORE_TYPE=external sbt run
Enable TLS verify-full mode on port 5435:
- Download the private key for
*.dev.contiamo.io:make get-pg-key echo "127.0.0.1 pg-localhost.dev.contiamo.io" | sudo tee -a /etc/hostsmake buildmake pantheon-start- You may need to tell your local
psqlabout the IdenTrust root we happen to be using:curl https://letsencrypt.org/certs/trustid-x3-root.pem.txt > ~/.postgresql/root.crt psql "user=lemon@example.com password=<token> dbname=<project UUID> sslmode=verify-full" -h pg-localhost.dev.contiamo.io -p 5435
Getting started
Prerequisites
Local development is supported via Docker Compose.
Before you start, you must install Docker and Docker-Compose.
Additionally, the development requires access to our private docker registry. To access this ask the Ops team for permissions. Once permissions have been granted you must install the gcloud CLI.
Once installed, run
make docker-auth pullThis will attempt to
- authenticate with Google,
- configure your Docker installation to use the new Google credentials, and
- pull the required Docker images.
Starting The Environment
Finally, to start the development environment, run
make startOnce the environment has started, you should see a message with a URL and credentials, like this
Dev ui: http://localhost:9898/contiamo/profile
Email: lemon@example.com
Password: localdevStart and add an external datasource
We have a dataset available on GCR for internal testing. It is a Postgres database that contains a single table liftdata. This can be used for testing against a known external dataset.
After starting the local dev environment, run
docker run --name liftdata --rm --network dev_default eu.gcr.io/dev-and-test-env/deutschebahn-liftdata-postgres:v1.0.0In the Data Hub, you can now add a external Postgres datasource using:
| field | value |
|---|---|
HOST |
liftdata |
PORT |
5432 |
DATABASE |
liftdata |
USER |
pantheon |
PASS |
contiamodatahub19 |
when you are done, run
docker kill liftdatato stop and cleanup the database container.
Stopping
You can always cleanly stop the environment using
make stopAny data in the databases will be preserved between stop and start.
Adding the metadbs as external data sources
You can add the Data Hubs own metadbs to the Data Hub, meaning you can inspect the internals of the Data Hub from the Data Hub :) . Each of the following databases can be added as PostgreSQL data sources.
| service | db name | host | port | username | password |
|---|---|---|---|---|---|
datastore |
datastore |
metadb |
5433 |
user |
localdev |
hub |
hub |
metadb |
5433 |
user |
localdev |
idp |
simpleidp |
metadb |
5433 |
user |
localdev |
pantheon |
pantheon |
metadb |
5433 |
pantheon |
test |
Cleaning up
If you need to reclaim space or want to restart your environment from scratch use
make cleanThis will stop your current environment and remove any Docker volumes related to it. This includes any data and metadata in the databases.
As time goes on, Docker will download new images, but it does not automatically garbage collect old images. To do so, run docker system prune.
On Mac, all Docker filesystem data is stored in a single file of a fixed size, which is 16GB or 32GB by default. You can configure the size of this file by clicking on the Docker Desktop tray icon -> Preferences -> Disk -> move the slider.
Running a db dump from another environment
If you need to run a "clone" of another environment, you can dump the dbs from that environment and have the local development environment load those dbs when it starts.
The db dumps should be generated using -O --inserts --column-inserts. For the hub metadb, this would look like
pg_dump hub -h hub-metadb -U hub -O --inserts --column-inserts > hub.sqlThe resulting file can then be put into the config/dumps folder and the docker container will load it during initial startup. This requires an empty db, so make clean should be run first. Also, the dump file must be named after the service: idp.sql, hub.sql, datastore.sql, and pantheon.sql. Any other sql files will be ignored.
Also, we will generally need the idp.sql dump and the encryption secret value, which will need to replace config/auth/encryption_pass.txt
At that point running make start stop start should consistently start the platform with the dumps loaded. The extra stop start is needed due to some awkward race at the startup and nginx not handling the resulting crash correctly.
Tips
Run
makeormake helpto see all available commands.You can also run these commands from a different directory, with e.g.
make -C /path/to/dev start.The commands in the Makefile are very useful, but there's some extra stuff available if you use
docker-composestraight. For instance, get all logs withdocker-compose logs --follow, or only datastore worker logs withdocker-compose logs --follow ds-worker. Refer todocker-compose.ymlfor the definitions of the services.To use
docker-composewithoutcd'ing to this directory, use e.g.docker-compose -f /path/to/dev/docker-compose.yml logs --follow.
Custom Images
The Compose file supports overriding the Docker tag used for a service by setting several environment variables:
| Server | Environment Variable | Default |
|---|---|---|
| datastore | DATASTORE_TAG |
dev |
| idp | IDP_TAG |
dev |
| pantheon | PANTHEON_TAG |
latest |
| contiamo-ui | CONTIAMOUI_TAG |
latest |
Options to Postgres
In environment variable POSTGRES_ARGS, you can pass extra arguments to the PostgreSQL daemon. By defaults, this is set to -c log_connections=on. To log modification statements in addition to connections, start the dev environment with
env POSTGRES_ARGS="-c log_connections=on -c log_statement=mod" make startYou can inspect these logs with docker-compose logs --follow metadb. The four acceptable values for log_statement are none, ddl, mod, and all. Further Postgres options can be found here: https://www.postgresql.org/docs/11/runtime-config.html .
Setting up Pantheon Local Development
Local Pantheon debug development is supported by port redirection. To set this up, you first need to run two extra steps.
Run
make buildThis builds the
eu.gcr.io/dev-and-test-env/pantheon:redirDocker image, a "pseudo-Pantheon" that forwards everything to your local Pantheon on127.0.0.1port4300. Do not push this image!Modify your
/etc/hostsfile to add127.0.0.1 metadbYou can easily do this with
sudo bash -c 'echo "127.0.0.1 metadb" >> /etc/hosts'.This ensures that Pantheon can correctly resolve the storage database service.
Running the Pantheon Local Development
Make sure you first set up the prerequisites, and also set up for Pantheon local development.
To start the Pantheon dev environment use
make pantheon-startThis will replace the Pantheon image with a simple port redirection image that will enable transparent redirect of
- http://localhost:9898/pantheon/api/v1/* to http://localhost:4300/api/v1/* ,
- http://localhost:9898/pantheon/jdbc/* to http://localhost:8765/* .
You can then start your local Pantheon debug build, e.g. from your IDE, and have it bind to those ports on localhost. To configure the meta-DB and enable data store from Pantheon, run SBT with
env METADB_URL="jdbc:postgresql://localhost:5433/pantheon?user=pantheon&password=test" DATASTORE_TYPE=external sbtor set the same environment variables in IntelliJ. You can also use export METADB_URL="jdbc:postgresql://localhost:5433/pantheon?user=pantheon&password=test" DATASTORE_TYPE=external, to set the environment variables in the current terminal.
The docker-compose configuration will expose the following ports for use from local Pantheon:
- Nginx web server at
127.0.0.1port9898<-- Use this to access Data Hub including UI, IDP, Pantheon, Datastore. - PostgreSQL meta-DB at
127.0.0.1port5433, usernamepantheon, passwordtest. - Datastore manager at
127.0.0.1port9191 - Minio (for ingested files) at
127.0.0.1port9000
When accessing Pantheon via Nginx on port 9898, you need to prepend /pantheon to Pantheon URLs, for instance: http://localhost:9898/pantheon/api/v1/status . Nginx will strip off the /pantheon, authenticate the request with IDP, and forward the request to Pantheon as /api/v1/status.
Using the pantheon/test credentials for Postgres, you also have access to
- the
metadbdatabase, for datastore, - collection databases corresponding to a managed DB,
- collection databases corresponding to materializations for a project,
- the
simpleidpdatabase.
Running a custom Pantheon in prod mode
You can also run Pantheon in prod mode locally, as follows.
- In
sbtshell, rundist. - From a console, run
docker build -t eu.gcr.io/dev-and-test-env/pantheon:local .This will download dependencies if they are not cached yet, build a Docker image for Pantheon, and tag itlocal. - Run
env PANTHEON_TAG=local make start.
Now datastore and metadb will still be available on the usual ports, but Nginx will proxy to a prod-mode Pantheon which runs inside Docker. Pantheon will automatically be run with appropriate environment variables (https://github.com/contiamo/dev/blob/master/docker-compose.yml#L81).
Warning! Do not push this image to GCR. It may accidentally end up being deployed on dev.contiamo.io .
Profiler Server
The Profiler currently lives at http://localhost:8383.