55e0a3cde6
The image builds were never exercised: the docker job needs lint, and lint was failing, so nothing downstream of it ever ran. Four defects had accumulated behind that gate, each fatal on its own. - pnpm creates no node_modules for a package without dependencies, and @source/shared has none. Three COPY lines named that path and failed. - The production stage copied apps/api/dist, which tsc never wrote: tsconfig.base.json sets noEmit and no package overrides it. Rather than turn emit on — every @source/* package points main at its TypeScript source, and @source/proto derives daemon.proto's location from a /src/index.ts module URL — the stage now runs the sources through tsx, exactly as the migrate stage has always done. - tsx lives in apps/api/node_modules/.bin under pnpm's isolated layout, so the command only resolves from the package directory. - Both healthchecks probed localhost, which musl resolves to ::1 while the servers bind IPv4. Every probe was refused, so the containers sat unhealthy forever — and `docker compose up --wait`, which is how a panel installs this stack, waits for healthy. Also fixed the postgres healthcheck in both compose files. pg_isready without -h asks over the unix socket, which answers during the image's init phase before the server listens on TCP; the migrate container then started and died with ECONNREFUSED against a container Compose had just called healthy. Verified by running the full stack from docker-compose.panel.yml with locally built images: migrations and seed complete, api, web, daemon, postgres and redis all report healthy, and /api/health answers 200 through the web container's proxy.
44 lines
1.6 KiB
Docker
44 lines
1.6 KiB
Docker
FROM node:20-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
|
WORKDIR /app
|
|
|
|
# --- Dependencies ---
|
|
FROM base AS deps
|
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
|
|
COPY apps/web/package.json apps/web/
|
|
COPY packages/shared/package.json packages/shared/
|
|
COPY packages/ui/package.json packages/ui/
|
|
# pnpm creates no node_modules for a workspace package that has no
|
|
# dependencies of its own, and @source/shared has none. The COPY lines below
|
|
# name that path, so give them an empty directory to find instead of failing
|
|
# the build on a path pnpm never made.
|
|
RUN pnpm install --frozen-lockfile --prod=false && mkdir -p packages/shared/node_modules
|
|
|
|
# --- Build ---
|
|
FROM base AS build
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
|
COPY --from=deps /app/packages/shared/node_modules ./packages/shared/node_modules
|
|
COPY --from=deps /app/packages/ui/node_modules ./packages/ui/node_modules
|
|
COPY . .
|
|
|
|
ARG VITE_API_URL=/api
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
RUN pnpm --filter @source/shared build && \
|
|
pnpm --filter @source/ui build && \
|
|
pnpm --filter @source/web build
|
|
|
|
# --- Production (nginx) ---
|
|
FROM nginx:alpine AS production
|
|
|
|
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build /app/apps/web/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
# 127.0.0.1 for the same reason as the API image: localhost resolves to
|
|
# ::1, where nginx is not listening.
|
|
HEALTHCHECK --interval=30s --timeout=5s CMD wget -qO- http://127.0.0.1/health || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|