forked from ff522/dm-ticket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (29 loc) · 1.32 KB
/
Dockerfile
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
# 编译
FROM --platform=$TARGETPLATFORM rust:1.71.0-bullseye as builder
WORKDIR /usr/src
RUN USER=root cargo new dm-ticket
RUN apt update \
&& apt install -y upx git
COPY Cargo.toml Cargo.lock /usr/src/dm-ticket/
COPY .cargo /usr/src/dm-ticket/.cargo
WORKDIR /usr/src/dm-ticket
RUN mkdir src/bin && cat src/main.rs > src/bin/client.rs && cat src/main.rs > src/bin/server.rs
RUN cargo build --release --verbose
COPY src /usr/src/dm-ticket/src/
RUN RUST_BACKTRACE=1 cargo build --release --verbose --bin dm-server && upx /usr/src/dm-ticket/target/release/dm-server
RUN RUST_BACKTRACE=1 cargo build --release --verbose --bin dm-client && upx /usr/src/dm-ticket/target/release/dm-client
FROM --platform=$TARGETPLATFORM debian:bullseye as runtime
ENV TZ=Asia/Shanghai
COPY scripts/start.sh /usr/bin/start
RUN apt update \
&& apt install -y tzdata supervisor redis chromium-driver procps \
&& echo "${TZ}" > /etc/timezone \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& apt clean \
&& rm -rf /var/cache/apt/* \
&& chmod 755 /usr/bin/start
WORKDIR /src/
COPY --from=builder /usr/src/dm-ticket/target/release/dm-server /usr/bin/dm-server
COPY --from=builder /usr/src/dm-ticket/target/release/dm-client /usr/bin/dm-client
COPY supervisord.conf /etc/supervisord.conf
CMD ["/usr/bin/start"]