Refactor code structure for improved readability and maintainability

This commit is contained in:
Boris D
2025-09-09 13:28:39 +03:00
parent 5572bf48b7
commit afb1f343e0
23 changed files with 4239 additions and 0 deletions

64
Dockerfile Normal file
View File

@ -0,0 +1,64 @@
# Multi-stage build for production optimization
FROM node:18-alpine AS development
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy source code
COPY . .
# Expose port
EXPOSE 3000
# Development command
CMD ["yarn", "start:dev"]
# Production build stage
FROM node:18-alpine AS build
WORKDIR /usr/src/app
# Copy package files
COPY package*.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN yarn build
# Production stage
FROM node:18-alpine AS production
WORKDIR /usr/src/app
# Copy package files
COPY package*.json yarn.lock ./
# Install only production dependencies
RUN yarn install --frozen-lockfile --production && yarn cache clean
# Copy built application
COPY --from=build /usr/src/app/dist ./dist
# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nestjs -u 1001
# Change ownership of the app directory
USER nestjs
# Expose port
EXPOSE 3000
# Production command
CMD ["node", "dist/main"]