FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy source code and tsconfig
COPY tsconfig.json ./
COPY src ./src
# Build TypeScript code
RUN npm run build
# Production stage
FROM node:18-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm install --omit=dev
# Copy built files from builder stage
COPY --from=builder /app/dist ./dist
COPY .env ./.env
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application
CMD ["node", "dist/index.js"]