mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-06-20 15:38:07 +02:00
47 lines
708 B
Text
47 lines
708 B
Text
|
|
# Build stage
|
||
|
|
FROM node:20-alpine AS builder
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy package files
|
||
|
|
COPY package*.json ./
|
||
|
|
|
||
|
|
# Install dependencies
|
||
|
|
RUN npm ci
|
||
|
|
|
||
|
|
# Copy source code
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Build TypeScript
|
||
|
|
RUN npm run build
|
||
|
|
|
||
|
|
# Production stage
|
||
|
|
FROM node:20-alpine AS production
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy package files
|
||
|
|
COPY package*.json ./
|
||
|
|
|
||
|
|
# Install production dependencies only
|
||
|
|
RUN npm ci --only=production
|
||
|
|
|
||
|
|
# Copy built files from builder
|
||
|
|
COPY --from=builder /app/dist ./dist
|
||
|
|
|
||
|
|
# Create non-root user
|
||
|
|
RUN addgroup -g 1001 -S nodejs && \
|
||
|
|
adduser -S nodejs -u 1001
|
||
|
|
|
||
|
|
USER nodejs
|
||
|
|
|
||
|
|
# Expose port
|
||
|
|
EXPOSE 3001
|
||
|
|
|
||
|
|
# Set environment variables
|
||
|
|
ENV NODE_ENV=production
|
||
|
|
ENV PORT=3001
|
||
|
|
|
||
|
|
# Start the application
|
||
|
|
CMD ["node", "dist/index.js"]
|