65 lines
1.4 KiB
Docker
65 lines
1.4 KiB
Docker
# Use the official Node.js runtime as base image
|
|
FROM node:22-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Make PUBLIC_ vars available at build time
|
|
ARG PUBLIC_CALENDAR_API_URL
|
|
ARG PUBLIC_CALENDAR_API_KEY
|
|
ARG PUBLIC_EMAIL_API_URL
|
|
ARG PUBLIC_EMAIL_API_KEY
|
|
ARG PUBLIC_WAVE_BUSINESS_ID
|
|
ARG WAVE_ACCESS_TOKEN
|
|
ENV PUBLIC_CALENDAR_API_URL=$PUBLIC_CALENDAR_API_URL
|
|
ENV PUBLIC_CALENDAR_API_KEY=$PUBLIC_CALENDAR_API_KEY
|
|
ENV PUBLIC_EMAIL_API_URL=$PUBLIC_EMAIL_API_URL
|
|
ENV PUBLIC_EMAIL_API_KEY=$PUBLIC_EMAIL_API_KEY
|
|
ENV PUBLIC_WAVE_BUSINESS_ID=$PUBLIC_WAVE_BUSINESS_ID
|
|
ENV WAVE_ACCESS_TOKEN=$WAVE_ACCESS_TOKEN
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:22-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Ensure production mode in runtime
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install only production dependencies (modern flag)
|
|
RUN npm ci --omit=dev && npm cache clean --force
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder /app/build build/
|
|
|
|
# Create a non-root user
|
|
RUN addgroup -g 1001 -S nodejs
|
|
RUN adduser -S svelte -u 1001
|
|
|
|
# Change ownership of the app directory
|
|
RUN chown -R svelte:nodejs /app
|
|
USER svelte
|
|
|
|
# Expose the port your app runs on
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["node", "build"]
|