Skip to content

Commit

Permalink
Merge pull request #55 from privacybydesign/config-template
Browse files Browse the repository at this point in the history
Add start script & option for config template
  • Loading branch information
w-ensink authored Jan 13, 2025
2 parents ecdc4a4 + 0ba14df commit b843a34
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ src/main/webapp/*
!src/main/webapp/WEB-INF/

.idea/
.vscode
38 changes: 0 additions & 38 deletions .gitlab-ci.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ RUN ./build.sh nl && mv build /www/nl
# Let root redirect to the english version
RUN cp /webapp/redirect-en.html /www/index.html

FROM gradle:7.6-jdk11 as javabuild
# --------------------------------------------------------

FROM gradle:7.6-jdk11 AS javabuild

# Build the java app
COPY ./ /app/
WORKDIR /app
RUN gradle build

# --------------------------------------------------------

FROM tomee:9.1-jre11
RUN apt-get update && apt-get install gettext-base

WORKDIR /server

# Copy the webapp to the webapps directory
RUN rm -rf /usr/local/tomee/webapps/*
Expand All @@ -32,12 +39,13 @@ COPY --from=javabuild /app/build/libs/irma_email_issuer.war /usr/local/tomee/web
COPY ./src/main/resources/email-en.html /email-templates/email-en.html
COPY ./src/main/resources/email-nl.html /email-templates/email-nl.html

COPY --from=javabuild /app/start.sh ./start.sh
RUN chmod +x ./start.sh

RUN mkdir /usr/local/keys

ENV IRMA_CONF="/config/"
RUN mkdir /irma-config
ENV IRMA_CONF="/irma-config/"
ENV EMAIL_TEMPLATE_DIR="/email-templates/"
EXPOSE 8080

# Copy the config file to the webapp. This is done at runtime so that the config file can be mounted as a volume.
CMD [ "/bin/sh", "-c", "openssl rsa -in /irma-jwt-key/priv.pem -outform der -out /usr/local/keys/priv.der && for lang in 'en' 'nl'; do cp /config/config.js /usr/local/tomee/webapps/ROOT/$lang/assets/config.js; done && exec catalina.sh run" ]
CMD [ "/bin/sh", "-C", "./start.sh" ]
21 changes: 21 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# this is the startup script in the docker container,
# doing a bunch of config at runtime before starting the actual server

set -e # exit the script immediately when an error is encountered

# in some cases secrets from different places might be required to be used together
# so this provides the option to provide a config template with some environment variables
echo "creating config.json based on template"
envsubst < /config/config.json > $IRMA_CONF/config.json

echo "generating binary file for private key"
openssl rsa -in /irma-jwt-key/priv.pem -outform der -out /usr/local/keys/priv.der

echo "copying config files to web app dir"
for lang in 'en' 'nl'; do
cp /config/config.js /usr/local/tomee/webapps/ROOT/$lang/assets/config.js;
done


echo "starting up server"
exec catalina.sh run

0 comments on commit b843a34

Please sign in to comment.