Skip to content

Commit

Permalink
ci(web components): use fitting wc version in wc embedder
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Aug 11, 2023
1 parent 822879a commit e28c756
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/data-platform/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"docker build -f ./apps/data-platform/Dockerfile . -t $(tools/print-docker-tag.sh data-platform)"
"docker build --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./apps/data-platform/Dockerfile . -t $(tools/print-docker-tag.sh data-platform)"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/datafeeder/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"options": {
"commands": [
"nx build datafeeder --base-href='/datafeeder/'",
"docker build --build-arg APP_NAME=datafeeder -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datafeeder)"
"docker build --build-arg APP_NAME=datafeeder --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datafeeder)"
],
"parallel": false
}
Expand Down
2 changes: 1 addition & 1 deletion apps/datahub/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"options": {
"commands": [
"nx build datahub --base-href='/datahub/'",
"docker build --build-arg APP_NAME=datahub -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datahub)"
"docker build --build-arg APP_NAME=datahub --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datahub)"
],
"parallel": false
}
Expand Down
4 changes: 3 additions & 1 deletion tools/docker/Dockerfile.apps
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

FROM nginx:1.24-alpine

ARG WEB_COMPONENT_VERSION="main"
ARG APP_NAME="search"
ENV APP_NAME=${APP_NAME}
ENV GN4_API_URL ""
Expand All @@ -14,8 +15,9 @@ ENV CUSTOM_SCRIPTS_DIRECTORY ""
COPY dist/apps/${APP_NAME} /usr/share/nginx/html/${APP_NAME}
COPY tools/docker/docker-entrypoint.sh /

# copy Web Components HTML embedder as a bonus
# copy Web Components HTML embedder using correct wc script version
COPY tools/webcomponent/wc-embedder.html /usr/share/nginx/html/${APP_NAME}
RUN sed -i "s/wc-dist/wc-dist-${WEB_COMPONENT_VERSION}/" /usr/share/nginx/html/${APP_NAME}/wc-embedder.html

# copy default NGINX conf & put the app name in it
COPY tools/docker/nginx.apps.conf /etc/nginx/conf.d/default.conf
Expand Down
10 changes: 10 additions & 0 deletions tools/print-wc-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Will print the current gitTag or 'main' if none
# This is used for web component versionning
# e.g.: v1.1.0
# or: main

gitTag=$(git describe --exact-match --tags 2>/dev/null)

echo "${gitTag:-main}"

0 comments on commit e28c756

Please sign in to comment.