one-api/Dockerfile
2023-09-14 11:52:28 +08:00

41 lines
909 B
Docker

# Initial stage
FROM python:3.11 as translator
WORKDIR /app
COPY . .
RUN chmod +x ./translate-en.sh && ./translate-en.sh
FROM oven/bun:latest as builder
WORKDIR /build
COPY ./web/package*.json ./web/bun.lockb ./web/.npmrc ./
RUN bun i
COPY --from=translator ./app/web .
COPY ./VERSION .
RUN REACT_APP_VERSION=$(cat VERSION) bun run build
FROM golang AS builder2
ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux
WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY --from=translator /app .
COPY --from=builder /build/build ./web/build
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
FROM alpine
RUN apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates 2>/dev/null || true
COPY --from=builder2 /build/one-api /
EXPOSE 3000
WORKDIR /data
ENTRYPOINT ["/one-api"]