Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +37 -8
Dockerfile
CHANGED
@@ -1,15 +1,44 @@
|
|
1 |
-
FROM
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
|
|
|
|
12 |
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:16 as builder
|
2 |
|
3 |
+
WORKDIR /build
|
4 |
+
RUN git clone https://github.com/MartialBE/one-api.git .
|
5 |
+
RUN wget -qO- -t1 -T2 "https://api.github.com/repos/MartialBE/one-hub/releases" | \
|
6 |
+
grep "tag_name" | \
|
7 |
+
head -n 1 | \
|
8 |
+
awk -F ":" '{print $2}' | \
|
9 |
+
sed 's/\"//g;s/,//g;s/ //g' > VERSION
|
10 |
|
11 |
+
RUN sed -i'' 's|router.Group("/v1|router.Group("/api/v1|g' /build/router/relay-router.go
|
12 |
+
RUN sed -i'' 's|HasPrefix(path, "/v1|HasPrefix(path, "/api/v1|g' /build/relay/common.go
|
13 |
|
14 |
+
WORKDIR /build/web
|
15 |
+
RUN npm install
|
16 |
+
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ../VERSION) npm run build
|
17 |
|
18 |
+
FROM golang AS builder2
|
19 |
|
20 |
+
ENV GO111MODULE=on \
|
21 |
+
CGO_ENABLED=1 \
|
22 |
+
GOOS=linux
|
23 |
|
24 |
+
WORKDIR /build
|
25 |
+
RUN git clone https://github.com/MartialBE/one-api.git .
|
26 |
+
RUN sed -i'' 's|router.Group("/v1|router.Group("/api/v1|g' /build/router/relay-router.go
|
27 |
+
RUN sed -i'' 's|HasPrefix(path, "/v1|HasPrefix(path, "/api/v1|g' /build/relay/common.go
|
28 |
|
29 |
+
RUN go mod download
|
30 |
+
COPY --from=builder /build/web/build ./web/build
|
31 |
+
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
32 |
+
|
33 |
+
FROM alpine
|
34 |
+
|
35 |
+
RUN apk update \
|
36 |
+
&& apk upgrade \
|
37 |
+
&& apk add --no-cache ca-certificates tzdata \
|
38 |
+
&& update-ca-certificates 2>/dev/null || true
|
39 |
+
|
40 |
+
COPY --from=builder2 /build/one-api /
|
41 |
+
EXPOSE 3000
|
42 |
+
WORKDIR /data
|
43 |
+
RUN chmod 777 -R /data
|
44 |
+
ENTRYPOINT ["/one-api"]
|