Dockerfile 734 B

123456789101112131415161718192021222324252627282930313233
  1. FROM node:16 as builder
  2. WORKDIR /build
  3. COPY web/package.json .
  4. RUN npm install
  5. COPY ./web .
  6. COPY ./VERSION .
  7. RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) npm run build
  8. FROM golang AS builder2
  9. ENV GO111MODULE=on \
  10. CGO_ENABLED=1 \
  11. GOOS=linux
  12. WORKDIR /build
  13. ADD go.mod go.sum ./
  14. RUN go mod download
  15. COPY . .
  16. COPY --from=builder /build/dist ./web/dist
  17. RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
  18. FROM alpine
  19. RUN apk update \
  20. && apk upgrade \
  21. && apk add --no-cache ca-certificates tzdata \
  22. && update-ca-certificates 2>/dev/null || true
  23. COPY --from=builder2 /build/one-api /
  24. EXPOSE 3000
  25. WORKDIR /data
  26. ENTRYPOINT ["/one-api"]