Skip to content

Commit

Permalink
frontend: add BEACONCHAIN_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Apr 8, 2024
1 parent 6a3e855 commit fcf1a44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 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: 4 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# this is meant to be built with the root of this repo as build-context
FROM node:18-alpine AS build

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 \
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="undefined"
ENV BEACONCHAIN_VERSION=${BEACONCHAIN_VERSION}
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000

Expand Down
6 changes: 5 additions & 1 deletion frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { gitDescribeSync } from 'git-describe'
import { warn } from 'vue'
import * as fs from 'fs';
let gitVersion = ''

try {
Expand All @@ -19,7 +20,10 @@ try {
}
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'
if (process.env.BEACONCHAIN_VERSION === '') {
gitVersion = '2'
}
gitVersion = process.env.BEACONCHAIN_VERSION + ''
}

export default defineNuxtConfig({
Expand Down

0 comments on commit fcf1a44

Please sign in to comment.