This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,17 +1,30 @@
|
||||
# ---- build stage ----
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
# Install deps
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source + build
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM node:20-alpine
|
||||
# ---- runtime stage ----
|
||||
FROM node:20-alpine AS runtime
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
# Optional: run as non-root
|
||||
RUN addgroup -S nodegroup && adduser -S nodeuser -G nodegroup
|
||||
|
||||
# Copy only the built output
|
||||
COPY --from=build /app/.output ./.output
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
USER nodeuser
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user