Update Dockerfile
Browse files- Dockerfile +13 -42
Dockerfile
CHANGED
|
@@ -1,47 +1,18 @@
|
|
| 1 |
-
FROM
|
| 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 |
-
|
| 11 |
-
|
| 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 |
-
|
| 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 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|