-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (57 loc) · 2.45 KB
/
Copy pathDockerfile
File metadata and controls
85 lines (57 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# syntax=docker/dockerfile:1
FROM node:24-bookworm-slim AS frontend-builder
WORKDIR /src/frontend
ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
ARG NEXT_PUBLIC_API_BASE_URL=""
ENV NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL}
COPY VERSION /src/VERSION
COPY scripts /src/scripts
COPY frontend/package.json frontend/pnpm-lock.yaml ./
COPY frontend/scripts ./scripts
COPY frontend/public/pwa ./public/pwa
RUN corepack enable
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
pnpm config set store-dir /pnpm/store \
&& pnpm install --frozen-lockfile
COPY frontend ./
# 如果你的 Next 版本支持,可以在 next.config 里开启 turbopack build filesystem cache
RUN --mount=type=cache,id=next-cache,target=/src/frontend/.next/cache \
pnpm build
FROM golang:1.26-bookworm AS backend-builder
WORKDIR /src/backend
ARG GIT_COMMIT=unknown
ARG BUILD_TIME=""
COPY VERSION /src/VERSION
COPY backend/go.mod backend/go.sum ./
RUN apt-get update \
&& apt-get install -y --no-install-recommends libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY backend ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
VERSION="$(cat /src/VERSION)" \
&& if [ -z "${BUILD_TIME}" ]; then BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"; fi \
&& CGO_ENABLED=1 \
go build -trimpath \
-ldflags="-s -w -X github.com/DEEIX-AI/DEEIX-Chat/backend/internal/shared/buildinfo.Version=${VERSION} -X github.com/DEEIX-AI/DEEIX-Chat/backend/internal/shared/buildinfo.Commit=${GIT_COMMIT} -X github.com/DEEIX-AI/DEEIX-Chat/backend/internal/shared/buildinfo.BuildTime=${BUILD_TIME}" \
-o /out/deeix-chat ./cmd/server
FROM debian:bookworm-slim AS runtime-deps
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
FROM debian:bookworm-slim AS runtime
WORKDIR /app
COPY --from=runtime-deps /etc/ssl/certs /etc/ssl/certs
COPY --from=runtime-deps /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=runtime-deps /etc/localtime /etc/localtime
COPY --from=runtime-deps /etc/timezone /etc/timezone
COPY --from=backend-builder /out/deeix-chat /app/deeix-chat
COPY --from=frontend-builder /src/frontend/out /app/frontend/out
COPY LICENSE NOTICE /app/licenses/DEEIX-Chat/
ENV FRONTEND_DIST_DIR=/app/frontend/out
EXPOSE 8080
VOLUME ["/app/storage", "/app/data"]
CMD ["/app/deeix-chat"]