-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
37 lines (28 loc) · 863 Bytes
/
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
FROM rustlang/rust:nightly-slim as builder
# update and install required packages
RUN apt-get update
RUN apt-get --yes install pkg-config libssl-dev
# simple project to build dependencies
RUN cargo new mimic-bot
# copy dependencies file from project
WORKDIR /mimic-bot
COPY Cargo.toml Cargo.lock ./
# build dependencies
RUN cargo build --release
# replace simple project with actual sources
COPY src src
# force update file so cargo will rebuild it
RUN touch src/main.rs
# build project
RUN cargo build --release
# multistage container
# use debian slim image for runtime
FROM debian:buster-slim as runtime
RUN apt-get update \
&& apt-get install -y libssl-dev ca-certificates\
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR app
COPY --from=builder /mimic-bot/target/release/mimic-bot .
# run project
CMD ["./mimic-bot"]