forked from FuelLabs/fuel-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
73 lines (58 loc) · 2.05 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Stage 1: Build
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
FROM --platform=$BUILDPLATFORM rust:1.71.0 AS chef
ARG TARGETPLATFORM
RUN cargo install cargo-chef
WORKDIR /build/
COPY --from=xx / /
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends \
lld \
clang \
libclang-dev \
protobuf-compiler \
&& xx-apt-get update \
&& xx-apt-get install -y libc6-dev g++ binutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
FROM chef as planner
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY --from=planner /build/recipe.json recipe.json
# Build our project dependecies, not our application!
RUN xx-cargo chef cook --release --no-default-features --features "production" -p fuel-core-bin --recipe-path recipe.json
# Up to this point, if our dependency tree stays the same,
# all layers should be cached.
COPY . .
RUN xx-cargo build --release --no-default-features --features "production" -p fuel-core-bin \
&& xx-verify ./target/$(xx-cargo --print-target-triple)/release/fuel-core \
&& mv ./target/$(xx-cargo --print-target-triple)/release/fuel-core ./target/release/fuel-core \
&& mv ./target/$(xx-cargo --print-target-triple)/release/fuel-core.d ./target/release/fuel-core.d
# Stage 2: Run
FROM ubuntu:22.04 as run
ARG IP=0.0.0.0
ARG PORT=4000
ARG P2P_PORT=30333
ARG DB_PATH=./mnt/db/
ENV IP="${IP}"
ENV PORT="${PORT}"
ENV DB_PATH="${DB_PATH}"
WORKDIR /root/
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/target/release/fuel-core .
COPY --from=builder /build/target/release/fuel-core.d .
EXPOSE ${PORT}
EXPOSE ${P2P_PORT}
# https://stackoverflow.com/a/44671685
# https://stackoverflow.com/a/40454758
# hadolint ignore=DL3025
CMD exec ./fuel-core run --ip ${IP} --port ${PORT} --db-path ${DB_PATH}