Skip to content

Commit

Permalink
frontend: add build-version
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Apr 8, 2024
1 parent 5560cbc commit 90596ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/frontend-publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,12 +51,13 @@ jobs:
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: frontend/Dockerfile
context: "{{defaultContext}}:frontend"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
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 }}
8 changes: 5 additions & 3 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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 },
Expand Down

0 comments on commit 90596ad

Please sign in to comment.