blue-blue commited on
Commit
36ce5ec
·
verified ·
1 Parent(s): 233b8b5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -18
Dockerfile CHANGED
@@ -1,38 +1,51 @@
 
 
 
1
  FROM oven/bun:latest AS builder
2
 
3
  WORKDIR /build
4
- COPY web/package.json .
5
- COPY web/bun.lock .
6
  RUN bun install
7
- COPY ./web .
8
- COPY ./VERSION .
9
- RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
10
 
11
- FROM golang:alpine AS builder2
12
- ENV GO111MODULE=on CGO_ENABLED=0
 
 
 
 
13
 
14
- ARG TARGETOS
15
- ARG TARGETARCH
16
- ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
17
- ENV GOEXPERIMENT=greenteagc
18
 
 
19
  WORKDIR /build
20
 
21
- ADD go.mod go.sum ./
22
  RUN go mod download
23
 
24
  COPY . .
25
  COPY --from=builder /build/dist ./web/dist
26
- RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
27
 
 
 
 
 
 
 
 
28
  FROM debian:bookworm-slim
29
 
30
- RUN apt-get update \
31
- && apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
32
- && rm -rf /var/lib/apt/lists/* \
33
- && update-ca-certificates
 
 
 
34
 
35
- COPY --from=builder2 /build/new-api /
36
  EXPOSE 3000
37
  WORKDIR /data
38
  ENTRYPOINT ["/new-api"]
 
1
+ # =======================
2
+ # Frontend build (Bun)
3
+ # =======================
4
  FROM oven/bun:latest AS builder
5
 
6
  WORKDIR /build
7
+
8
+ COPY web/package.json web/bun.lock ./
9
  RUN bun install
 
 
 
10
 
11
+ COPY web ./web
12
+ COPY VERSION ./VERSION
13
+
14
+ RUN DISABLE_ESLINT_PLUGIN=true \
15
+ VITE_REACT_APP_VERSION=$(cat VERSION) \
16
+ bun run build
17
 
18
+ # =======================
19
+ # Backend build (Go)
20
+ # =======================
21
+ FROM golang:1.22-alpine AS builder2
22
 
23
+ ENV CGO_ENABLED=0 GO111MODULE=on
24
  WORKDIR /build
25
 
26
+ COPY go.mod go.sum ./
27
  RUN go mod download
28
 
29
  COPY . .
30
  COPY --from=builder /build/dist ./web/dist
 
31
 
32
+ RUN go build -ldflags="-s -w \
33
+ -X github.com/QuantumNous/new-api/common.Version=$(cat VERSION)" \
34
+ -o new-api
35
+
36
+ # =======================
37
+ # Runtime image
38
+ # =======================
39
  FROM debian:bookworm-slim
40
 
41
+ RUN apt-get update && \
42
+ apt-get install -y --no-install-recommends \
43
+ ca-certificates tzdata libasan8 wget && \
44
+ rm -rf /var/lib/apt/lists/* && \
45
+ update-ca-certificates
46
+
47
+ COPY --from=builder2 /build/new-api /new-api
48
 
 
49
  EXPOSE 3000
50
  WORKDIR /data
51
  ENTRYPOINT ["/new-api"]