123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- FROM node:20-alpine3.19 as base_builder
- WORKDIR /usr/src/app
- ENV HOPP_ALLOW_RUNTIME_ENV=true
- # Required by @hoppscotch/js-sandbox to build `isolated-vm`
- RUN apk add python3 make g++
- RUN npm install -g pnpm
- COPY pnpm-lock.yaml .
- RUN pnpm fetch
- COPY . .
- RUN pnpm install -f --offline
- FROM base_builder as backend
- RUN apk add caddy
- WORKDIR /usr/src/app/packages/hoppscotch-backend
- RUN pnpm exec prisma generate
- RUN pnpm run build
- COPY --from=base_builder /usr/src/app/packages/hoppscotch-backend/backend.Caddyfile /etc/caddy/backend.Caddyfile
- # Remove the env file to avoid backend copying it in and using it
- RUN rm "../../.env"
- ENV PRODUCTION="true"
- ENV PORT=8080
- ENV APP_PORT=${PORT}
- ENV DB_URL=${DATABASE_URL}
- CMD ["node", "/usr/src/app/packages/hoppscotch-backend/prod_run.mjs"]
- EXPOSE 80
- EXPOSE 3170
- FROM base_builder as fe_builder
- WORKDIR /usr/src/app/packages/hoppscotch-selfhost-web
- RUN pnpm run generate
- FROM caddy:2-alpine as app
- WORKDIR /site
- COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/prod_run.mjs /usr
- COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/selfhost-web.Caddyfile /etc/caddy/selfhost-web.Caddyfile
- COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist/ .
- RUN apk add nodejs npm
- RUN npm install -g @import-meta-env/cli
- EXPOSE 80
- EXPOSE 3000
- CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/selfhost-web.Caddyfile --adapter caddyfile"]
- FROM base_builder as sh_admin_builder
- WORKDIR /usr/src/app/packages/hoppscotch-sh-admin
- # Generate two builds for `sh-admin`, one based on subpath-access and the regular build
- RUN pnpm run build --outDir dist-multiport-setup
- RUN pnpm run build --outDir dist-subpath-access --base /admin/
- FROM caddy:2-alpine as sh_admin
- WORKDIR /site
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/prod_run.mjs /usr
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/sh-admin-multiport-setup.Caddyfile /etc/caddy/sh-admin-multiport-setup.Caddyfile
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/sh-admin-subpath-access.Caddyfile /etc/caddy/sh-admin-subpath-access.Caddyfile
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist-multiport-setup /site/sh-admin-multiport-setup
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist-subpath-access /site/sh-admin-subpath-access
- RUN apk add nodejs npm
- RUN npm install -g @import-meta-env/cli
- EXPOSE 80
- EXPOSE 3100
- CMD ["node","/usr/prod_run.mjs"]
- FROM backend as aio
- RUN apk add caddy tini
- RUN npm install -g @import-meta-env/cli
- COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist /site/selfhost-web
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist-multiport-setup /site/sh-admin-multiport-setup
- COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist-subpath-access /site/sh-admin-subpath-access
- COPY aio-multiport-setup.Caddyfile /etc/caddy/aio-multiport-setup.Caddyfile
- COPY aio-subpath-access.Caddyfile /etc/caddy/aio-subpath-access.Caddyfile
- ENTRYPOINT [ "tini", "--" ]
- RUN apk --no-cache add curl
- COPY --chmod=755 healthcheck.sh .
- HEALTHCHECK --interval=2s CMD /bin/sh ./healthcheck.sh
- CMD ["node", "/usr/src/app/aio_run.mjs"]
- EXPOSE 3170
- EXPOSE 3000
- EXPOSE 3100
- EXPOSE 80
|