From d0cb34b6eb1294923d85daefacf66670d6f8ce92 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Fri, 12 Jun 2026 15:56:16 -0700 Subject: [PATCH] Build at runtime so env vars work --- .dockerignore | 1 + .env.example | 4 ++-- Dockerfile | 26 ++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3a5137a..219e0f1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ node_modules dist +.env .git .gitignore *.log diff --git a/.env.example b/.env.example index f79a568..8899dfb 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ -VITE_SEARCH_RELAYS=wss://relay.nostr.band,wss://nostr.wine -VITE_INDEXER_RELAYS=wss://purplepag.es +VITE_SEARCH_RELAYS=wss://relay.ditto.pub,wss://antiprimal.net,wss://relay.vertexlab.io +VITE_INDEXER_RELAYS=wss://purplepag.es,wss://relay.damus.io,wss://indexer.coracle.social diff --git a/Dockerfile b/Dockerfile index a5baa04..fd5e420 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,26 @@ # syntax=docker/dockerfile:1 -# ---- Build stage: compile the Vite/SolidJS app to static files ---- -FROM node:24-alpine AS build +# Single stage: the Vite/SolidJS app is built at *container start* rather than at +# image build, so VITE_* env vars passed to `docker run` are inlined into the bundle. +FROM node:24-alpine WORKDIR /app # pnpm ships with Node via corepack; pin to the version that produced pnpm-lock.yaml. RUN corepack enable && corepack prepare pnpm@10.33.0 --activate +# `serve` (what `npx serve` runs) — installed now so the image is self-contained. +RUN npm install -g serve@14 + # Install deps first so this layer is cached unless the manifest/lockfile change. +# devDependencies are kept because the build runs at container start. COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile -# Build (`tsc && vite build` → /app/dist). devDependencies are needed here. +# App source. The build itself is deferred to the CMD below. COPY . . -RUN pnpm build - -# ---- Serve stage: static files via `serve` ---- -FROM node:24-alpine AS serve -WORKDIR /app - -# `serve` (what `npx serve` runs) — installed at build time so the image is self-contained. -RUN npm install -g serve@14 - -COPY --from=build /app/dist ./dist EXPOSE 3000 -CMD ["serve", "-s", "dist", "-l", "3000"] + +# Build (`tsc && vite build` → /app/dist) at runtime so VITE_* vars from the +# environment configure the app, then serve the static output. +CMD pnpm build && serve -s dist -l 3000