- Rename .env.staging → .env.dev (and .default template) - Add .env.test.default for the test tier (test-api.oneskyit.com) - build:staging → build:dev/test/prod using vite --mode <name> - deploy:staging → deploy:dev; add deploy:test - Dockerfile: ARG BUILD_MODE=dev; explicit .env.runtime copy per mode - .dockerignore: rewritten (deduped); allow .env.dev/.env.test/.env.prod - .gitignore: track .env.dev.default and .env.test.default - Remove dead PUBLIC_AE_* imports from ae_stores.ts (ACCOUNT_ID, EVENT_ID, NO_ACCOUNT_ID_TOKEN, SPONSORSHIP_CFG_ID); sponsorship_cfg_id defaults to null - Strip dead vars from .env.prod.default template (AE_CFG_ID, AE_APP_NODE_PORT, ACCOUNT_ID, EVENT_ID, SPONSORSHIP_CFG_ID, NO_ACCOUNT_ID_TOKEN) - GUIDE__Development.md: build:staging → build:dev Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
2.0 KiB
Docker
63 lines
2.0 KiB
Docker
# Stage 1: Build the application
|
|
FROM node:24-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Install dependencies first for better Docker layer caching.
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
|
|
# Copy the rest of the source code.
|
|
COPY . .
|
|
|
|
# Build Argument to determine build environment (dev, test, prod).
|
|
ARG BUILD_MODE=dev
|
|
ENV NODE_ENV=production
|
|
|
|
# Sync the SvelteKit project to generate ./.svelte-kit/tsconfig.json
|
|
RUN npx svelte-kit sync
|
|
|
|
# Perform the build based on the BUILD_MODE argument.
|
|
# Each script uses vite --mode <name>, which reads .env.<name> directly — no cp hack needed.
|
|
RUN if [ "$BUILD_MODE" = "prod" ] || [ "$BUILD_MODE" = "production" ]; then \
|
|
npm run build:prod; \
|
|
elif [ "$BUILD_MODE" = "test" ]; then \
|
|
npm run build:test; \
|
|
else \
|
|
npm run build:dev; \
|
|
fi
|
|
|
|
# Copy the source env file to .env.runtime for the deploy stage.
|
|
# PUBLIC_* vars are baked into the JS bundle by vite; non-PUBLIC vars (AE_CFG_ID,
|
|
# AE_APP_NODE_PORT) are read by the Node server at runtime and need this file.
|
|
RUN if [ "$BUILD_MODE" = "prod" ] || [ "$BUILD_MODE" = "production" ]; then \
|
|
cp .env.prod .env.runtime; \
|
|
elif [ "$BUILD_MODE" = "test" ]; then \
|
|
cp .env.test .env.runtime; \
|
|
else \
|
|
cp .env.dev .env.runtime; \
|
|
fi
|
|
|
|
# Stage 2: Final runtime image
|
|
FROM node:24-alpine AS deploy-node
|
|
WORKDIR /app
|
|
|
|
# Copy built files and package info.
|
|
COPY --from=builder /app/build .
|
|
COPY --from=builder /app/package.json .
|
|
COPY --from=builder /app/package-lock.json .
|
|
|
|
# Install only production dependencies.
|
|
RUN npm install --omit=dev
|
|
|
|
# Copy the runtime env file (non-PUBLIC vars for the Node server).
|
|
COPY --from=builder /app/.env.runtime .env
|
|
|
|
# SvelteKit (via adapter-node) defaults to port 3000.
|
|
EXPOSE 3000
|
|
|
|
# Healthcheck to verify the app is running
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD node -e "fetch('http://localhost:3000/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"
|
|
|
|
CMD ["node", "index.js"]
|