Skip to content

Commit be95dc6

Browse files
committed
fix(docker): implemented Cloud SQL JDBC Socket Factory support for Java services
Signed-off-by: moabu <[email protected]>
1 parent 04be023 commit be95dc6

File tree

20 files changed

+85
-36
lines changed

20 files changed

+85
-36
lines changed

docker-jans-auth-server/Dockerfile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,26 @@ RUN mkdir -p ${JETTY_BASE}/jans-auth/webapps \
6565
# ===========
6666

6767
RUN mkdir -p /usr/share/java \
68-
${JETTY_BASE}/jans-auth/_libs
68+
${JETTY_BASE}/jans-auth/_libs \
69+
${JETTY_BASE}/jans-auth/custom/libs
6970

7071
ARG TWILIO_VERSION=7.17.0
7172
ARG JSMPP_VERSION=2.3.7
7273
ARG CLOUDSQL_SOCKET_FACTORY_VERSION=1.27.0
7374

74-
RUN wget -q https://repo1.maven.org/maven2/com/twilio/sdk/twilio/${TWILIO_VERSION}/twilio-${TWILIO_VERSION}.jar -P ${JETTY_BASE}/jans-auth/_libs/ \
75-
&& wget -q https://repo1.maven.org/maven2/org/jsmpp/jsmpp/${JSMPP_VERSION}/jsmpp-${JSMPP_VERSION}.jar -P ${JETTY_BASE}/jans-auth/_libs/ \
76-
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/mysql-socket-factory-connector-j-8/${CLOUDSQL_SOCKET_FACTORY_VERSION}/mysql-socket-factory-connector-j-8-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-auth/_libs/ \
77-
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/postgres-socket-factory/${CLOUDSQL_SOCKET_FACTORY_VERSION}/postgres-socket-factory-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-auth/_libs/ \
78-
&& for custom_lib in casa-config jans-fido2-client jans-fido2-model agama-inbound jans-lock-service jans-lock-model jans-lock-cedarling cedarling-java; \
75+
# Download custom libs directly to custom/libs (always available)
76+
RUN wget -q https://repo1.maven.org/maven2/com/twilio/sdk/twilio/${TWILIO_VERSION}/twilio-${TWILIO_VERSION}.jar -P ${JETTY_BASE}/jans-auth/custom/libs/ \
77+
&& wget -q https://repo1.maven.org/maven2/org/jsmpp/jsmpp/${JSMPP_VERSION}/jsmpp-${JSMPP_VERSION}.jar -P ${JETTY_BASE}/jans-auth/custom/libs/ \
78+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/mysql-socket-factory-connector-j-8/${CLOUDSQL_SOCKET_FACTORY_VERSION}/mysql-socket-factory-connector-j-8-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-auth/custom/libs/ \
79+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/postgres-socket-factory/${CLOUDSQL_SOCKET_FACTORY_VERSION}/postgres-socket-factory-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-auth/custom/libs/ \
80+
&& for custom_lib in casa-config jans-fido2-client jans-fido2-model agama-inbound cedarling-java; \
7981
do \
80-
wget -nv "https://jenkins.jans.io/maven/io/jans/${custom_lib}/${CN_VERSION}/${custom_lib}-${CN_VERSION}.jar" -P "${JETTY_BASE}/jans-auth/_libs"; \
82+
wget -nv "https://jenkins.jans.io/maven/io/jans/${custom_lib}/${CN_VERSION}/${custom_lib}-${CN_VERSION}.jar" -P "${JETTY_BASE}/jans-auth/custom/libs"; \
83+
done
84+
85+
RUN for lock_lib in jans-lock-service jans-lock-model jans-lock-cedarling; \
86+
do \
87+
wget -nv "https://jenkins.jans.io/maven/io/jans/${lock_lib}/${CN_VERSION}/${lock_lib}-${CN_VERSION}.jar" -P "${JETTY_BASE}/jans-auth/_libs"; \
8188
done
8289

8390
# ===========

docker-jans-auth-server/scripts/bootstrap.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,11 @@ def configure_logging():
175175

176176
def copy_builtin_libs():
177177
lock_enabled = as_boolean(os.environ.get("CN_LOCK_ENABLED", "false"))
178-
cloudsql_connector_enabled = as_boolean(os.environ.get("CN_SQL_CLOUDSQL_CONNECTOR_ENABLED", "false"))
179178

180-
for src in Path("/opt/jans/jetty/jans-auth/_libs").glob("*.jar"):
181-
# skip jans-lock-service and jans-lock-model unless lock is enabled
182-
if lock_enabled is False and src.name.startswith("jans-lock"):
183-
continue
184-
185-
# skip Cloud SQL JDBC Socket Factory JARs unless connector is enabled
186-
if cloudsql_connector_enabled is False and (
187-
src.name.startswith("mysql-socket-factory") or
188-
src.name.startswith("postgres-socket-factory")
189-
):
190-
continue
179+
if not lock_enabled:
180+
return
191181

182+
for src in Path("/opt/jans/jetty/jans-auth/_libs").glob("jans-lock*.jar"):
192183
dst = f"/opt/jans/jetty/jans-auth/custom/libs/{src.name}"
193184
shutil.copyfile(src, dst)
194185

docker-jans-casa/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ LABEL org.opencontainers.image.url="ghcr.io/janssenproject/jans/casa" \
206206
org.opencontainers.image.title="Janssen Casa" \
207207
org.opencontainers.image.description="Self-service portal for people to manage their account security preferences in the Janssen, like 2FA"
208208

209+
# ===========
210+
# Custom libs
211+
# ===========
212+
213+
ARG CLOUDSQL_SOCKET_FACTORY_VERSION=1.27.0
214+
215+
# Download Cloud SQL JDBC Socket Factory JARs directly to custom/libs (always available)
216+
RUN mkdir -p ${JETTY_BASE}/jans-casa/custom/libs \
217+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/mysql-socket-factory-connector-j-8/${CLOUDSQL_SOCKET_FACTORY_VERSION}/mysql-socket-factory-connector-j-8-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-casa/custom/libs/ \
218+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/postgres-socket-factory/${CLOUDSQL_SOCKET_FACTORY_VERSION}/postgres-socket-factory-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-casa/custom/libs/
219+
209220
RUN mkdir -p /opt/jans/python/libs \
210221
${JETTY_BASE}/jans-casa/static \
211222
${JETTY_BASE}/jans-casa/plugins \

docker-jans-casa/templates/jans-mysql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
db.schema.name=%(rdbm_schema)s
22

3-
connection.uri=jdbc:mysql://%(rdbm_host)s:%(rdbm_port)s/%(rdbm_db)s?enabledTLSProtocols=TLSv1.2
3+
connection.uri=%(rdbm_connection_uri)s
44

55
connection.driver-property.serverTimezone=%(server_time_zone)s
66
# Prefix connection.driver-property.key=value will be coverterd to key=value JDBC driver properties

docker-jans-casa/templates/jans-pgsql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
db.schema.name=%(rdbm_schema)s
22

3-
connection.uri=jdbc:postgresql://%(rdbm_host)s:%(rdbm_port)s/%(rdbm_db)s
3+
connection.uri=%(rdbm_connection_uri)s
44

55
# Prefix connection.driver-property.key=value will be coverterd to key=value JDBC driver properties
66
#connection.driver-property.driverProperty=driverPropertyValu

docker-jans-config-api/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,18 @@ LABEL org.opencontainers.image.url="ghcr.io/janssenproject/jans/config-api" \
232232
org.opencontainers.image.title="Janssen Config API" \
233233
org.opencontainers.image.description=""
234234

235+
# ===========
236+
# Custom libs
237+
# ===========
238+
239+
ARG CLOUDSQL_SOCKET_FACTORY_VERSION=1.27.0
240+
241+
# Download Cloud SQL JDBC Socket Factory JARs directly to custom/libs (always available)
242+
RUN mkdir -p ${JETTY_BASE}/jans-config-api/custom/libs \
243+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/mysql-socket-factory-connector-j-8/${CLOUDSQL_SOCKET_FACTORY_VERSION}/mysql-socket-factory-connector-j-8-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-config-api/custom/libs/ \
244+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/postgres-socket-factory/${CLOUDSQL_SOCKET_FACTORY_VERSION}/postgres-socket-factory-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-config-api/custom/libs/
245+
235246
RUN mkdir -p /etc/certs \
236-
${JETTY_BASE}/jans-config-api/custom/libs \
237247
${JETTY_BASE}/jans-config-api/custom/config/adminUI \
238248
${JETTY_BASE}/jans-config-api/logs \
239249
${JETTY_BASE}/common/libs \

docker-jans-config-api/templates/jans-mysql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
db.schema.name=%(rdbm_schema)s
22

3-
connection.uri=jdbc:mysql://%(rdbm_host)s:%(rdbm_port)s/%(rdbm_db)s?enabledTLSProtocols=TLSv1.2
3+
connection.uri=%(rdbm_connection_uri)s
44

55
connection.driver-property.serverTimezone=%(server_time_zone)s
66
# Prefix connection.driver-property.key=value will be coverterd to key=value JDBC driver properties

docker-jans-config-api/templates/jans-pgsql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
db.schema.name=%(rdbm_schema)s
22

3-
connection.uri=jdbc:postgresql://%(rdbm_host)s:%(rdbm_port)s/%(rdbm_db)s
3+
connection.uri=%(rdbm_connection_uri)s
44

55
# Prefix connection.driver-property.key=value will be coverterd to key=value JDBC driver properties
66
#connection.driver-property.driverProperty=driverPropertyValu

docker-jans-fido2/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,19 @@ LABEL org.opencontainers.image.url="ghcr.io/janssenproject/jans/fido2" \
209209
org.opencontainers.image.title="Janssen FIDO2" \
210210
org.opencontainers.image.description="FIDO2 server"
211211

212+
# ===========
213+
# Custom libs
214+
# ===========
215+
216+
ARG CLOUDSQL_SOCKET_FACTORY_VERSION=1.27.0
217+
218+
# Download Cloud SQL JDBC Socket Factory JARs directly to custom/libs (always available)
219+
RUN mkdir -p ${JETTY_BASE}/jans-fido2/custom/libs \
220+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/mysql-socket-factory-connector-j-8/${CLOUDSQL_SOCKET_FACTORY_VERSION}/mysql-socket-factory-connector-j-8-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-fido2/custom/libs/ \
221+
&& wget -q https://repo1.maven.org/maven2/com/google/cloud/sql/postgres-socket-factory/${CLOUDSQL_SOCKET_FACTORY_VERSION}/postgres-socket-factory-${CLOUDSQL_SOCKET_FACTORY_VERSION}.jar -P ${JETTY_BASE}/jans-fido2/custom/libs/
222+
212223
RUN mkdir -p /etc/certs \
213224
${JETTY_BASE}/jans-fido2/logs \
214-
${JETTY_BASE}/jans-fido2/custom/libs \
215225
${JETTY_BASE}/common/libs \
216226
${JETTY_HOME}/temp \
217227
/usr/share/java

docker-jans-fido2/templates/jans-mysql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
db.schema.name=%(rdbm_schema)s
22

3-
connection.uri=jdbc:mysql://%(rdbm_host)s:%(rdbm_port)s/%(rdbm_db)s?enabledTLSProtocols=TLSv1.2
3+
connection.uri=%(rdbm_connection_uri)s
44

55
connection.driver-property.serverTimezone=%(server_time_zone)s
66
# Prefix connection.driver-property.key=value will be coverterd to key=value JDBC driver properties

0 commit comments

Comments
 (0)