gemtrack-backend/Dockerfile

44 lines
1.1 KiB
Docker

# Stage 1: Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies)
RUN npm install
# Copy source code and config files
COPY . .
# Generate TSOA specs/routes and build the project
RUN npm run build
# Stage 2: Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Set production environment
ENV NODE_ENV=production
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built files from the builder stage
COPY --from=builder /app/dist ./dist
# If TSOA requires the generated routes to be in src/shared, copy them as well
# Copy the entire src directory if needed for TSOA routes or other assets
# Actually, dist/main.js should have everything if bundled, but TSOA routes are usually required at runtime
COPY --from=builder /app/src/shared/interfaces/http/tsoa/generated ./src/shared/interfaces/http/tsoa/generated
# Expose the application port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]