egentrening/Dockerfile

39 lines
936 B
Text
Raw Permalink Normal View History

2025-09-03 16:05:08 +02:00
# Build stage - includes dev dependencies for building the app
FROM node:22-alpine AS build
2025-09-02 23:58:00 +02:00
2025-09-03 16:05:08 +02:00
# Set working directory for build operations
2025-09-02 23:58:00 +02:00
WORKDIR /app
2025-09-03 16:05:08 +02:00
# Copy package files to install dependencies
2025-09-02 23:58:00 +02:00
COPY package*.json ./
2025-09-03 16:05:08 +02:00
# Install all dependencies including dev dependencies needed for build
RUN npm ci
2025-09-02 23:58:00 +02:00
2025-09-03 16:05:08 +02:00
# Copy source code and build the application
2025-09-02 23:58:00 +02:00
COPY . .
2025-09-03 19:10:17 +02:00
RUN npx svelte-kit sync
2025-09-03 00:23:17 +02:00
RUN npm run build
2025-09-03 16:05:08 +02:00
# Production stage - clean runtime environment
FROM node:22-alpine AS production
2025-09-02 23:58:00 +02:00
2025-09-03 16:05:08 +02:00
# Set working directory for runtime
2025-09-02 23:58:00 +02:00
WORKDIR /app
2025-09-03 16:05:08 +02:00
# Copy package files for production install
2025-09-02 23:58:00 +02:00
COPY package*.json ./
2025-09-03 16:05:08 +02:00
# Install only production dependencies (excludes dev dependencies)
RUN npm ci --only=production
2025-09-02 23:58:00 +02:00
2025-09-03 16:05:08 +02:00
# Copy built application from build stage
COPY --from=build /app/build ./build
2025-09-02 23:58:00 +02:00
2025-09-03 16:05:08 +02:00
# Expose the port the application will run on
2025-09-02 23:58:00 +02:00
EXPOSE 3000
2025-09-03 16:05:08 +02:00
# Set environment to production
2025-09-02 23:58:00 +02:00
ENV NODE_ENV=production
2025-09-03 16:05:08 +02:00
# Start the application
2025-09-03 00:48:35 +02:00
CMD ["node", "build"]