Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start script & option for config template #55

Merged
merged 10 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" ]
22 changes: 22 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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 > /tmp/conf.json
cp /tmp/conf.json $IRMA_CONF/config.json
w-ensink marked this conversation as resolved.
Show resolved Hide resolved

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
Loading