add docker file

This commit is contained in:
hsueh chiahao
2025-10-26 11:03:27 +08:00
parent f92417d5e3
commit f335c7546a
4 changed files with 101 additions and 1 deletions

39
Dockerfile Normal file
View File

@@ -0,0 +1,39 @@
# Build stage
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install all dependencies (including dev dependencies for building)
RUN npm ci
# Copy source code
COPY src/ ./src/
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine AS production
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Expose port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]