Awesome
Gantree-Cli-Docker
This docker container is designed to simplify the setup and usage of gantree-cli
For deeper understanding of the items and concepts referenced in this document please see the READMEs for gantree-cli and gantree-lib.
For information on setting up docker see docs.docker.com/install
Setup
Files
Various configuration files need to be passed to the docker container on running,
this is accomplised by mounting a host directory as the /gantree
directory in the container.
The mounted directory should contain a structure that will be recognized by the container and is described below.
To mount a directory when running the container:
docker run -v /home/myuser/work/gantree-working:/gantree gantree-cli-docker
Files you may wish to add to this directory:
{host-dir}/config/{your-gantree-configuration-file}.json
{host-dir}/gcp/{your-google-application-credentials}.json
{host-dir}/ssh/{your-ssh-private-key}
Private keys should be RSA type, contain embedded PEM information, and not use a password
Some versions of ssh-keygen will generate this key by default, for others versions you can force this behaviour:
ssh-keygen -f ./ssh_id_rsa_validator -t rsa -m PEM -q -N ""
For more information about these files see the gantree-cli documentation.
Environment Variables
Some credentials can be passed directly to the docker container as environment variables.
These include:
- GANTREE_CONFIG_PATH
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- DO_API_TOKEN
- GCP_AUTH_KIND
- GCP_SERVICE_ACCOUNT_FILE
To pass environment variables when running the container:
docker run -e DO_API_TOKEN=XXXXXXXXX gantree-cli-docker
or
docker run --env-file myenvfile gantree-cli-docker
where myenvfile contains
DO_API_TOKEN=XXXXXXXXX
HOST_USER
The HOST_USER
environment variable can also be passed to ensure files created by docker in the {host-folder} become owned by the host machine's user account
As a run command parameter:
-e HOST_USER=$(id -u)
Or in the env-file if you set HOST_USER
to the result of running id -u
in terminal, eg. 1000
, 1001
, ..
depending on your system
Paths
Environment variables that contain paths should point to the file location mounted inside the container
For example, if a config file is located on the host at
/home/myuser/my_gantree_workspace/config/myconfig.json
the container could be run with
docker run \
-v /home/myuser/my_gantree_workspace:/gantree \
-e GANTREE_CONFIG_PATH=/gantree/config/myconfig.json \
-e HOST_USER=$(id -u) \
--rm -ti
gantree-cli-docker
Gantree config files support user defined environment variable lookup of the form
{
"some_key": "$env:USER_DEFINED_ENV_VAR"
}
These can also be passed through using the above methods
Usage
Build the container
docker build -t {docker-image-name} .
eg.
docker build -t gantree-cli-docker .
Run gantree-cli-docker
docker run -v {host-directory}:/gantree \
--env-file {env-file} \
-e HOST_USER=$(id -u) \
--rm -ti \
{docker-image-name} [cli arguments]
eg.
docker run -v /home/myuser/work/gantree_work:/gantree \
--env-file /home/myuser/work/gantree_env/envfile \
-e HOST_USER=$(id -u) \
--rm -ti \
gantree-cli-docker sync