forked from sdc50/ubi-tethys-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
196 lines (177 loc) · 5.78 KB
/
Dockerfile
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
ARG BASE_IMAGE=tethysplatform/ubi-micromamba
FROM ${BASE_IMAGE}
###################
# BUILD ARGUMENTS #
###################
ARG PYTHON_VERSION=3.*
ARG RUN_SUPERVISOR_AS_USER="root"
ARG TETHYS_VERSION="4"
ARG TETHYS_CHANNEL="conda-forge"
ARG DJANGO_VERSION=4.2
ARG MICRO_TETHYS=false
###############
# ENVIRONMENT #
###############
ENV TETHYS_HOME="/usr/lib/tethys"
ENV TETHYS_LOG="/var/log/tethys"
ENV TETHYS_PERSIST="/var/lib/tethys_persist"
ENV TETHYS_APPS_ROOT="/var/www/tethys/apps"
ENV TETHYS_PORT=8000
ENV POSTGRES_PASSWORD="pass"
ENV TETHYS_DB_NAME='tethys_platform'
ENV TETHYS_DB_USERNAME="tethys_default"
ENV TETHYS_DB_PASSWORD="pass"
ENV TETHYS_DB_HOST="db"
ENV TETHYS_DB_PORT=5432
ENV TETHYS_DB_ENGINE="django.db.backends.postgresql"
ENV TETHYS_DB_OPTIONS=""
ENV TETHYS_DB_SUPERUSER="tethys_super"
ENV TETHYS_DB_SUPERUSER_PASS="pass"
ENV PORTAL_SUPERUSER_NAME=""
ENV PORTAL_SUPERUSER_EMAIL=""
ENV PORTAL_SUPERUSER_PASSWORD=""
ENV TETHYS_MANAGE="${TETHYS_HOME}/tethys/tethys_portal/manage.py"
ENV WAIT_FOR_DB=true
ENV SKIP_DB_SETUP=false
ENV SKIP_DB_MIGRATE=false
# Salt Scripts
ENV SALT_SCRIPTS="pre_tethys:tethyscore:post_app"
ENV ADDITIONAL_SALT_SCRIPTS=""
# Proxy Server Config
ENV APACHE_SSL_CERT_FILE="${TETHYS_PERSIST}/keys/server.crt"
ENV APACHE_SSL_KEY_FILE="${TETHYS_PERSIST}/keys/server.key"
ENV PROXY_SERVER_PORT=""
ENV USE_SSL=false
ENV RUN_PROXY_SERVER_AS_USER="root"
ENV PROXY_SERVER_PORT=""
ENV PROXY_SERVER_ADDITIONAL_DIRECTIVES=""
# Misc
ENV BASH_PROFILE=".bashrc"
ENV CONDA_HOME="/opt/conda"
ENV CONDA_ENV_NAME=tethys
ENV ENV_NAME=tethys
ENV ASGI_PROCESSES=1
ENV CLIENT_MAX_BODY_SIZE="75M"
# Tethys settings arguments
ENV DEBUG="False"
ENV ALLOWED_HOSTS="\"[localhost, 127.0.0.1]\""
ENV BYPASS_TETHYS_HOME_PAGE="True"
ENV ADD_DJANGO_APPS="\"[]\""
ENV SESSION_WARN=1500
ENV SESSION_EXPIRE=1800
ENV STATICFILES_USE_NPM=false
ENV REGISTER_CONTROLLER=null
ENV STATIC_ROOT="${TETHYS_PERSIST}/static"
ENV WORKSPACE_ROOT="${TETHYS_PERSIST}/workspaces"
ENV QUOTA_HANDLERS="\"[]\""
ENV DJANGO_ANALYTICAL="\"{}\""
ENV ADD_BACKENDS="\"[]\""
ENV OAUTH_OPTIONS="\"{}\""
ENV CHANNEL_LAYERS_BACKEND="channels.layers.InMemoryChannelLayer"
ENV CHANNEL_LAYERS_CONFIG="\"{}\""
ENV RECAPTCHA_PRIVATE_KEY=""
ENV RECAPTCHA_PUBLIC_KEY=""
ENV OTHER_SETTINGS=""
# Tethys site arguments
ENV SITE_TITLE=""
ENV FAVICON=""
ENV BRAND_TEXT=""
ENV BRAND_IMAGE=""
ENV BRAND_IMAGE_HEIGHT=""
ENV BRAND_IMAGE_WIDTH=""
ENV BRAND_IMAGE_PADDING=""
ENV APPS_LIBRARY_TITLE=""
ENV PRIMARY_COLOR=""
ENV SECONDARY_COLOR=""
ENV PRIMARY_TEXT_COLOR=""
ENV PRIMARY_TEXT_HOVER_COLOR=""
ENV SECONDARY_TEXT_COLOR=""
ENV SECONDARY_TEXT_HOVER_COLOR=""
ENV BACKGROUND_COLOR=""
ENV COPYRIGHT=""
ENV HERO_TEXT=""
ENV BLURB_TEXT=""
ENV FEATURE_1_HEADING=""
ENV FEATURE_1_BODY=""
ENV FEATURE_1_IMAGE=""
ENV FEATURE_2_HEADING=""
ENV FEATURE_2_BODY=""
ENV FEATURE_2_IMAGE=""
ENV FEATURE_3_HEADING=""
ENV FEATURE_3_BODY=""
ENV FEATURE_3_IMAGE=""
ENV CALL_TO_ACTION=""
ENV CALL_TO_ACTION_BUTTON=""
ENV PORTAL_BASE_CSS=""
ENV HOME_PAGE_CSS=""
ENV APPS_LIBRARY_CSS=""
ENV ACCOUNTS_BASE_CSS=""
ENV LOGIN_CSS=""
ENV REGISTER_CSS=""
ENV USER_BASE_CSS=""
ENV HOME_PAGE_TEMPLATE=""
ENV APPS_LIBRARY_TEMPLATE=""
ENV LOGIN_PAGE_TEMPLATE=""
ENV REGISTER_PAGE_TEMPLATE=""
ENV USER_PAGE_TEMPLATE=""
ENV USER_SETTINGS_PAGE_TEMPLATE=""
#########
# SETUP #
#########
USER root
WORKDIR ${TETHYS_HOME}
# Install APT packages
RUN rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8 \
&& dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
&& curl -fsSL https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.repo | tee /etc/yum.repos.d/salt.repo \
&& dnf update -y \
&& dnf -y install bzip2 httpd mod_ssl supervisor salt-minion procps pv \
&& dnf clean all
# Remove default Apache site
RUN rm -f /etc/httpd/conf.d/ssl.conf
# Setup Conda Environment
WORKDIR ${TETHYS_HOME}/tethys
RUN micromamba create -n "${CONDA_ENV_NAME}" --yes -c ${TETHYS_CHANNEL} -c conda-forge \
$(if [ "$MICRO_TETHYS" = false ]; then echo tethys-platform; else echo micro-tethys-platform; fi)=${TETHYS_VERSION} \
python=${PYTHON_VERSION} django=${DJANGO_VERSION}\
&& micromamba clean --all --yes
###########
# INSTALL #
###########
# Make dirs
RUN mkdir -p ${TETHYS_PERSIST} ${TETHYS_APPS_ROOT} ${WORKSPACE_ROOT} ${STATIC_ROOT} ${TETHYS_LOG}
# Setup www user, run supervisor and nginx processes as www user
RUN sed -i "/^\[supervisord\]$/a user=${RUN_SUPERVISOR_AS_USER}" /etc/supervisord.conf \
; chown -R apache: ${TETHYS_LOG} /run /var/log/supervisor /var/log/httpd /var/lib/httpd
# Run Installer
ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN tethys gen portal_config
# Install channel-redis
RUN pip install channels_redis
############
# CLEAN UP #
############
RUN dnf -y autoremove \
; dnf -y clean all
#########################
# CONFIGURE ENVIRONMENT#
#########################
VOLUME ["${WORKSPACE_ROOT}", "${STATIC_ROOT}", "${TETHYS_PERSIST}/keys"]
EXPOSE ${PROXY_SERVER_PORT}
###############*
# COPY IN SALT #
###############*
ADD docker/salt/ /srv/salt/
ADD docker/run.sh ${TETHYS_HOME}/
RUN /opt/saltstack/salt/bin/pip install setuptools urllib3 zipp cryptography -U
########
# RUN! #
########
WORKDIR ${TETHYS_HOME}
# Create Salt configuration based on ENVs
CMD bash run.sh
HEALTHCHECK --start-period=240s \
CMD function check_process_is_running(){ if [ "$(ps $1 | wc -l)" -ne 2 ]; then echo The $2 process \($1\) is not running. 1>&2; return 1; fi }; \
check_process_is_running $(cat $(grep 'pidfile=.*' /etc/supervisord.conf | awk -F'=' '{print $2}' | awk '{print $1}')) supervisor; \
check_process_is_running $(cat $(grep "PidFile " /etc/httpd/conf/httpd.conf || echo $(grep 'ServerRoot "' /etc/httpd/conf/httpd.conf | awk -F'"' '{print $2}')/logs/httpd.pid)) apache; \
check_process_is_running $(ls -l /run/tethys_asgi0.sock.lock | awk -F'-> ' '{print $2}') asgi;