| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- # -----------------------------------------------------------------------------
- # Node builder: frontend only
- # -----------------------------------------------------------------------------
- FROM node:22-bookworm-slim AS node-builder
- RUN corepack enable && corepack prepare pnpm@latest --activate
- WORKDIR /build
- COPY frontend/ ./
- RUN CI=true pnpm install && pnpm build
- # -----------------------------------------------------------------------------
- # Go builder: backend only
- # -----------------------------------------------------------------------------
- FROM golang:1.26.1 AS go-builder
- RUN apt-get update && apt-get install -y --no-install-recommends \
- git \
- && rm -rf /var/lib/apt/lists/*
- RUN --mount=type=cache,target=/go/pkg/mod \
- --mount=type=cache,target=/root/.cache/go-build \
- go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
- WORKDIR /build
- COPY go.mod go.sum ./
- RUN --mount=type=cache,target=/go/pkg/mod \
- go mod download
- COPY . .
- RUN sqlc generate
- RUN --mount=type=cache,target=/go/pkg/mod \
- --mount=type=cache,target=/root/.cache/go-build \
- GOOS=linux go build \
- -trimpath \
- -ldflags "-s -w" \
- -o goflare ./cmd/goflare
- # -----------------------------------------------------------------------------
- # Final image: copy from both builders
- # -----------------------------------------------------------------------------
- FROM debian:bookworm-slim
- RUN apt-get update && apt-get install -y --no-install-recommends \
- ca-certificates \
- curl \
- && rm -rf /var/lib/apt/lists/*
- WORKDIR /app
- COPY --from=go-builder /build/goflare /app/goflare
- COPY --from=node-builder /build/dist /app/frontend
- RUN mkdir -p /app/data
- EXPOSE 8080
- HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
- CMD curl -sf http://localhost:8080/api/setup || exit 1
- ENV GOFLARE_PORT=:8080 \
- GOFLARE_DB_PATH=/app/data/goflare.db \
- GOFLARE_FRONTEND_DIR=/app/frontend
- CMD ["/app/goflare"]
|