-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (39 loc) · 1.46 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
# Credit goes to https://www.lpalmieri.com/posts/2020-11-01-zero-to-production-5-how-to-deploy-a-rust-application/#3-8-optimising-our-docker-image
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app
# Check for modified dependencies
FROM chef AS planner
WORKDIR /app
COPY . .
# Compute a lock-like file for our project
RUN cargo chef prepare --recipe-path recipe.json
# Cache dependencies
FROM chef AS builder
WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
# Build our application, leveraging the cached deps!
RUN cargo build --release
# Veloren Server Bot Runtime Environment.
# Requires git, git-lfs, rustup and whatever Veloren gameserver depends on.
FROM debian:bookworm-slim AS runtime
RUN apt-get update
RUN export DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y --no-install-recommends --assume-yes \
ca-certificates \
build-essential \
curl \
git \
git-lfs
RUN git lfs install
RUN git config --global advice.detachedHead false
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly --profile=minimal; \
. /root/.cargo/env; \
rustup default nightly;
COPY --from=builder /app/target/release/veloren_server_bot .
ENV RUST_BACKTRACE=1
ENV PATH="/root/.cargo/bin:${PATH}"
CMD [ "./veloren_server_bot" ]