- Changed 'npm ci --production' to 'npm install --production' - More forgiving with cached package files in CI/CD - Matches working pattern from other deployments - Fixes Easypanel build cache issues
46 lines
1.1 KiB
Docker
46 lines
1.1 KiB
Docker
# Build Stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
# Create data directory for database
|
|
RUN mkdir -p data
|
|
|
|
# Build Astro
|
|
RUN npm run build
|
|
|
|
# Production Stage
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install SQLite runtime
|
|
RUN apk add --no-cache sqlite-libs
|
|
|
|
COPY package*.json ./
|
|
RUN npm install --production
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/astro.config.mjs ./
|
|
COPY --from=builder /app/data ./data
|
|
|
|
EXPOSE 80
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:80', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
|
|
ENV NODE_ENV=production
|
|
ENV ASTRO_DB_REMOTE_URL=file:/app/data/consent.db
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=80
|
|
|
|
# Use serve to host static files on port 80
|
|
CMD ["npx", "serve", "dist", "-l", "80", "--config", "{\"directoryListing\": false, \"headers\": [{\"source\": \"**\", \"headers\": [{\"key\": \"Cache-Control\", \"value\": \"public, max-age=31536000, immutable\"}]}]}"]
|