Skip to content

Commit

Permalink
fix: forward build info in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Nov 13, 2023
1 parent 9ecec91 commit b60292d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ jobs:
platforms: linux/amd64,linux/arm64
build-args: |
OCULAR_GENESIS_HOST=${{ env.OCULAR_GENESIS_HOST }}
OCULAR_BUILD_VERSION=${{ github.ref_name }}
OCULAR_BUILD_SHA=${{ github.sha }}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
FROM --platform=$BUILDPLATFORM node:20-alpine AS build

ARG OCULAR_GENESIS_HOST
ARG OCULAR_BUILD_VERSION
ARG OCULAR_BUILD_SHA

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

ENV OCULAR_BUILD_VERSION=${OCULAR_BUILD_VERSION}
ENV OCULAR_BUILD_SHA=${OCULAR_BUILD_SHA}

RUN npx pnpm install --global pnpm@8
WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions src/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ interface ImportMetaEnv {

// Build information
readonly OCULAR_BUILD_TIMESTAMP: number;
readonly OCULAR_BUILD_SHA: string;
readonly OCULAR_BUILD_VERSION: string;
readonly OCULAR_BUILD_VERSION?: string;
readonly OCULAR_BUILD_SHA?: string;
}

interface ImportMeta {
Expand Down
6 changes: 1 addition & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ export default defineConfig({
}
},
define: {
'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now(),
'import.meta.env.OCULAR_BUILD_SHA': JSON.stringify(execSync('git rev-parse --short HEAD').toString().trim()),
'import.meta.env.OCULAR_BUILD_VERSION': JSON.stringify(
execSync('git describe --tags --always --abbrev=0').toString().trim()
)
'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now()
},
plugins: [
tsconfigPaths({ loose: true }),
Expand Down

0 comments on commit b60292d

Please sign in to comment.