Refactor Dockerfile for Node 18 and pnpm

Updated Dockerfile to use Node 18-alpine and streamline build process.
This commit is contained in:
Steven Noack 2025-12-11 06:32:28 +01:00 committed by GitHub
parent 051f4acecc
commit 8c7648d330
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,34 +1,28 @@
FROM node:20.11-bullseye AS build
FROM node:18-alpine
# Install pnpm
RUN npm install -g pnpm
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN pnpm install
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Copy application files
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source
COPY . .
# Generate prisma client and build the application
# Build
RUN pnpm run build
# Run prisma migrations
RUN npx prisma generate
RUN npm run build
# Runtime stage
FROM node:20.11-alpine as runtime
WORKDIR /app
RUN apk update && \
apk add --no-cache openssl && \
rm -rf /var/cache/apk/*
# Copy built files from the build stage
COPY --from=build /app .
# Install only runtime dependencies
RUN npm install --only=production
# Create config directory
RUN mkdir -p /app/config
EXPOSE 3000
ENTRYPOINT [ "node", "./dist/index.js" ]
CMD ["start"]
CMD ["node", "dist/index.js"]