lonetest commited on
Commit
2a6546a
·
verified ·
1 Parent(s): 77c9093

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -13
Dockerfile CHANGED
@@ -5,35 +5,34 @@ RUN git clone https://github.com/Calcium-Ion/new-api.git
5
 
6
  # Stage 2: Node builder
7
  FROM node:16 as builder
8
-
9
  WORKDIR /build
10
- COPY web/package.json .
11
  RUN npm install
12
- COPY ./web .
13
- COPY ./VERSION .
14
- RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) npm run build
15
 
 
16
  FROM golang AS builder2
17
-
18
  ENV GO111MODULE=on \
19
  CGO_ENABLED=1 \
20
  GOOS=linux
21
-
22
  WORKDIR /build
23
- ADD go.mod go.sum ./
 
24
  RUN go mod download
25
- COPY . .
26
  COPY --from=builder /build/dist ./web/dist
27
  RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
28
 
 
29
  FROM alpine
30
-
31
  RUN apk update \
32
  && apk upgrade \
33
  && apk add --no-cache ca-certificates tzdata \
34
  && update-ca-certificates 2>/dev/null || true
35
-
36
  COPY --from=builder2 /build/one-api /
37
- EXPOSE 3000
38
  WORKDIR /data
39
- ENTRYPOINT ["/one-api"]
 
 
 
5
 
6
  # Stage 2: Node builder
7
  FROM node:16 as builder
 
8
  WORKDIR /build
9
+ COPY --from=clone /app/new-api/web/package.json .
10
  RUN npm install
11
+ COPY --from=clone /app/new-api/web .
12
+ COPY --from=clone /app/new-api/VERSION .
13
+ RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
14
 
15
+ # Stage 3: Go builder
16
  FROM golang AS builder2
 
17
  ENV GO111MODULE=on \
18
  CGO_ENABLED=1 \
19
  GOOS=linux
 
20
  WORKDIR /build
21
+ COPY --from=clone /app/new-api/go.mod .
22
+ COPY --from=clone /app/new-api/go.sum .
23
  RUN go mod download
24
+ COPY --from=clone /app/new-api .
25
  COPY --from=builder /build/dist ./web/dist
26
  RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
27
 
28
+ # Stage 4: Final stage
29
  FROM alpine
 
30
  RUN apk update \
31
  && apk upgrade \
32
  && apk add --no-cache ca-certificates tzdata \
33
  && update-ca-certificates 2>/dev/null || true
 
34
  COPY --from=builder2 /build/one-api /
 
35
  WORKDIR /data
36
+ RUN chmod -R 777 /data
37
+ ENTRYPOINT ["/one-api"]
38
+ EXPOSE 3000