Skip to content

Docker Configuration (API) #22

@huy1010

Description

@huy1010

Docker Configuration (API)

Description

Create Dockerfile and docker-compose setup for the API.

Acceptance Criteria

  • Multi-stage Dockerfile for apps/api:
    • Build stage: compile TypeScript
    • Production stage: minimal runtime image
  • Non-root user for security
  • Health check configuration
  • Optimized layer caching
  • .dockerignore file

Technical Notes

# Install deps stage
FROM node:25-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci

# Build stage
FROM node:25-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build

# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
RUN addgroup -g 1001 -S nodejs && adduser -S nestjs -u 1001
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER nestjs
EXPOSE 3001
CMD ["node", "dist/main.js"]

Labels

template, docker

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions