zaxx commited on
Commit
efb832f
·
verified ·
1 Parent(s): 7431074

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -42
Dockerfile CHANGED
@@ -1,47 +1,18 @@
1
- FROM oven/bun:1@sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7 AS builder
2
- WORKDIR /build
3
- COPY web/default/package.json .
4
- COPY web/default/bun.lock .
5
- RUN bun install
6
- COPY ./web/default .
7
- COPY ./VERSION .
8
- RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
9
 
10
- FROM golang:1.26.1-alpine@sha256:2389ebfa5b7f43eeafbd6be0c3700cc46690ef842ad962f6c5bd6be49ed82039 AS builder2
11
- ENV GO111MODULE=on CGO_ENABLED=0
12
- ARG TARGETOS
13
- ARG TARGETARCH
14
- ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
15
- ENV GOEXPERIMENT=greenteagc
16
- WORKDIR /build
17
- ADD go.mod go.sum ./
18
- RUN go mod download
19
- COPY . .
20
- # Copy only the default UI dist folder
21
- COPY --from=builder /build/dist ./web/default/dist
22
- RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
23
 
24
- FROM debian:bookworm-slim@sha256:f06537653ac770703bc45b4b113475bd402f451e85223f0f2837acbf89ab020a
25
- RUN apt-get update \
26
- && apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
27
- && rm -rf /var/lib/apt/lists/* \
28
- && update-ca-certificates
29
-
30
- # Create a non-root user (UID 1000) required by Hugging Face Spaces
31
- RUN useradd -m -u 1000 user
32
-
33
- COPY --from=builder2 /build/new-api /
34
- COPY LICENSE NOTICE THIRD-PARTY-LICENSES.md /licenses/
35
-
36
- # Create the data directory and set permissions for the non-root user
37
- RUN mkdir -p /data && chown -R user:user /data /new-api /licenses
38
-
39
- # Switch to the non-root user
40
- USER user
41
-
42
- # Set the default port to 7860 (Hugging Face standard)
43
  ENV PORT=7860
44
  EXPOSE 7860
45
 
46
- WORKDIR /data
47
- ENTRYPOINT ["/new-api"]
 
 
 
 
 
 
 
 
1
+ FROM calciumion/new-api:latest
 
 
 
 
 
 
 
2
 
3
+ # Switch to root temporarily to adjust folder access
4
+ USER root
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ # 1. Hugging Face Spaces expect the app to listen on port 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  ENV PORT=7860
8
  EXPOSE 7860
9
 
10
+ # 2. Open up permissions on the data and log directories
11
+ # so that Hugging Face's non-root runtime (UID 1000) can read/write to them freely
12
+ RUN mkdir -p /data /app/logs && chmod -R 777 /data /app
13
+
14
+ # 3. Switch back to the standard non-root user required by Spaces
15
+ USER 1000
16
+
17
+ # The official base image already includes the entrypoint binary (/new-api),
18
+ # so it will spin up automatically.