Simplify Docker deployment
This commit is contained in:
+27
-6
@@ -1,7 +1,28 @@
|
||||
FROM dhi.io/node:23-alpine3.21-dev
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies first (better layer caching)
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source and build
|
||||
COPY . .
|
||||
CMD ["npm", "run", "build"]
|
||||
CMD ["node", "-r", "dotenv/config", "build"]
|
||||
RUN npm run build
|
||||
|
||||
# Production image
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Only copy what we need for production
|
||||
COPY --from=builder /app/build ./build
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/package-lock.json ./
|
||||
|
||||
# Install production dependencies only (including dotenv)
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
EXPOSE 3001
|
||||
|
||||
CMD ["node", "-r", "dotenv/config", "build"]
|
||||
Reference in New Issue
Block a user