I have 2 types of enterprise apps that I need to create docker images, and I have a question how best to handle per-client settings in
domain.xml (notably, JDBC connection settings).
The
first type of EAR is common for all clients (ie, no custom modules in the build). I could create a docker image for each client, as in the following
Dockerfile:
FROM payara/server-full:174
COPY client-domain.xml ${PAYARA_PATH}/glassfish/domains/${PAYARA_DOMAIN}
/config/domain.xml
COPY ../../../../resources/sqljdbc4.jar ${PAYARA_PATH}/glassfish/domains/${PAYARA_DOMAIN}/lib
COPY ../../../../resources/activemq-rar-5.12.0.rar $DEPLOY_DIR
COPY services-ear-1.0-SNAPSHOT.ear $DEPLOY_DIR
EXPOSE 8080 8181
That just seems like overkill to create a docker image for each client when the only difference is a slightly different
domain.xml. Couldn't I just eliminate the
COPY of
domain.xml in the above
Dockerfile, and instead make that swap in
docker-compose.yml, like such:
version: '3'
services:
my-services:
image: my-services:latest
volumes:
- "client-domain.xml:
${PAYARA_PATH}/glassfish/domains/${PAYARA_DOMAIN}
/config/domain.xml
"
extra_hosts:
- "sqlserver:192.168.1.20"
Perhaps
${PAYARA_PATH} and
${PAYARA_DOMAIN} aren't available, and I'd have to hardcode it as
/opt/payara41/glassfish/domains/domain1/config/domain.xml.
The
second type of EAR is one that is custom to all clients (about 90% common module, 10% custom EJBs). With this type I see no problem copying the domain.xml into the Docker image, but that mean I need an image for each environment (TEST, STAGE, PROD), which is again overkill. I could do something in docker-compose.xml like above.
Lastly, I'd like to point out that the
extra_hosts setting in the above
docker-compose.xml is present so that I can semi-common settings in
domain.xml. I think that's how it works, right? It doesn't take care of other JDBC values such as database name, port, username, password, etc. Here is the relevant portion of the
domain.xml that I'm trying to make as generic as possible:
<jdbc-connection-pool datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerDataSource" name="MyJDBC" res-type="javax.sql.DataSource">
<property name="User" value="myuser"></property>
<property name="URL" value="jdbc:sqlserver://"></property>
<property name="Password" value="mypass"></property>
<property name="DatabaseName" value="TEST_DB"></property>
<property name="ServerName" value="sqlserver"></property>
<property name="PortNumber" value="1433"></property>
</jdbc-connection-pool>
What are your thoughts? Am I going about this all wrong?