Skip to content

Commit

Permalink
inject .env file on Render builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bgentry committed May 6, 2024
1 parent 5298978 commit fda71be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ COPY ui/package.json ui/package-lock.json ./
RUN npm install
ENV NODE_ENV=production
COPY ui/ .
RUN npm run build
# TODO: this is a Render-specific build-time env var hack and isn't suitable for
# a published Dockerfile:
RUN --mount=type=secret,id=_env,dst=/app/.env \
npm exec vite build

# Build the Go binary, including embedded UI files:
FROM golang:1.22.2-alpine AS build-go
Expand Down
8 changes: 8 additions & 0 deletions ui/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
/// <reference types="./global-type-overrides.d.ts" />
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_RIVER_API_BASE_URL: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}

0 comments on commit fda71be

Please sign in to comment.