From 7795b602ffd8835b79729614fbeae318b6b440b8 Mon Sep 17 00:00:00 2001 From: Ivar Derksen Date: Fri, 1 Dec 2023 14:06:38 +0100 Subject: [PATCH 1/2] Improvement: include all webapp locales in Dockerfile --- .gitignore | 1 + Dockerfile | 20 ++++++++++++++------ docker-compose.yml | 4 ++-- webapp/redirect-en.html | 11 +++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 webapp/redirect-en.html diff --git a/.gitignore b/.gitignore index 0c7dbc7..04d7247 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/ .gradle/ +src/main/resources/config.js src/main/resources/config.json *.der *.pem diff --git a/Dockerfile b/Dockerfile index acbcce3..aa58053 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,16 @@ -FROM yarnpkg/node-yarn:latest as webappbuild - -ARG LANGUAGE=en +FROM node:20 as webappbuild # Build the webapp COPY ./webapp/ /webapp/ +RUN mkdir -p /www + WORKDIR /webapp -RUN yarn install && ./build.sh ${LANGUAGE} +RUN yarn install +RUN ./build.sh en && mv build /www/en +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 @@ -18,9 +22,13 @@ RUN gradle build FROM tomee:9.0-jre11 # Copy the webapp to the webapps directory -COPY --from=webappbuild /webapp/build/ /usr/local/tomee/webapps/ROOT/ +RUN rm -rf /usr/local/tomee/webapps/ROOT +COPY --from=webappbuild /www/ /usr/local/tomee/webapps/ROOT/ # Copy the war file to the webapps directory COPY --from=javabuild /app/build/libs/irma_email_issuer-1.1.0.war /usr/local/tomee/webapps/ -EXPOSE 8080 \ No newline at end of file +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", "for lang in 'en' 'nl'; do cp /config/config.js /usr/local/tomee/webapps/ROOT/$lang/assets/config.js; done && catalina.sh run" ] diff --git a/docker-compose.yml b/docker-compose.yml index f0cc7db..db81bc9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ name: irma_email_issuer services: # Irma issuer service irmaserver: - image: ghcr.io/privacybydesign/irma:v0.13.2 + image: ghcr.io/privacybydesign/irma:v0.14.2 working_dir: /irmago ports: - 8088:8088 @@ -45,7 +45,7 @@ services: # Make keys and config files available for Java app - ./src/main/resources/:/config/ # Make config.js available for webapp - - ./webapp/config.example.js:/usr/local/tomee/webapps/ROOT/assets/config.js:ro" + - ./webapp/config.example.js:/config/config.js:ro" ports: - 8080:8080 expose: diff --git a/webapp/redirect-en.html b/webapp/redirect-en.html new file mode 100644 index 0000000..9a5af17 --- /dev/null +++ b/webapp/redirect-en.html @@ -0,0 +1,11 @@ + + + + + + Redirecting... + + +

If you are not redirected, click here.

+ + From 89a5109a15bc3d7686257afd33d084fc0756a9d6 Mon Sep 17 00:00:00 2001 From: Ivar Derksen Date: Fri, 1 Dec 2023 14:08:29 +0100 Subject: [PATCH 2/2] Docs: add explanation for config mount --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1ecaddd..8e68e76 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ By default, docker-compose caches docker images, so on a second run the previous $ IP=192.168.1.105 docker-compose up --build ``` +The configuration should be mounted in the `/config` directory of the container. The `docker-compose.yml` file already contains this configuration. + ## Manual The Java api and JavaScript frontend can be built and run manually using the following commands: