Skip to content

Commit d4f0b90

Browse files
committed
Also declare the arg and narrow down the scope of variables
1 parent a734dac commit d4f0b90

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ ARG NODE_VERSION=22.16.0
33

44
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS base
55

6+
ARG APP_VERSION
7+
ARG GIT_SHA
8+
69
ENV SKIP_ENV_VALIDATION="true"
710
ENV DOCKER_OUTPUT=1
811
ENV NEXT_TELEMETRY_DISABLED=1
912
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
10-
ENV APP_VERSION=${APP_VERSION}
11-
ENV GIT_SHA=${GIT_SHA}
13+
14+
ENV NEXT_PUBLIC_APP_VERSION=${APP_VERSION}
15+
ENV NEXT_PUBLIC_GIT_SHA=${GIT_SHA}
1216

1317
RUN apk update && apk add --no-cache libc6-compat
1418

@@ -24,9 +28,6 @@ RUN pnpm build
2428

2529
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS release
2630

27-
ARG APP_VERSION
28-
ARG GIT_SHA
29-
3031
ENV NODE_ENV=production
3132
ENV DOCKER_OUTPUT=1
3233

@@ -43,8 +44,6 @@ COPY --from=base /app/prisma/migrations ./prisma/migrations
4344

4445
# set this so it throws error where starting server
4546
ENV SKIP_ENV_VALIDATION="false"
46-
ENV APP_VERSION=${APP_VERSION}
47-
ENV GIT_SHA=${GIT_SHA}
4847

4948
COPY ./start.sh ./start.sh
5049

src/components/Account/DebugInfo.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const DebugInfo: React.FC<React.PropsWithChildren> = ({ children }) => {
3535
}
3636
};
3737

38-
if (env.NEXT_PUBLIC_VERSION) {
38+
if (env.NEXT_PUBLIC_APP_VERSION) {
3939
void fetchLatestVersion();
4040
}
4141
}, []);
@@ -46,8 +46,8 @@ export const DebugInfo: React.FC<React.PropsWithChildren> = ({ children }) => {
4646
if (env.NEXT_PUBLIC_GIT_SHA) {
4747
debugInfo.push(`${t('account.debug_info_details.git')}: ${env.NEXT_PUBLIC_GIT_SHA}`);
4848
}
49-
if (env.NEXT_PUBLIC_VERSION) {
50-
debugInfo.push(`${t('account.debug_info_details.version')} ${env.NEXT_PUBLIC_VERSION}`);
49+
if (env.NEXT_PUBLIC_APP_VERSION) {
50+
debugInfo.push(`${t('account.debug_info_details.version')} ${env.NEXT_PUBLIC_APP_VERSION}`);
5151
}
5252
try {
5353
void navigator.clipboard.writeText(debugInfo.join('\n'));
@@ -78,10 +78,12 @@ export const DebugInfo: React.FC<React.PropsWithChildren> = ({ children }) => {
7878
/>
7979
<DebugInfoRow
8080
label={t('account.debug_info_details.version')}
81-
value={env.NEXT_PUBLIC_VERSION}
81+
value={env.NEXT_PUBLIC_APP_VERSION}
8282
className="mt-4"
8383
/>
84-
{newVersion && env.NEXT_PUBLIC_VERSION && newVersion !== env.NEXT_PUBLIC_VERSION ? (
84+
{newVersion &&
85+
env.NEXT_PUBLIC_APP_VERSION &&
86+
newVersion !== env.NEXT_PUBLIC_APP_VERSION ? (
8587
<p className="mt-4 text-sm text-yellow-600">
8688
{t('account.debug_info_details.new_version_available')}: {newVersion}
8789
</p>

src/env.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const env = createEnv({
8080
* `NEXT_PUBLIC_`. Note that these are only evaluated at build time!
8181
*/
8282
client: {
83-
NEXT_PUBLIC_VERSION: z.string().optional(),
83+
NEXT_PUBLIC_APP_VERSION: z.string().optional(),
8484
NEXT_PUBLIC_GIT_SHA: z.string().optional(),
8585
},
8686

@@ -143,8 +143,8 @@ export const env = createEnv({
143143
UPLOAD_MAX_FILE_SIZE_MB: process.env.UPLOAD_MAX_FILE_SIZE_MB
144144
? Number(process.env.UPLOAD_MAX_FILE_SIZE_MB)
145145
: 10,
146-
NEXT_PUBLIC_VERSION: process.env.APP_VERSION,
147-
NEXT_PUBLIC_GIT_SHA: process.env.GIT_SHA,
146+
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION,
147+
NEXT_PUBLIC_GIT_SHA: process.env.NEXT_PUBLIC_GIT_SHA,
148148
},
149149
/**
150150
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially

0 commit comments

Comments
 (0)