liuzhao521 commited on
Commit
fa70604
·
1 Parent(s): e02646f

Restore source build for latest features (Gemini image edit, Veo3.1)

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -3
Dockerfile CHANGED
@@ -1,9 +1,44 @@
1
- # Use pre-built image to avoid build timeout on HuggingFace Spaces
2
- FROM calciumion/new-api:latest
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # HuggingFace Spaces requires port 7860
5
  ENV PORT=7860
6
  EXPOSE 7860
7
 
8
- WORKDIR /data
9
  ENTRYPOINT ["/new-api"]
 
1
+ FROM oven/bun:latest AS builder
2
+
3
+ WORKDIR /build
4
+ COPY web/package.json .
5
+ COPY web/bun.lock .
6
+ RUN bun install
7
+ COPY ./web .
8
+ COPY ./VERSION .
9
+ RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
10
+
11
+ FROM golang:alpine AS builder2
12
+ ENV GO111MODULE=on CGO_ENABLED=0
13
+
14
+ ARG TARGETOS
15
+ ARG TARGETARCH
16
+ ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
17
+
18
+ WORKDIR /build
19
+
20
+ ADD go.mod go.sum ./
21
+ RUN go mod download
22
+
23
+ COPY . .
24
+ COPY --from=builder /build/dist ./web/dist
25
+ RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
26
+
27
+ FROM alpine
28
+
29
+ RUN apk upgrade --no-cache \
30
+ && apk add --no-cache ca-certificates tzdata \
31
+ && update-ca-certificates
32
+
33
+ # Create a non-root user for HuggingFace Spaces
34
+ RUN adduser -D -u 1000 user
35
+ USER user
36
+
37
+ COPY --from=builder2 /build/new-api /new-api
38
 
39
  # HuggingFace Spaces requires port 7860
40
  ENV PORT=7860
41
  EXPOSE 7860
42
 
43
+ WORKDIR /home/user/data
44
  ENTRYPOINT ["/new-api"]