nexus-5-frontend-1/Dockerfile
2026-01-26 11:25:38 -05:00

56 lines
1.1 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
ENV PUBLIC_CALENDAR_API_URL=$PUBLIC_CALENDAR_API_URL
ENV PUBLIC_CALENDAR_API_KEY=$PUBLIC_CALENDAR_API_KEY
# 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 (ensure package.json has "start": "node build")
CMD ["npm", "start"]