-
Notifications
You must be signed in to change notification settings - Fork 83
/
Dockerfile
74 lines (62 loc) · 2.65 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
74
FROM docker.io/flyway/flyway:10.7.1 as migrations
COPY database/ /flyway/
CMD ["migrate"]
FROM docker.io/rust:1-slim-bookworm as cargo-build
WORKDIR /src/
# Install dependencies
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update && \
apt-get install -y git libssl-dev pkg-config git
# Copy and Build Code
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/src/target \
CARGO_PROFILE_RELEASE_DEBUG=1 cargo build --release && \
cp target/release/alerter / && \
cp target/release/autopilot / && \
cp target/release/driver / && \
cp target/release/orderbook / && \
cp target/release/refunder / && \
cp target/release/solvers /
# Create an intermediate image to extract the binaries
FROM docker.io/debian:bookworm-slim as intermediate
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update && \
apt-get install -y ca-certificates tini gettext-base && \
apt-get clean
FROM intermediate as alerter
COPY --from=cargo-build /alerter /usr/local/bin/alerter
ENTRYPOINT [ "alerter" ]
FROM intermediate as autopilot
COPY --from=cargo-build /autopilot /usr/local/bin/autopilot
ENTRYPOINT [ "autopilot" ]
FROM intermediate as driver
COPY --from=cargo-build /driver /usr/local/bin/driver
ENTRYPOINT [ "driver" ]
FROM intermediate as orderbook
COPY --from=cargo-build /orderbook /usr/local/bin/orderbook
ENTRYPOINT [ "orderbook" ]
FROM intermediate as refunder
COPY --from=cargo-build /refunder /usr/local/bin/refunder
ENTRYPOINT [ "refunder" ]
FROM intermediate as solvers
COPY --from=cargo-build /solvers /usr/local/bin/solvers
ENTRYPOINT [ "solvers" ]
# Extract Binary
FROM intermediate
RUN apt-get update && \
apt-get install -y build-essential cmake git zlib1g-dev libelf-dev libdw-dev libboost-dev libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libunwind-dev libzstd-dev git
RUN git clone https://invent.kde.org/sdk/heaptrack.git /heaptrack && \
mkdir /heaptrack/build && cd /heaptrack/build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF .. && \
make -j$(nproc) && \
make install && \
cd / && rm -rf /heaptrack
COPY --from=cargo-build /alerter /usr/local/bin/alerter
COPY --from=cargo-build /autopilot /usr/local/bin/autopilot
COPY --from=cargo-build /driver /usr/local/bin/driver
COPY --from=cargo-build /orderbook /usr/local/bin/orderbook
COPY --from=cargo-build /refunder /usr/local/bin/refunder
COPY --from=cargo-build /solvers /usr/local/bin/solvers
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD echo "Specify binary..."
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/entrypoint.sh"]