prod.Dockerfile 2.2 KB

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