managarten/apps/zitare/apps/web/Dockerfile

34 lines
1.3 KiB
Docker

# syntax=docker/dockerfile:1
FROM sveltekit-base:local AS builder
ARG PUBLIC_BACKEND_URL=http://mana-auth
ARG PUBLIC_MANA_CORE_AUTH_URL=http://mana-auth:3001
ENV PUBLIC_BACKEND_URL=$PUBLIC_BACKEND_URL
ENV PUBLIC_MANA_CORE_AUTH_URL=$PUBLIC_MANA_CORE_AUTH_URL
COPY apps/zitare/packages/content ./apps/zitare/packages/content
COPY apps/zitare/apps/web ./apps/zitare/apps/web
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
pnpm install --no-frozen-lockfile --ignore-scripts
# Build app-specific packages (e.g. content with dist/ output)
RUN cd /app/apps/zitare/packages/content && pnpm build || true
WORKDIR /app/apps/zitare/apps/web
RUN pnpm exec svelte-kit sync
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build
FROM node:20-alpine AS production
WORKDIR /app/apps/zitare/apps/web
COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm
COPY --from=builder /app/apps/zitare/apps/web/node_modules ./node_modules
COPY --from=builder /app/apps/zitare/apps/web/build ./build
COPY --from=builder /app/apps/zitare/apps/web/package.json ./
EXPOSE 5025
ENV NODE_ENV=production PORT=5025 HOST=0.0.0.0
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:5025/health || exit 1
CMD ["node", "build"]