fix(docker): don't set NODE_ENV=production before npm ci in builder stage
All checks were successful
build-and-release / build (push) Successful in 1m34s
All checks were successful
build-and-release / build (push) Successful in 1m34s
With NODE_ENV=production set, npm ci skips devDependencies - but
npm run build (vinxi/vite under the hood) needs them, failing with
ERR_MODULE_NOT_FOUND for 'vite'. This broke every build regardless
of what changed in the app itself, including the innocuous waitlist
page added in 26667c7. Pre-existing bug, not introduced by that
commit - confirmed via git log that the NODE_ENV=production line
predates it.
Moved NODE_ENV=production to the runtime stage only, where it
actually matters (affects the running server, not the build tooling).
Added --include=dev to npm ci for defense in depth if NODE_ENV ever
gets reintroduced in the builder stage.
Verified with a local - completes
successfully now.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
2614beb62a
commit
8c03cd0eac
1 changed files with 10 additions and 3 deletions
13
Dockerfile
13
Dockerfile
|
|
@ -5,7 +5,11 @@ WORKDIR /app
|
||||||
# Skip browser downloads
|
# Skip browser downloads
|
||||||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||||
ENV CYPRESS_INSTALL_BINARY=0
|
ENV CYPRESS_INSTALL_BINARY=0
|
||||||
ENV NODE_ENV=production
|
# NODE_ENV=production must NOT be set in this stage: with it set, `npm ci`
|
||||||
|
# skips devDependencies (vite, @tailwindcss/vite, etc.) that `npm run build`
|
||||||
|
# itself needs (SolidStart's build runs through vite) - the build then fails
|
||||||
|
# with ERR_MODULE_NOT_FOUND for 'vite'. It belongs in the runtime stage only,
|
||||||
|
# where it actually affects the running server, not here.
|
||||||
|
|
||||||
# GATEWAY_URL is resolved at runtime from the process environment (see
|
# GATEWAY_URL is resolved at runtime from the process environment (see
|
||||||
# src/lib/server/gateway.ts), not baked in at build time.
|
# src/lib/server/gateway.ts), not baked in at build time.
|
||||||
|
|
@ -16,8 +20,10 @@ RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies (--include=dev is redundant with NODE_ENV unset, but
|
||||||
RUN npm ci --legacy-peer-deps --prefer-offline --no-audit
|
# explicit so this doesn't silently break again if NODE_ENV=production ever
|
||||||
|
# gets reintroduced above)
|
||||||
|
RUN npm ci --legacy-peer-deps --prefer-offline --no-audit --include=dev
|
||||||
|
|
||||||
# Copy source
|
# Copy source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
@ -33,6 +39,7 @@ WORKDIR /app
|
||||||
# Copy built output
|
# Copy built output
|
||||||
COPY --from=builder /app/.output ./.output
|
COPY --from=builder /app/.output ./.output
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
ENV PORT=9202
|
ENV PORT=9202
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
EXPOSE 9102
|
EXPOSE 9102
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue