mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-16 19:29:26 +02:00
The self-hosting Docker Compose setup fails to build on a clean clone due to several issues: 1. Dockerfile.web did not copy .npmrc into the deps stage. The project uses shamefully-hoist=true, so without it pnpm produces a different node_modules layout and module resolution breaks. 2. The builder stage copied individual node_modules directories from the deps stage (COPY --from=deps). This breaks pnpm's symlink structure -- especially on Windows where symlinks resolve to host paths. Additionally, packages/tsconfig has zero dependencies so its node_modules never exists, causing a hard COPY failure. Fixed by copying the full workspace from deps and running an offline pnpm install to re-link after source overlay. 3. next.config.ts imports dotenv but it was not declared as a direct dependency in apps/web/package.json. It resolves locally as a hoisted transitive dep but fails the TypeScript type check during next build in Docker. 4. docker/entrypoint.sh gets CRLF line endings on Windows due to git autocrlf, which breaks the shebang (container looks for /bin/sh\r). Added .gitattributes to enforce LF for shell scripts and a sed strip in the Dockerfile as a safety net.
39 lines
1016 B
Docker
39 lines
1016 B
Docker
# --- Build stage ---
|
|
FROM golang:1.26-alpine AS builder
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
WORKDIR /src
|
|
|
|
# Cache dependencies
|
|
COPY server/go.mod server/go.sum ./server/
|
|
RUN cd server && go mod download
|
|
|
|
# Copy server source
|
|
COPY server/ ./server/
|
|
|
|
# Build binaries
|
|
ARG VERSION=dev
|
|
ARG COMMIT=unknown
|
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/server ./cmd/server
|
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT}" -o bin/multica ./cmd/multica
|
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/migrate ./cmd/migrate
|
|
|
|
# --- Runtime stage ---
|
|
FROM alpine:3.21
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /src/server/bin/server .
|
|
COPY --from=builder /src/server/bin/multica .
|
|
COPY --from=builder /src/server/bin/migrate .
|
|
COPY server/migrations/ ./migrations/
|
|
COPY docker/entrypoint.sh .
|
|
RUN sed -i 's/\r$//' entrypoint.sh && chmod +x entrypoint.sh
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|