# syntax=docker/dockerfile:1 # ─── Base ──────────────────────────────────────────────────────────────────── FROM oven/bun:1.4-alpine AS base WORKDIR /app ENV CI=1 # ─── Dependencies ──────────────────────────────────────────────────────────── FROM base AS deps COPY package.json bun.lock bunfig.toml turbo.json ./ COPY apps/backend/package.json ./apps/backend/ COPY apps/web/package.json ./apps/web/ COPY packages/config/package.json ./packages/config/ COPY packages/shared/package.json ./packages/shared/ # bun's global cache weighs ~370MB: it is dropped in the same layer. RUN bun install --frozen-lockfile && rm -rf /root/.bun/install # ─── Vite build ────────────────────────────────────────────────────────────── FROM deps AS build # Vite replaces import.meta.env.* at build time, not at runtime. # Empty = same origin: nginx's /api proxy acts as the API. ARG VITE_API_URL="" ENV VITE_API_URL=$VITE_API_URL COPY apps/web ./apps/web COPY packages ./packages RUN bun --filter @gruperly/web build # ─── Final image ───────────────────────────────────────────────────────────── FROM nginx:1.27-alpine AS web COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/apps/web/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ CMD wget --quiet --tries=1 --spider http://127.0.0.1/ || exit 1 CMD ["nginx", "-g", "daemon off;"]