diff --git a/.github/workflows/frontend-publish-docker.yml b/.github/workflows/frontend-publish-docker.yml index e6e574276..162596da3 100644 --- a/.github/workflows/frontend-publish-docker.yml +++ b/.github/workflows/frontend-publish-docker.yml @@ -29,6 +29,9 @@ jobs: uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set version + run: | + echo "BEACONCHAIN_VERSION=$(git describe --always --tags)" >> "$GITHUB_ENV" # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 @@ -48,8 +51,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v5.1.0 with: - context: . - file: frontend/Dockerfile + context: "{{defaultContext}}:frontend" push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -57,3 +59,5 @@ jobs: cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max secrets: | NPMRC_FILE=${{ secrets.NPMRC_FILE }} + build-args: | + BEACONCHAIN_VERSION=${{ env.BEACONCHAIN_VERSION }} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 094bd6e36..8aebcbf3e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -5,15 +5,17 @@ RUN mkdir -p /usr/src/nuxt-app WORKDIR /usr/src/nuxt-app COPY . . -WORKDIR /usr/src/nuxt-app/frontend -RUN --mount=type=secret,id=NPMRC_FILE,target=/usr/src/nuxt-app/frontend/.npmrc \ +WORKDIR /usr/src/nuxt-app +RUN --mount=type=secret,id=NPMRC_FILE,target=/usr/src/nuxt-app/.npmrc \ npm ci && npm cache clean --force RUN npm run build FROM node:18-alpine WORKDIR /usr/src/nuxt-app -COPY --from=build /usr/src/nuxt-app/frontend /usr/src/nuxt-app +COPY --from=build /usr/src/nuxt-app /usr/src/nuxt-app +ARG BEACONCHAIN_VERSION +ENV NUXT_PUBLIC_GIT_VERSION=$BEACONCHAIN_VERSION ENV NUXT_HOST=0.0.0.0 ENV NUXT_PORT=3000 diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 125d712cd..a2b97c18d 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -7,8 +7,8 @@ let gitVersion = '' try { const info = gitDescribeSync() - if (info.tag != null) { - gitVersion = info.tag + if (info.raw != null) { + gitVersion = info.raw } if (gitVersion === '' && info.hash != null) { warn('The GitHub tag of the explorer is unknown. Reading the GitHub hash instead.') @@ -17,10 +17,6 @@ try { } catch (err) { warn('The GitHub tag and hash of the explorer cannot be read with git-describe.') } -if (gitVersion === '') { - warn('Neither the GitHub tag nor the GitHub hash could be read. The version number of the explorer shown on the front end will be "2" by default.') - gitVersion = '2' -} export default defineNuxtConfig({ devtools: { enabled: true },