prod.Dockerfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. FROM node:18-alpine3.16 as base_builder
  2. WORKDIR /usr/src/app
  3. ENV HOPP_ALLOW_RUNTIME_ENV=true
  4. RUN npm install -g pnpm
  5. COPY pnpm-lock.yaml .
  6. RUN pnpm fetch
  7. COPY . .
  8. RUN pnpm install -f --offline
  9. FROM base_builder as backend
  10. WORKDIR /usr/src/app/packages/hoppscotch-backend
  11. RUN pnpm exec prisma generate
  12. RUN pnpm run build
  13. ENV PRODUCTION="true"
  14. ENV PORT=3170
  15. CMD ["pnpm", "run", "start:prod"]
  16. EXPOSE 3170
  17. FROM base_builder as fe_builder
  18. WORKDIR /usr/src/app/packages/hoppscotch-selfhost-web
  19. RUN pnpm run generate
  20. FROM caddy:2-alpine as app
  21. WORKDIR /site
  22. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-sh-admin/prod_run.mjs /usr
  23. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/Caddyfile /etc/caddy/Caddyfile
  24. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist/ .
  25. RUN apk add nodejs npm
  26. RUN npm install -g @import-meta-env/cli
  27. EXPOSE 8080
  28. CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
  29. FROM base_builder as sh_admin_builder
  30. WORKDIR /usr/src/app/packages/hoppscotch-sh-admin
  31. RUN pnpm run build
  32. FROM caddy:2-alpine as sh_admin
  33. WORKDIR /site
  34. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/prod_run.mjs /usr
  35. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/Caddyfile /etc/caddy/Caddyfile
  36. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist/ .
  37. RUN apk add nodejs npm
  38. RUN npm install -g @import-meta-env/cli
  39. EXPOSE 8080
  40. CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
  41. FROM backend as aio
  42. RUN apk add caddy tini
  43. RUN npm install -g @import-meta-env/cli
  44. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist /site/selfhost-web
  45. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist /site/sh-admin
  46. COPY aio.Caddyfile /etc/caddy/Caddyfile
  47. ENTRYPOINT [ "tini", "--" ]
  48. CMD ["node", "/usr/src/app/aio_run.mjs"]
  49. EXPOSE 3170
  50. EXPOSE 3000
  51. EXPOSE 3100