prod.Dockerfile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. ENV APP_PORT=${PORT}
  16. ENV DB_URL=${DATABASE_URL}
  17. CMD ["pnpm", "run", "start:prod"]
  18. EXPOSE 3170
  19. FROM base_builder as fe_builder
  20. WORKDIR /usr/src/app/packages/hoppscotch-selfhost-web
  21. RUN pnpm run generate
  22. FROM caddy:2-alpine as app
  23. WORKDIR /site
  24. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-sh-admin/prod_run.mjs /usr
  25. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/Caddyfile /etc/caddy/Caddyfile
  26. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist/ .
  27. RUN apk add nodejs npm
  28. RUN npm install -g @import-meta-env/cli
  29. EXPOSE 8080
  30. CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
  31. FROM base_builder as sh_admin_builder
  32. WORKDIR /usr/src/app/packages/hoppscotch-sh-admin
  33. RUN pnpm run build
  34. FROM caddy:2-alpine as sh_admin
  35. WORKDIR /site
  36. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/prod_run.mjs /usr
  37. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/Caddyfile /etc/caddy/Caddyfile
  38. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist/ .
  39. RUN apk add nodejs npm
  40. RUN npm install -g @import-meta-env/cli
  41. EXPOSE 8080
  42. CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
  43. FROM backend as aio
  44. RUN apk add caddy tini
  45. RUN npm install -g @import-meta-env/cli
  46. COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist /site/selfhost-web
  47. COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist /site/sh-admin
  48. COPY aio.Caddyfile /etc/caddy/Caddyfile
  49. ENTRYPOINT [ "tini", "--" ]
  50. RUN apk --no-cache add curl
  51. COPY --chmod=755 healthcheck.sh .
  52. HEALTHCHECK --interval=2s CMD /bin/sh ./healthcheck.sh
  53. CMD ["node", "/usr/src/app/aio_run.mjs"]
  54. EXPOSE 3170
  55. EXPOSE 3000
  56. EXPOSE 3100