-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (49 loc) 路 1.46 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (49 loc) 路 1.46 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
# Author: ProgramZmh
# License: Apache-2.0
# Description: Dockerfile for chatnio
FROM --platform=$TARGETPLATFORM golang:1.20-alpine AS backend
WORKDIR /backend
COPY . .
# Set go proxy to https://goproxy.cn (open for vps in China Mainland)
# RUN go env -w GOPROXY=https://goproxy.cn,direct
ARG TARGETARCH
ARG TARGETOS
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on CGO_ENABLED=1
# Install build dependencies
RUN apk update && \
apk add --no-cache \
gcc \
musl-dev \
g++ \
make \
linux-headers
# Build backend
RUN go build -o chat -a -ldflags="-extldflags=-static" .
FROM node:18 AS frontend
WORKDIR /app
COPY ./app .
RUN npm install -g pnpm && \
pnpm install && \
pnpm run build && \
rm -rf node_modules src
FROM alpine
# Install dependencies
RUN apk upgrade --no-cache && \
apk add --no-cache wget ca-certificates tzdata && \
update-ca-certificates 2>/dev/null || true
# Set timezone
RUN echo "Asia/Shanghai" > /etc/timezone && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
WORKDIR /
# Copy dist
COPY --from=backend /backend/chat /chat
COPY --from=backend /backend/config.example.yaml /config.example.yaml
COPY --from=backend /backend/utils/templates /utils/templates
COPY --from=backend /backend/addition/article/template.docx /addition/article/template.docx
COPY --from=frontend /app/dist /app/dist
# Volumes
VOLUME ["/config", "/logs", "/storage"]
# Expose port
EXPOSE 8094
# Run application
CMD ["./chat"]