feat: better dockerfile
This commit is contained in:
parent
270e366cd9
commit
839dcc3ab2
@ -1,11 +1,11 @@
|
||||
# Initial stage
|
||||
FROM python:3.11 as translator
|
||||
FROM python:3.12 as translator
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json
|
||||
|
||||
# Node build stage
|
||||
FROM node:18 as builder
|
||||
FROM node:18-alpine as nodeBuilder
|
||||
WORKDIR /build
|
||||
COPY ./web/package*.json ./
|
||||
RUN npm ci
|
||||
@ -13,7 +13,7 @@ COPY --from=translator /app .
|
||||
RUN cd web && REACT_APP_VERSION=$(cat VERSION) npm run build
|
||||
|
||||
# Go build stage
|
||||
FROM golang AS builder2
|
||||
FROM golang:1.20.5 AS goBuilder
|
||||
ENV GO111MODULE=on \
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=linux
|
||||
@ -22,13 +22,13 @@ COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
COPY --from=translator /app .
|
||||
COPY --from=builder /build/web/build ./web/build
|
||||
COPY --from=nodeBuilder /build/web/build ./web/build
|
||||
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
||||
|
||||
# Final stage
|
||||
FROM alpine
|
||||
FROM alpine:latest
|
||||
RUN apk update && apk upgrade && apk add --no-cache ca-certificates tzdata && update-ca-certificates 2>/dev/null || true
|
||||
WORKDIR /data
|
||||
COPY --from=builder2 /build/one-api /
|
||||
COPY --from=goBuilder /build/one-api /
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["/one-api"]
|
||||
|
Loading…
Reference in New Issue
Block a user