Dockerfile.backend-only 927 B

12345678910111213141516171819202122232425262728293031323334
  1. # Backend-only Dockerfile - uses official frontend, builds custom backend
  2. # This is useful when you only modified backend code and want to avoid frontend build
  3. FROM calciumion/new-api:latest AS frontend
  4. FROM golang:alpine AS builder
  5. ENV GO111MODULE=on CGO_ENABLED=0
  6. ARG TARGETOS
  7. ARG TARGETARCH
  8. ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
  9. ENV GOEXPERIMENT=greenteagc
  10. WORKDIR /build
  11. ADD go.mod go.sum ./
  12. RUN go mod download
  13. COPY . .
  14. # Copy frontend from official image
  15. COPY --from=frontend /web/dist ./web/dist
  16. RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
  17. FROM debian:bookworm-slim
  18. RUN apt-get update \
  19. && apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
  20. && rm -rf /var/lib/apt/lists/* \
  21. && update-ca-certificates
  22. COPY --from=builder /build/new-api /
  23. EXPOSE 3000
  24. WORKDIR /data
  25. ENTRYPOINT ["/new-api"]