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