35 lines
734 B
Docker
35 lines
734 B
Docker
|
|
# ---- Stage 1: Build ----
|
||
|
|
FROM node:24-alpine AS builder
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Install dependencies first (for caching)
|
||
|
|
COPY package.json package-lock.json* pnpm-lock.yaml* bun.lockb* ./
|
||
|
|
# If you're using pnpm or bun, adjust the install command below
|
||
|
|
RUN npm install
|
||
|
|
|
||
|
|
# Copy the source code
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Build the SvelteKit app
|
||
|
|
RUN npm run build
|
||
|
|
|
||
|
|
# ---- Stage 2: Production Runtime ----
|
||
|
|
FROM node:24-alpine AS runtime
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy built output and production deps
|
||
|
|
COPY --from=builder /app/package.json ./
|
||
|
|
COPY --from=builder /app/build ./build
|
||
|
|
COPY --from=builder /app/node_modules ./node_modules
|
||
|
|
|
||
|
|
# Default environment variables
|
||
|
|
ENV NODE_ENV=production
|
||
|
|
ENV PORT=3000
|
||
|
|
|
||
|
|
EXPOSE 3000
|
||
|
|
|
||
|
|
# Start the SvelteKit app
|
||
|
|
CMD ["node", "build"]
|