This repository was archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (38 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
44 lines (38 loc) · 1.33 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
FROM registry.cn-hangzhou.aliyuncs.com/raynor/rust-npm:1.0.0 as builder
WORKDIR /app
COPY . .
ENV LLVM_SYS_130_PREFIX /usr
RUN apt install libz-dev -y
RUN cargo build --package cc99 --bin cc99 --release
RUN cd web/web-frontend && npm install && npm run build && mv build /srv && mv /srv/build /srv/cc99
FROM golang:1.18-bullseye as prod
EXPOSE 5001
RUN mkdir /backend && mkdir /app
WORKDIR /backend
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update
# cache deps before building and copying source so that we don't need to re-download as muchw
# and so that source changes don't invalidate our downloaded layer
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
COPY ./web/web-backend/go.mod go.mod
COPY ./web/web-backend/go.sum go.sum
RUN go mod download
RUN go mod tidy
# src code
COPY ./web/web-backend .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o cc99-backend .
RUN chmod +x cc99-backend
#copy frontend and cc99 and header file
WORKDIR /app
COPY --from=builder /srv/cc99 /srv/cc99
COPY --from=builder /app/target/release/cc99 .
COPY --from=builder /app/include ./include
WORKDIR /backend
RUN mv /app/cc99 /backend
RUN mv /app/include /backend
RUN apt install -y clang-11
RUN ln -s /usr/bin/clang-11 /usr/bin/clang
ENV PATH "$PATH:/backend"
ENV TZ=Asia/Shanghai
ENTRYPOINT ["/backend/cc99-backend"]