Files
lifeforge/docker/client/Dockerfile
melvinchia3636 57a24a52a7 refactor: extract shared configs & federation packages; rename log/server-utils
- Create @lifeforge/configs package with shared client/module Vite configs
  and the `@` path alias resolver extracted from client/vite.config.ts
- Create @lifeforge/federation package with module loading, federation
  provider, and route utilities moved out of the client app
- Rename packages/lifeforge-log → packages/log
- Rename packages/lifeforge-server-utils → packages/server-utils
- Update all imports, tsconfig references, Dockerfiles, and workspace
  scripts to reflect the new package names and locations
2026-06-25 08:54:14 +08:00

54 lines
1.4 KiB
Docker

# syntax=docker/dockerfile:1
# ============================================
# Builder stage - build client and tools
# ============================================
FROM oven/bun:alpine AS builder
# Accept build arg for API host
ARG VITE_API_HOST=/api
ENV VITE_API_HOST=$VITE_API_HOST
WORKDIR /app
# Copy source
COPY . .
# Install dependencies
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --linker isolated
# Build @lifeforge/log (required by forge CLI used in prebuild)
RUN cd /app/packages/log && bun run build
# Build shared package (required by server types)
RUN cd /app/shared && bun run build
# Build @lifeforge/server-utils (required by server types)
RUN cd /app/packages/server-utils && bun run build
# Build client
RUN cd /app/client && bun run build
# ============================================
# Production stage - Nginx static server
# ============================================
FROM nginx:alpine
# Install curl for health check
RUN apk add --no-cache curl
# Copy nginx config for SPA routing and API proxying
COPY docker/client/nginx.conf /etc/nginx/conf.d/default.conf
# Copy built client from builder
COPY --from=builder /app/client/dist /usr/share/nginx/html
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]