Skip to content

Commit

Permalink
fix issue with docker tags
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-fdeniger committed May 29, 2024
1 parent e355d56 commit bc61e34
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
HCW_DOCTOR_VERSION=5.0.9
HCW_ADMIN_VERSION=5.0.2
HCW_BACKEND_VERSION=5.0.19
HCW_PATIENT_VERSION=5.0.14
8 changes: 6 additions & 2 deletions .github/workflows/publish-hcw-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Load .env file
id: dotenv
uses: ./.github/actions/dotenv-action

- name: Extract metadata (tags, labels) for Docker Admin
id: meta-admin
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ env.HCW_ADMIN_IMAGE_NAME }}
tags: |
type=raw,value=${{ env.HCW_ADMIN_VERSION }}-${{ env.IMAGE_TAG }}
type=sha,prefix=${{ env.HCW_ADMIN_VERSION }}-
type=raw,value=${{ steps.dotenv.outputs.HCW_ADMIN_VERSION }}-${{ env.IMAGE_TAG }}
type=sha,prefix=${{ steps.dotenv.outputs.HCW_ADMIN_VERSION }}-
- name: Extract metadata (tags, labels) for Docker Doctor
id: meta-doctor
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ To provide custom translations, fork this repository and modify the `<lang>.over
for each project, there is a folder named `assets/i18n` containing `<lang>.override.json` files.
For instance for the patient interface, translations are in the folder [./patient/assets/i18n](./patient/assets/i18n).


# How to update HCW versions generated by this repository and their related translations
- Change HCW versions in `.env`
- update translations by running the script `update-i18n-resources.sh`
- Do a PR to this repository

The script `update-i18n-resources.sh` will update original json files in the folders `<service>/assets/i18n`.
These files will be used in weblate.

# How to start the applications locally

To test translations, all application can be started locally.
Expand Down
7 changes: 4 additions & 3 deletions admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ARG HCW_ADMIN_VERSION
FROM iabsis/hcw-admin:${HCW_ADMIN_VERSION} AS i18n-layer
FROM iabsis/hcw-admin:${HCW_ADMIN_VERSION} AS init-layer

FROM init-layer AS i18n-layer
USER root
RUN apt update && apt install -y jq && rm -rf /var/lib/apt/lists/*
COPY assets/* /usr/share/nginx/html/assets/i18n
RUN bash /usr/share/nginx/html/assets/i18n/combine.sh


FROM iabsis/hcw-admin:${HCW_ADMIN_VERSION}

FROM init-layer
COPY --from=i18n-layer /usr/share/nginx/html/assets/i18n/*.json /usr/share/nginx/html/assets/i18n/
17 changes: 10 additions & 7 deletions admin/assets/i18n/combine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

## This script combine the language files
# simply create a file <lang>.override.json and the overrided language
# will be applied on upgrade.

folder=$(dirname $0)

for file in ${folder}/??.json ; do
basename=$(echo ${file/.json/})
filename=$(basename ${file})
basename=$(echo "${file/.json/}")
filename=$(basename "${file}")
lang=${filename/.json/}
if [ -f ${basename}.override.json ] ; then
jq -s '.[0] * .[1]' ${basename}.json ${basename}.override.json > ${basename}.combined.json ; ret=$?
if [ "${basename}" != "template" ] ; then
echo "Keep original file in ${basename}.orig.json"
cp "${basename}".json "${basename}".orig.json
fi
if [ -f "${basename}".override.json ] ; then
jq -s '.[0] * .[1]' "${basename}".json "${basename}".override.json > "${basename}".combined.json ; ret=$?
if [ ${ret} = 0 ] ; then
mv ${basename}.json ${basename}.orig.json
mv ${basename}.combined.json ${basename}.json
mv "${basename}".combined.json "${basename}".json
rm "${basename}".override.json
echo "Lang ${lang} combined successfully"
else
echo "Error during combining lang ${lang}, check if json is valid"
Expand Down
5 changes: 3 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ARG HCW_BACKEND_VERSION
FROM iabsis/hcw-backend:${HCW_BACKEND_VERSION} AS i18n-layer
FROM iabsis/hcw-backend:${HCW_BACKEND_VERSION} AS init-layer
FROM init-layer AS i18n-layer
USER root
RUN apt update && apt install -y jq && rm -rf /var/lib/apt/lists/*
COPY assets/* /usr/src/app/config/locales/
RUN bash /usr/src/app/config/locales/combine.sh


FROM iabsis/hcw-backend:${HCW_BACKEND_VERSION}
FROM init-layer

COPY --from=i18n-layer /usr/src/app/config/locales/*.json /usr/src/app/config/locales/
17 changes: 10 additions & 7 deletions backend/assets/i18n/combine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

## This script combine the language files
# simply create a file <lang>.override.json and the overrided language
# will be applied on upgrade.

folder=$(dirname $0)

for file in ${folder}/??.json ; do
basename=$(echo ${file/.json/})
filename=$(basename ${file})
basename=$(echo "${file/.json/}")
filename=$(basename "${file}")
lang=${filename/.json/}
if [ -f ${basename}.override.json ] ; then
jq -s '.[0] * .[1]' ${basename}.json ${basename}.override.json > ${basename}.combined.json ; ret=$?
if [ "${basename}" != "template" ] ; then
echo "Keep original file in ${basename}.orig.json"
cp "${basename}".json "${basename}".orig.json
fi
if [ -f "${basename}".override.json ] ; then
jq -s '.[0] * .[1]' "${basename}".json "${basename}".override.json > "${basename}".combined.json ; ret=$?
if [ ${ret} = 0 ] ; then
mv ${basename}.json ${basename}.orig.json
mv ${basename}.combined.json ${basename}.json
mv "${basename}".combined.json "${basename}".json
rm "${basename}".override.json
echo "Lang ${lang} combined successfully"
else
echo "Error during combining lang ${lang}, check if json is valid"
Expand Down
21 changes: 11 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
context: patient
args:
# If you update this, please update .github/workflows/publish-hcw-docker-images.yml
- HCW_PATIENT_VERSION=5.0.14
- HCW_PATIENT_VERSION=$HCW_PATIENT_VERSION
user: nginx
ports:
- "8080:8080"
Expand All @@ -24,7 +24,8 @@ services:
context: doctor
args:
# If you update this, please update .github/workflows/publish-hcw-docker-images.yml
- HCW_DOCTOR_VERSION=5.0.9
- HCW_DOCTOR_VERSION=$HCW_DOCTOR_VERSION
# target: export-json
user: nginx
ports:
- "8081:8081"
Expand All @@ -39,7 +40,7 @@ services:
context: admin
args:
# If you update this, please update .github/workflows/publish-hcw-docker-images.yml
- HCW_ADMIN_VERSION=5.0.2
- HCW_ADMIN_VERSION=$HCW_ADMIN_VERSION
user: nginx
ports:
- "8082:8082"
Expand All @@ -54,7 +55,7 @@ services:
context: backend
args:
#If you update this, please update .github/workflows/publish-hcw-docker-images.yml
- HCW_BACKEND_VERSION=5.0.19
- HCW_BACKEND_VERSION=$HCW_BACKEND_VERSION
user: node
ports:
- "1337:1337"
Expand Down Expand Up @@ -95,12 +96,12 @@ services:
- "3310:3310"

mediasoup:
image: iabsis/mediasoup-api:latest
env_file:
- ./secrets.env
environment:
- API_USER=mediasoup_user
- REDIS_HOST=redis
image: iabsis/mediasoup-api:latest
env_file:
- ./secrets.env
environment:
- API_USER=mediasoup_user
- REDIS_HOST=redis


volumes:
Expand Down
8 changes: 5 additions & 3 deletions doctor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
ARG HCW_DOCTOR_VERSION
FROM iabsis/hcw-doctor:${HCW_DOCTOR_VERSION} AS i18n-layer
FROM iabsis/hcw-doctor:${HCW_DOCTOR_VERSION} AS init-layer

FROM init-layer AS i18n-layer
USER root
RUN apt update && apt install -y jq && rm -rf /var/lib/apt/lists/*
COPY assets/* /usr/share/nginx/html/assets/i18n
RUN bash /usr/share/nginx/html/assets/i18n/combine.sh


FROM iabsis/hcw-doctor:${HCW_DOCTOR_VERSION}
FROM init-layer

COPY --from=i18n-layer /usr/share/nginx/html/assets/i18n/*.* /usr/share/nginx/html/assets/i18n/
COPY --from=i18n-layer /usr/share/nginx/html/assets/i18n/*.json /usr/share/nginx/html/assets/i18n/
17 changes: 10 additions & 7 deletions doctor/assets/i18n/combine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

## This script combine the language files
# simply create a file <lang>.override.json and the overrided language
# will be applied on upgrade.

folder=$(dirname $0)

for file in ${folder}/??.json ; do
basename=$(echo ${file/.json/})
filename=$(basename ${file})
basename=$(echo "${file/.json/}")
filename=$(basename "${file}")
lang=${filename/.json/}
if [ -f ${basename}.override.json ] ; then
jq -s '.[0] * .[1]' ${basename}.json ${basename}.override.json > ${basename}.combined.json ; ret=$?
if [ "${basename}" != "template" ] ; then
echo "Keep original file in ${basename}.orig.json"
cp "${basename}".json "${basename}".orig.json
fi
if [ -f "${basename}".override.json ] ; then
jq -s '.[0] * .[1]' "${basename}".json "${basename}".override.json > "${basename}".combined.json ; ret=$?
if [ ${ret} = 0 ] ; then
mv ${basename}.json ${basename}.orig.json
mv ${basename}.combined.json ${basename}.json
mv "${basename}".combined.json "${basename}".json
rm "${basename}".override.json
echo "Lang ${lang} combined successfully"
else
echo "Error during combining lang ${lang}, check if json is valid"
Expand Down
7 changes: 4 additions & 3 deletions patient/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ARG HCW_PATIENT_VERSION
FROM iabsis/hcw-patient:${HCW_PATIENT_VERSION} AS i18n-layer
FROM iabsis/hcw-patient:${HCW_PATIENT_VERSION} AS init-layer

FROM init-layer AS i18n-layer
USER root
RUN apt update && apt install -y jq && rm -rf /var/lib/apt/lists/*
COPY assets/* /usr/share/nginx/html/assets/i18n
RUN bash /usr/share/nginx/html/assets/i18n/combine.sh


FROM iabsis/hcw-patient:${HCW_PATIENT_VERSION}

FROM init-layer
COPY --from=i18n-layer /usr/share/nginx/html/assets/i18n/*.json /usr/share/nginx/html/assets/i18n/
17 changes: 10 additions & 7 deletions patient/assets/i18n/combine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

## This script combine the language files
# simply create a file <lang>.override.json and the overrided language
# will be applied on upgrade.

folder=$(dirname $0)

for file in ${folder}/??.json ; do
basename=$(echo ${file/.json/})
filename=$(basename ${file})
basename=$(echo "${file/.json/}")
filename=$(basename "${file}")
lang=${filename/.json/}
if [ -f ${basename}.override.json ] ; then
jq -s '.[0] * .[1]' ${basename}.json ${basename}.override.json > ${basename}.combined.json ; ret=$?
if [ "${basename}" != "template" ] ; then
echo "Keep original file in ${basename}.orig.json"
cp "${basename}".json "${basename}".orig.json
fi
if [ -f "${basename}".override.json ] ; then
jq -s '.[0] * .[1]' "${basename}".json "${basename}".override.json > "${basename}".combined.json ; ret=$?
if [ ${ret} = 0 ] ; then
mv ${basename}.json ${basename}.orig.json
mv ${basename}.combined.json ${basename}.json
mv "${basename}".combined.json "${basename}".json
rm "${basename}".override.json
echo "Lang ${lang} combined successfully"
else
echo "Error during combining lang ${lang}, check if json is valid"
Expand Down
28 changes: 28 additions & 0 deletions update-i18n-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# This script will start docker services and copy initial i18n files for HCW Docker images.

# copy file from docker service to the related i18n folder
move_files() {
local service=$1
local docker_path=$2
local tmp_folder="./${service}/assets/i18n-temp"
local i18n_folder="./${service}/assets/i18n"
rm -rf "${tmp_folder}"
docker compose cp "${service}":"${docker_path}" "${tmp_folder}"
echo "move ${tmp_folder}/template.json to ${i18n_folder}"
mv "${tmp_folder}"/template.json "${i18n_folder}"/
for orig_file in "${tmp_folder}"/*.orig.json; do
target_name=$(basename "$orig_file"|cut -d. -f1)".json"
target_file=${i18n_folder}/$target_name
echo "Move ${orig_file} to ${target_file}"
mv "${orig_file}" "${target_file}"
done
rm -rf "${tmp_folder}"

}

docker compose up -d --build
move_files "doctor" "/usr/share/nginx/html/assets/i18n/"
move_files "admin" "/usr/share/nginx/html/assets/i18n/"
move_files "patient" "/usr/share/nginx/html/assets/i18n/"
move_files "backend" "/usr/src/app/config/locales/"

0 comments on commit bc61e34

Please sign in to comment.