Advertisement
Guest User

Node Dockerfile

a guest
Nov 21st, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. # Image to use as a base for the others.
  2. FROM node:current-alpine3.19 AS base
  3.  
  4.  
  5.  
  6. # Image to actually build the output.
  7. FROM base AS builder
  8.  
  9. WORKDIR /app
  10.  
  11. COPY package.json package-lock.json ./
  12. RUN npm ci
  13.  
  14. COPY . .
  15. RUN npm run build
  16.  
  17.  
  18.  
  19. # Image to build the runtime, so that the final output doesn't have the NPM caches.
  20. FROM base AS runtime-builder
  21.  
  22. WORKDIR /app
  23.  
  24. COPY package.json package-lock.json ./
  25. RUN npm ci --omit=dev
  26.  
  27. COPY --from=builder /app/target/build /app/target
  28.  
  29.  
  30.  
  31. # Actual final runtime.
  32. FROM base AS runtime
  33. WORKDIR /app
  34. COPY --from=runtime-builder /app ./
  35.  
  36. CMD ["node", "./target/src"]
  37.  
  38. ENV NODE_ENV=production
  39. ENV PORT=8000
  40.  
  41. HEALTHCHECK --interval=10s --timeout=5s --start-period=15s \
  42. CMD wget --no-verbose --tries=1 localhost:$PORT/debug/ping || exit 1%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement