new-api/Dockerfile

39 lines
913 B
Docker
Raw Normal View History

2025-01-22 04:21:08 +08:00
FROM oven/bun:latest AS builder
2023-04-22 20:39:27 +08:00
WORKDIR /build
COPY web/package.json .
COPY web/bun.lock .
RUN bun install
2023-04-22 20:39:27 +08:00
COPY ./web .
COPY ./VERSION .
RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
2023-04-22 20:39:27 +08:00
FROM golang:alpine AS builder2
2025-10-11 13:24:04 +08:00
ENV GO111MODULE=on CGO_ENABLED=0
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
2025-12-02 23:15:20 +08:00
ENV GOEXPERIMENT=greenteagc
2023-04-22 20:39:27 +08:00
WORKDIR /build
ADD go.mod go.sum ./
RUN go mod download
2023-04-22 20:39:27 +08:00
COPY . .
2024-03-23 21:47:51 +08:00
COPY --from=builder /build/dist ./web/dist
2025-10-12 13:05:13 +08:00
RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
2023-04-22 20:39:27 +08:00
2025-12-02 23:15:20 +08:00
FROM debian:bookworm-slim
2023-04-22 20:39:27 +08:00
2025-12-02 23:15:20 +08:00
RUN apt-get update \
2025-12-12 20:37:32 +08:00
&& apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
2025-12-02 23:15:20 +08:00
&& rm -rf /var/lib/apt/lists/* \
2025-01-25 12:58:08 +07:00
&& update-ca-certificates
2023-04-26 13:04:01 +08:00
COPY --from=builder2 /build/new-api /
2023-04-22 20:39:27 +08:00
EXPOSE 3000
WORKDIR /data
ENTRYPOINT ["/new-api"]