dockerize smtp-proxy (#118)

This commit is contained in:
KM Koushik
2025-03-20 21:56:12 +11:00
committed by GitHub
parent 5465e2ec74
commit ecd28428d2
5 changed files with 141 additions and 53 deletions

View File

@@ -0,0 +1,45 @@
# Stage 1: Build stage
FROM node:20-alpine AS builder
# Install pnpm (package manager) globally
RUN npm install -g pnpm
# Set working directory for the application
WORKDIR /app
# Copy configuration files first
COPY package.json tsconfig.json tsup.config.ts ./
# Install dependencies (including devDependencies)
RUN pnpm install
# Copy the source code
COPY src/ ./src/
# Build the application
RUN pnpm run build
# Remove development dependencies to reduce size
RUN pnpm prune --prod
# Stage 2: Production stage
FROM node:20-alpine AS production
# Set working directory in the final image
WORKDIR /app
# Copy necessary files from the builder stage: production node_modules, build output, and package definition
COPY --from=builder /app/node_modules ./node_modules
# Copy only the necessary files from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
# Expose SMTP ports (standard SMTP, SMTPS, and alternative ports)
EXPOSE 25 465 587 2465 2587
# Run the SMTP server
CMD ["node", "dist/server.js"]