38 lines
719 B
Docker
38 lines
719 B
Docker
# Stage 1: Build stage
|
|
FROM node:24-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files and install dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copy the rest of the application files
|
|
COPY . .
|
|
|
|
# Build frontend and server.ts
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production stage
|
|
FROM node:24-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Set production environment
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
|
|
# Copy package files and install only production dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci --only=production
|
|
|
|
# Copy built assets and compiled server from builder stage
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/server.js ./server.js
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Run the server
|
|
CMD ["node", "server.js"]
|