From fda71be7427ef0fd5d4a0107ca839ae7f0a79dfd Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Mon, 6 May 2024 09:59:15 -0500 Subject: [PATCH] inject .env file on Render builds --- Dockerfile | 5 ++++- ui/src/vite-env.d.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b53e2eb..ce3469e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/ui/src/vite-env.d.ts b/ui/src/vite-env.d.ts index 19bfac9..8ff4ccf 100644 --- a/ui/src/vite-env.d.ts +++ b/ui/src/vite-env.d.ts @@ -1,2 +1,10 @@ /// /// + +interface ImportMetaEnv { + readonly VITE_RIVER_API_BASE_URL: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}