Download Dockerfile from heroo/chatapi: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/heroo/chatapi/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/heroo/chatapi/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/heroo/chatapi/resolve/main/Dockerfile
1.58 kB
| FROM node:18.19.0-alpine as react-builder | |
| WORKDIR /app | |
| RUN apk add --no-cache git | |
| RUN wget -qO- -t1 -T2 "https://api.github.com/repos/ai365vip/chat-api/releases" | \ | |
| grep "tag_name" | \ | |
| head -n 1 | \ | |
| awk -F ":" '{print $2}' | \ | |
| sed 's/\"//g;s/,//g;s/ //g' > VERSION | |
| RUN git clone https://github.com/ai365vip/chat-api.git chat-api | |
| WORKDIR /app/chat-api | |
| # No need to copy package-lock.json, it is already in the cloned source code | |
| # 这时候我们已经在chat-api项目的根目录下了,我们可以直接为 web-user 和 web-admin 安装依赖项 | |
| RUN npm ci --prefix web-user | |
| RUN npm ci --prefix web-admin | |
| # 构建 web-user 和 web-admin 应用 | |
| RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build --prefix web-user | |
| RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build --prefix web-admin | |
| FROM golang:latest AS go-builder | |
| WORKDIR /build/chat-api | |
| COPY --from=react-builder /app/chat-api . | |
| RUN go mod download | |
| # 构建 Go 二进制文件 | |
| RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o chat-api | |
| FROM alpine:latest | |
| RUN apk update && apk add --no-cache ca-certificates tzdata && update-ca-certificates && rm -rf /var/cache/apk/* | |
| # 复制 Go 二进制文件 | |
| COPY --from=go-builder /build/chat-api/chat-api /chat-api | |
| COPY --from=cloudflare/cloudflared:latest /usr/local/bin/cloudflared /usr/local/bin/cloudflared | |
| EXPOSE 3000 | |
| WORKDIR /data | |
| RUN chmod 777 -R /data | |
| ENTRYPOINT cloudflared tunnel --no-autoupdate run --token $CF_TOKEN & \ | |
| /chat-api |