-
Notifications
You must be signed in to change notification settings - Fork 3
/
terra.env
131 lines (106 loc) · 5.08 KB
/
terra.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
JUST_PROJECT_PREFIX=TERRA
JUST_VERSION="0.2.2+1dev"
if [[ -z "${TERRA_CWD+set}" ]]; then
TERRA_CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"
fi
: ${TERRA_AUTO_ESCAPE=TERRA_.*_DIR_DOCKER}
: ${TERRA_DOCKER_REPO=terra}
: ${TERRA_HOME=/home/user}
: ${TERRA_USERNAME=$(id -u -n)}
: ${TERRA_UID=$(id -u)}
: ${TERRA_GIDS=$(id -G)}
: ${TERRA_GID=${TERRA_GIDS%% *}}
: ${TERRA_GROUP_NAMES=$(group_names)}
#**
# .. envvar:: TERRA_LOCAL
#
# By default, terra runs in a docker container. Since the docker compute type uses docker, in scenarios other than the docker socket and external docker sockets, piping the docker connection into a container can prove troublesome. For this reason, the terra master controller can also be run on the host.
#
# :envvar:`TERRA_LOCAL` defaults to 0, disabled. But can either be enabled in your ``local.env`` or by using the ``--local`` flag
#**
: ${TERRA_LOCAL=1}
# This directory is added to the container using the docker-compose file. This mechanism
# should only be used when the directory is guaranteed to exist
: ${TERRA_TERRA_DIR=${TERRA_CWD}}
: ${TERRA_TERRA_DIR_DOCKER=/terra}
: ${TERRA_TERRA_DIR_TYPE=bind}
: ${TERRA_APP_DIR=${TERRA_CWD}}
: ${TERRA_APP_DIR_DOCKER=/src}
: ${TERRA_APP_DIR_TYPE=bind}
# The host dir should be set by the compute/service definition
: ${TERRA_SETTINGS_DIR_DOCKER=/settings}
if [ -d "/tmp/.X11-unix" ]; then
TERRA_VOLUMES=("/tmp/.X11-unix:/tmp/.X11-unix:ro"
${TERRA_VOLUMES+"${TERRA_VOLUMES[@]}"})
fi
: ${TERRA_DOCKER_RUNTIME="$([[ "$(nvidia-docker version 2>/dev/null)" = "NVIDIA Docker: 2"* ]] && echo nvidia)"}
# Redis values
: ${TERRA_REDIS_PORT=6379}
: ${TERRA_REDIS_PORT_DOCKER=6379}
: ${TERRA_REDIS_DIR=terra-redis}
: ${TERRA_REDIS_DIR_DOCKER=/data}
: ${TERRA_REDIS_DIR_TYPE=volume}
: ${TERRA_REDIS_HOSTNAME=localhost}
: ${TERRA_REDIS_HOSTNAME_DOCKER=terra-redis}
: ${TERRA_REDIS_SINGULAR_IMAGE=redis_${TERRA_USERNAME}.simg}
: ${TERRA_SINGULAR_COMPOSE_FILES=${TERRA_CWD}/singular-compose.env}
#**
# .. envvar:: TERRA_REDIS_SECRET_DOCKER
#
# The name of the ``docker-compose`` secret used.
#
# .. envvar:: TERRA_REDIS_SECRET_FILE
#
# The file name used to store the password locally. Default: ``redis_password.secret``. If the file does not exist in ``redis_secret`` mode, than it is generated with a random password. This secret file should not be added to the your git repository; ``*.secret`` files are in the ``.gitignore`` file for this reason.
#**
: ${TERRA_REDIS_SECRET_FILE=${TERRA_CWD}/redis_password.secret}
: ${TERRA_REDIS_SECRET_DOCKER=redis_password}
if [[ ! -f /.dockerenv && ! -s "${TERRA_REDIS_SECRET_FILE}" ]]; then
source "${VSI_COMMON_DIR}/linux/random.bsh"
# Allow printable ascii characters excpet quotes, ';' (for an unknown redis/celery parsing reason), ':' or '@' (for redis url reasons)
urandom_password 20 '\x21\x23-\x26\x28-\x39\x3c-\x3f\x41-\x7E' > "${TERRA_REDIS_SECRET_FILE}"
fi
#**
# .. envvar:: TERRA_CELERY_MAIN_NAME
#
# (Optional) Name of the main module if running as __main__. This is used as the prefix for auto-generated task names that are defined in the same module as ``__main__`` (Usually caused by ``python -m``). At first, python will try ``sys.modules['__main__'].__spec__.name``, before using this value, when that fails.
#
# .. envvar:: TERRA_KEEP_TEMP_DIR
#
# Optional environment variable, that when set to ``1`` will keep the temporary config files generated for containers. For debug use.
#**
#**
# .. envvar:: TERRA_CELERY_CONF
#
# Celery reads the configuration from :envvar:`TERRA_CELERY_CONF` as the name of a module to import. Default: ``terra.celeryconfig``. You can override all the options and use your own configuration file. To easily modify one value, you can:
#
# .. code-block:: python
#
# from terra.celeryconfig import *
#
# result_expires=7200
#**
: ${TERRA_CELERY_CONF=terra.executor.celery.celeryconfig}
: ${TERRA_CELERY_SERVICE=celery}
: ${TERRA_REDIS_COMMANDER_PORT=4567}
: ${TERRA_REDIS_COMMANDER_PORT_DOCKER=4567}
: ${TERRA_REDIS_COMMANDER_SECRET=redis_commander_secret}
: ${TERRA_REDIS_COMMANDER_SECRET_FILE=${TERRA_CWD}/redis_commander_password.secret}
: ${SINGULARITY_CUSTOM_IMPORT_SCRIPT=${TERRA_TERRA_DIR}/docker/tosingular}
# Sphinx docs values
set_array_default TERRA_SPHINX_EXCLUDE_DIRS docs external
set_array_default TERRA_SPHINX_AUTODOC_DIRS terra
set_array_default TERRA_SPHINX_AUTODOC_OUTPUT_DIRS python
set_array_default TERRA_SPHINX_AUTODOC_EXCLUDE_DIRS terra/tests
###############################################################################
# Non-TERRA Settings
###############################################################################
: ${TZ=/usr/share/zoneinfo/UTC}
# Put variables that do not begin with TERRA here.
# Use this to add the user name to the docker-compose project name. This is
# important when multiple users are using this docker-compose project on a
# single host. This way all of the docker resources are prefixed with a unique
# name and do not collide
source "${VSI_COMMON_DIR}/linux/docker_functions.bsh"
: ${COMPOSE_PROJECT_NAME=$(docker_compose_sanitize_project_name "${TERRA_CWD}" "${TERRA_USERNAME}")}
: ${COMPOSE_FILE=${TERRA_CWD}/docker-compose-main.yml}