-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
228 lines (191 loc) · 7.5 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
FROM alpine:3.13
# ===============
# Alpine packages
# ===============
RUN apk update \
&& apk add --no-cache openssl py3-pip tini curl bash openjdk11 py3-cryptography py3-grpcio py3-psycopg2 \
&& apk add --no-cache --virtual build-deps wget git \
&& mkdir -p /usr/java/latest \
&& ln -sf /usr/lib/jvm/default-jvm/jre /usr/java/latest/jre
# =====
# Jetty
# =====
ARG JETTY_VERSION=9.4.35.v20201120
ARG JETTY_HOME=/opt/jetty
ARG JETTY_BASE=/opt/jans/jetty
ARG JETTY_USER_HOME_LIB=/home/jetty/lib
# Install jetty
RUN wget -q https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${JETTY_VERSION}/jetty-distribution-${JETTY_VERSION}.tar.gz -O /tmp/jetty.tar.gz \
&& mkdir -p /opt \
&& tar -xzf /tmp/jetty.tar.gz -C /opt \
&& mv /opt/jetty-distribution-${JETTY_VERSION} ${JETTY_HOME} \
&& rm -rf /tmp/jetty.tar.gz
# Ports required by jetty
EXPOSE 8080
# ======
# Jython
# ======
ARG JYTHON_VERSION=2.7.2
RUN wget -q https://repo1.maven.org/maven2/org/python/jython-installer/${JYTHON_VERSION}/jython-installer-${JYTHON_VERSION}.jar -O /tmp/jython-installer.jar \
&& mkdir -p /opt/jython \
&& java -jar /tmp/jython-installer.jar -v -s -d /opt/jython \
&& rm -f /tmp/jython-installer.jar /tmp/*.properties
# install pydev debugger into Jython
RUN wget -q https://github.com/fabioz/PyDev.Debugger/archive/refs/tags/pydev_debugger_2_3_0.tar.gz -P /tmp \
&& tar xvf /tmp/pydev_debugger_2_3_0.tar.gz -C /tmp \
&& cd /tmp/PyDev.Debugger-pydev_debugger_2_3_0 \
&& /opt/jython/bin/pip install . \
&& rm -rf /tmp/pydev_debugger* /tmp/PyDev.Debugger-*
# ===========
# Auth server
# ===========
ENV CN_VERSION=1.0.0-SNAPSHOT
ENV CN_BUILD_DATE='2021-06-22 16:57'
ENV CN_SOURCE_URL=https://maven.jans.io/maven/io/jans/jans-auth-server/${CN_VERSION}/jans-auth-server-${CN_VERSION}.war
# Install Jans Auth
RUN wget -q ${CN_SOURCE_URL} -O /tmp/jans-auth.war \
&& mkdir -p ${JETTY_BASE}/jans-auth/webapps/jans-auth \
&& unzip -qq /tmp/jans-auth.war -d ${JETTY_BASE}/jans-auth/webapps/jans-auth \
&& java -jar ${JETTY_HOME}/start.jar jetty.home=${JETTY_HOME} jetty.base=${JETTY_BASE}/jans-auth --add-to-start=server,deploy,annotations,resources,http,http-forwarded,threadpool,jsp,websocket \
&& rm -f /tmp/jans-auth.war
# ===========
# Custom libs
# ===========
RUN mkdir -p /usr/share/java
ARG TWILIO_VERSION=7.17.0
RUN wget -q https://repo1.maven.org/maven2/com/twilio/sdk/twilio/${TWILIO_VERSION}/twilio-${TWILIO_VERSION}.jar -O /usr/share/java/twilio.jar
ARG JSMPP_VERSION=2.3.7
RUN wget -q https://repo1.maven.org/maven2/org/jsmpp/jsmpp/${JSMPP_VERSION}/jsmpp-${JSMPP_VERSION}.jar -O /usr/share/java/jsmpp.jar
# ======
# Python
# ======
COPY requirements.txt /app/requirements.txt
RUN pip3 install -U pip \
&& pip3 install --no-cache-dir -r /app/requirements.txt \
&& rm -rf /src/jans-pycloudlib/.git
# =======
# Cleanup
# =======
RUN apk del build-deps \
&& rm -rf /var/cache/apk/*
# =======
# License
# =======
RUN mkdir -p /licenses
COPY LICENSE /licenses/
# ==========
# Config ENV
# ==========
ENV CN_CONFIG_ADAPTER=consul \
CN_CONFIG_CONSUL_HOST=localhost \
CN_CONFIG_CONSUL_PORT=8500 \
CN_CONFIG_CONSUL_CONSISTENCY=stale \
CN_CONFIG_CONSUL_SCHEME=http \
CN_CONFIG_CONSUL_VERIFY=false \
CN_CONFIG_CONSUL_CACERT_FILE=/etc/certs/consul_ca.crt \
CN_CONFIG_CONSUL_CERT_FILE=/etc/certs/consul_client.crt \
CN_CONFIG_CONSUL_KEY_FILE=/etc/certs/consul_client.key \
CN_CONFIG_CONSUL_TOKEN_FILE=/etc/certs/consul_token \
CN_CONFIG_CONSUL_NAMESPACE=jans \
CN_CONFIG_KUBERNETES_NAMESPACE=default \
CN_CONFIG_KUBERNETES_CONFIGMAP=jans \
CN_CONFIG_KUBERNETES_USE_KUBE_CONFIG=false \
CN_CONFIG_GOOGLE_SECRET_VERSION_ID=latest \
CN_CONFIG_GOOGLE_SECRET_NAME_PREFIX=jans
# ==========
# Secret ENV
# ==========
ENV CN_SECRET_ADAPTER=vault \
CN_SECRET_VAULT_SCHEME=http \
CN_SECRET_VAULT_HOST=localhost \
CN_SECRET_VAULT_PORT=8200 \
CN_SECRET_VAULT_VERIFY=false \
CN_SECRET_VAULT_ROLE_ID_FILE=/etc/certs/vault_role_id \
CN_SECRET_VAULT_SECRET_ID_FILE=/etc/certs/vault_secret_id \
CN_SECRET_VAULT_CERT_FILE=/etc/certs/vault_client.crt \
CN_SECRET_VAULT_KEY_FILE=/etc/certs/vault_client.key \
CN_SECRET_VAULT_CACERT_FILE=/etc/certs/vault_ca.crt \
CN_SECRET_VAULT_NAMESPACE=jans \
CN_SECRET_KUBERNETES_NAMESPACE=default \
CN_SECRET_KUBERNETES_SECRET=jans \
CN_SECRET_KUBERNETES_USE_KUBE_CONFIG=false \
CN_SECRET_GOOGLE_SECRET_MANAGER_PASSPHRASE=secret \
CN_SECRET_GOOGLE_SECRET_VERSION_ID=latest \
CN_SECRET_GOOGLE_SECRET_NAME_PREFIX=jans
# ===============
# Persistence ENV
# ===============
ENV CN_PERSISTENCE_TYPE=ldap \
CN_PERSISTENCE_LDAP_MAPPING=default \
CN_LDAP_URL=localhost:1636 \
CN_LDAP_USE_SSL=true \
CN_COUCHBASE_URL=localhost \
CN_COUCHBASE_USER=admin \
CN_COUCHBASE_CERT_FILE=/etc/certs/couchbase.crt \
CN_COUCHBASE_PASSWORD_FILE=/etc/jans/conf/couchbase_password \
CN_COUCHBASE_CONN_TIMEOUT=10000 \
CN_COUCHBASE_CONN_MAX_WAIT=20000 \
CN_COUCHBASE_SCAN_CONSISTENCY=not_bounded \
CN_COUCHBASE_BUCKET_PREFIX=jans \
CN_COUCHBASE_TRUSTSTORE_ENABLE=true \
CN_COUCHBASE_KEEPALIVE_INTERVAL=30000 \
CN_COUCHBASE_KEEPALIVE_TIMEOUT=2500 \
CN_GOOGLE_SPANNER_INSTANCE_ID="" \
CN_GOOGLE_SPANNER_DATABASE_ID=""
# ===========
# Generic ENV
# ===========
ENV CN_MAX_RAM_PERCENTAGE=75.0 \
CN_WAIT_MAX_TIME=300 \
CN_WAIT_SLEEP_DURATION=10 \
PYTHON_HOME=/opt/jython \
CN_DOCUMENT_STORE_TYPE=LOCAL \
CN_JACKRABBIT_URL=http://localhost:8080 \
CN_JACKRABBIT_ADMIN_ID=admin \
CN_JACKRABBIT_ADMIN_PASSWORD_FILE=/etc/jans/conf/jackrabbit_admin_password \
CN_JAVA_OPTIONS="" \
CN_SYNC_JKS_ENABLED=false \
CN_SYNC_JKS_INTERVAL=30 \
GOOGLE_PROJECT_ID="" \
GOOGLE_APPLICATION_CREDENTIALS=/etc/jans/conf/google-credentials.json
# ==========
# misc stuff
# ==========
LABEL name="Janssen Authorization Server" \
maintainer="Janssen Project <[email protected]>" \
vendor="Janssen Project" \
version="1.0.0" \
release="b6" \
summary="Janssen Authorization Server" \
description="OAuth 2.0 server and client; OpenID Connect Provider (OP) & UMA Authorization Server (AS)"
RUN mkdir -p /etc/certs /deploy \
/opt/jans/python/libs \
${JETTY_BASE}/jans-auth/custom/pages ${JETTY_BASE}/jans-auth/custom/static \
${JETTY_BASE}/jans-auth/custom/libs \
${JETTY_BASE}/jans-auth/custom/i18n \
/etc/jans/conf \
/app/templates
COPY libs /opt/jans/python/libs
COPY certs /etc/certs
COPY jetty/jans-auth_web_resources.xml ${JETTY_BASE}/jans-auth/webapps/
COPY jetty/jans-auth.xml ${JETTY_BASE}/jans-auth/webapps/
COPY conf/*.tmpl /app/templates/
COPY scripts /app/scripts
RUN chmod +x /app/scripts/entrypoint.sh
# # create non-root user
RUN adduser -s /bin/sh -D -G root -u 1000 jetty
# adjust ownership
RUN chown -R 1000:1000 /opt/jans/jetty \
&& chown -R 1000:1000 /opt/jetty \
&& chown -R 1000:1000 /deploy \
&& chown -R 1000:1000 /tmp \
&& chgrp -R 0 /opt/jans/jetty && chmod -R g=u /opt/jans/jetty \
&& chgrp -R 0 /opt/jetty && chmod -R g=u /opt/jetty \
&& chgrp -R 0 /tmp && chmod -R g=u /tmp \
&& chgrp -R 0 /deploy && chmod -R g=u /deploy \
&& chgrp -R 0 /etc/certs && chmod -R g=u /etc/certs \
&& chgrp -R 0 /etc/jans && chmod -R g=u /etc/jans \
&& chmod -R +w /etc/ssl/certs/java/cacerts && chgrp -R 0 /etc/ssl/certs/java/cacerts && chmod -R g=u /etc/ssl/certs/java/cacerts
USER 1000
ENTRYPOINT ["tini", "-e", "143", "-g", "--"]
CMD ["sh", "/app/scripts/entrypoint.sh"]