Skip to content

Commit 0ec46b6

Browse files
committed
fix: The App version is now defined as an env variable
1 parent 6494109 commit 0ec46b6

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

.github/workflows/publish-image.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,13 @@ jobs:
3939
node-version: 20
4040
cache: pnpm
4141

42-
- name: Update package.json version
43-
run: |
44-
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version = process.env.PACKAGE_VERSION; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
45-
env:
46-
PACKAGE_VERSION: ${{ steps.gitversion.outputs.semVer }}
47-
4842
- name: Install dependencies
4943
run: pnpm install --frozen-lockfile
5044

5145
- name: Build application
5246
run: pnpm build
47+
env:
48+
APP_VERSION: ${{ steps.gitversion.outputs.semVer }}
5349

5450
- name: Log in to GitHub Container Registry
5551
uses: docker/login-action@v3
@@ -74,3 +70,5 @@ jobs:
7470
push: true
7571
tags: ${{ steps.meta.outputs.tags }}
7672
labels: ${{ steps.meta.outputs.labels }}
73+
build-args: |
74+
APP_VERSION=${{ steps.gitversion.outputs.semVer }}

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ RUN mkdir -p $PNPM_HOME && corepack enable && corepack prepare pnpm@10.2.1 --act
55
WORKDIR /app
66

77
FROM base AS builder
8+
ARG APP_VERSION=0.0.0
9+
ENV APP_VERSION=$APP_VERSION
810
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
911
RUN pnpm install --frozen-lockfile
1012
COPY . .
1113
RUN pnpm build
1214
RUN pnpm prune --prod
1315

1416
FROM node:22-alpine AS runtime
17+
ARG APP_VERSION=0.0.0
1518
ENV NODE_ENV=production
1619
ENV PNPM_HOME=/pnpm
1720
ENV PATH=$PNPM_HOME:$PATH
@@ -20,6 +23,7 @@ RUN mkdir -p $PNPM_HOME \
2023
&& corepack prepare pnpm@10.2.1 --activate \
2124
&& apk add --no-cache poppler-utils
2225
WORKDIR /app
26+
ENV APP_VERSION=$APP_VERSION
2327
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
2428
COPY --from=builder /app/node_modules ./node_modules
2529
COPY --from=builder /app/build ./build

app/routes/settings.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useEffect } from "react";
22
import { data, useLoaderData, useFetcher } from "react-router";
33
import { eq } from "drizzle-orm";
44
import path from "node:path";
5-
import { readFile } from "node:fs/promises";
65

76
import {
87
Card,
@@ -106,12 +105,7 @@ export async function loader({ request }: Route.LoaderArgs) {
106105
const { user, headers } = await requireUser(request);
107106
const db = await getDb();
108107

109-
const packageJsonRaw = await readFile(
110-
new URL("../../package.json", import.meta.url),
111-
"utf-8",
112-
);
113-
const packageMetadata = JSON.parse(packageJsonRaw) as { version?: string };
114-
const APP_VERSION = packageMetadata.version ?? "0.0.0";
108+
const APP_VERSION = process.env.APP_VERSION ?? "0.0.0";
115109

116110
const isAdmin = user.role === "admin";
117111
const [locationResult, currencyResult, usersList] = await Promise.all([

0 commit comments

Comments
 (0)