forked from LightDotSo/LightDotSo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
106 lines (88 loc) · 3.43 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# From: https://raw.githubusercontent.com/ultrasoundmoney/eth-analysis-rs/main/Dockerfile
# Thank you to the ultrasoundmoney team for the Dockerfile!
# Awesome work for the ethereum community!
# Specify the base image we're building from.
FROM rust:1.75 AS builder
# Specify turborepo related args
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG SCCACHE_ENDPOINT
ARG TURBO_API
ARG TURBO_REMOTE_CACHE_SIGNATURE_KEY
ARG TURBO_TEAM
ARG TURBO_TOKEN
# Specify the working directory.
WORKDIR /app
# Install nodejs 18.
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
# Install planning dependencies.
RUN apt install -y python3-pip nodejs
# Install building dependencies.
RUN apt-get update && \
apt-get -y install build-essential git clang curl libsasl2-dev libssl-dev llvm libudev-dev make protobuf-compiler && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Build the prisma dep.
# Install sccache dependencies.
ENV SCCACHE_VERSION=0.5.4
RUN curl -L https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -o sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz \
&& tar -xzf sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz \
&& mv sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache /usr/local/bin/ \
&& chmod +x /usr/local/bin/sccache
# Install foundry.
SHELL ["/bin/bash", "-c"]
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="/root/.foundry/bin:${PATH}"
RUN foundryup
# Copy over dir.
COPY . .
# Specify the build related environment variables.
ENV \
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
CARGO_INCREMENTAL=0 \
DOCKER=true \
RUST_LOG="sccache=trace" \
RUST_BACKTRACE=1 \
RUSTFLAGS="-C overflow-checks=yes" \
# RUSTFLAGS="-D warnings" \
RUSTC_WRAPPER="/usr/local/bin/sccache" \
SCCACHE_BUCKET="sccache" \
SCCACHE_ENDPOINT=$SCCACHE_ENDPOINT \
SCCACHE_IDLE_TIMEOUT="0" \
SCCACHE_REGION=auto \
SCCACHE_LOG="info,sccache::cache=debug" \
TURBO_TEAM=$TURBO_TEAM \
TURBO_TOKEN=$TURBO_TOKEN
# Run the build.
RUN make install && \
sccache --start-server && \
turbo run prisma && \
cargo build --release && \
sccache --show-stats
# Slim down the image for runtime.
FROM debian:bookworm-slim AS runtime
# Switch to the runtime directory.
WORKDIR /app
# Specify the runtime related environment variables.
ENV \
RUST_BACKTRACE=1 \
RUST_FLAGS="-C overflow-checks=yes"
# sqlx depends on native TLS, which is missing in buster-slim.
RUN apt update && apt install -y libsasl2-dev libssl3 ca-certificates
# Copy over the binaries.
COPY --from=builder /app/target/release/lightdotso-bin /usr/local/bin
COPY --from=builder /app/target/release/api /usr/local/bin
COPY --from=builder /app/target/release/bundler /usr/local/bin
COPY --from=builder /app/target/release/cli /usr/local/bin
COPY --from=builder /app/target/release/consumer /usr/local/bin
COPY --from=builder /app/target/release/gas /usr/local/bin
COPY --from=builder /app/target/release/indexer /usr/local/bin
COPY --from=builder /app/target/release/paymaster /usr/local/bin
COPY --from=builder /app/target/release/polling /usr/local/bin
COPY --from=builder /app/target/release/prometheus /usr/local/bin
COPY --from=builder /app/target/release/rpc /usr/local/bin
# Run the binary.
EXPOSE 3002
ENTRYPOINT ["/usr/local/bin/lightdotso-bin"]