2024-05-08 22:05:16 +00:00
|
|
|
# gitzone dockerfile_service
|
|
|
|
## STAGE 1 // BUILD
|
2024-11-18 14:21:48 +00:00
|
|
|
FROM code.foss.global/host.today/ht-docker-node:npmci as node1
|
2024-05-08 22:05:16 +00:00
|
|
|
COPY ./ /app
|
|
|
|
WORKDIR /app
|
|
|
|
ARG NPMCI_TOKEN_NPM2
|
|
|
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
|
|
|
RUN npmci npm prepare
|
|
|
|
RUN pnpm config set store-dir .pnpm-store
|
|
|
|
RUN rm -rf node_modules && pnpm install
|
|
|
|
RUN pnpm run build
|
|
|
|
|
|
|
|
# gitzone dockerfile_service
|
|
|
|
## STAGE 2 // install production
|
2024-11-18 14:21:48 +00:00
|
|
|
FROM code.foss.global/host.today/ht-docker-node:npmci as node2
|
2024-05-08 22:05:16 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=node1 /app /app
|
|
|
|
RUN rm -rf .pnpm-store
|
|
|
|
ARG NPMCI_TOKEN_NPM2
|
|
|
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
|
|
|
RUN npmci npm prepare
|
|
|
|
RUN pnpm config set store-dir .pnpm-store
|
|
|
|
RUN rm -rf node_modules/ && pnpm install --prod
|
|
|
|
|
|
|
|
|
|
|
|
## STAGE 3 // rebuild dependencies for alpine
|
2024-11-18 14:21:48 +00:00
|
|
|
FROM code.foss.global/host.today/ht-docker-node:alpine_npmci as node3
|
2024-05-08 22:05:16 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=node2 /app /app
|
|
|
|
ARG NPMCI_TOKEN_NPM2
|
|
|
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
|
|
|
RUN npmci npm prepare
|
|
|
|
RUN pnpm config set store-dir .pnpm-store
|
|
|
|
RUN pnpm rebuild -r
|
|
|
|
|
|
|
|
## STAGE 4 // the final production image with all dependencies in place
|
2024-11-18 14:21:48 +00:00
|
|
|
FROM code.foss.global/host.today/ht-docker-node:alpine as node4
|
2024-05-08 22:05:16 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=node3 /app /app
|
|
|
|
|
|
|
|
### Healthchecks
|
2024-11-18 14:21:48 +00:00
|
|
|
RUN pnpm install -g @servezone/healthy
|
2024-05-08 22:05:16 +00:00
|
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD [ "healthy" ]
|
|
|
|
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["npm", "start"]
|