forked from zkemail/relayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelayer.Dockerfile
More file actions
58 lines (43 loc) · 2.14 KB
/
relayer.Dockerfile
File metadata and controls
58 lines (43 loc) · 2.14 KB
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
# ------------------ Chef stage -------------------
# Use cargo chef to cache dependencies
FROM rustlang/rust:nightly AS chef
# Install cargo chef
RUN cargo install cargo-chef
# Work in app
WORKDIR /app
# ------------------ Planner stage -------------------
FROM chef as planner
# Copy files into container
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# Create a lockfile for cargo chef
RUN cargo +nightly chef prepare --recipe-path recipe.json
# ------------------ Builder stage -------------------
FROM chef AS builder
ARG RELAYER_BRANCH_NAME=v0
# Clone the relayer repository at the latest commit and set it as the working directory
RUN git clone --branch ${RELAYER_BRANCH_NAME} --single-branch https://github.com/zkemail/relayer /relayer
WORKDIR /relayer
# Copy over our lock file
COPY --from=planner /app/recipe.json /relayer/recipe.json
# Build for any AWS machine. Same as cargo build but caches dependencies with the chef to make builds faster.
RUN cargo chef cook --target x86_64-unknown-linux-gnu --release --recipe-path recipe.json
RUN cp /relayer/target/x86_64-unknown-linux-gnu/release/relayer /relayer/target/release/
### Above this all dependencies should be cached as long as our lock file stays the same
# Build binary
RUN cargo build --target x86_64-unknown-linux-gnu --release
# ------------------ Runtime stage -------------------
# Using super lightweight debian image to reduce overhead
FROM ubuntu:latest AS runtime
# Copy prebuild bin from the Builder stage
COPY --from=builder /relayer/target/release/relayer /usr/local/bin/relayer
COPY --from=builder /relayer/target/release/relayer /relayer/target/release/relayer
COPY --from=builder /relayer/abi /relayer/abi
COPY --from=builder /relayer/Cargo.toml /relayer/Cargo.toml
COPY --from=builder /relayer/Cargo.lock /relayer/Cargo.lock
COPY --from=builder /relayer/proofs /relayer/proofs
COPY --from=builder /relayer/received_eml /relayer/received_eml
COPY --from=builder /relayer/src /relayer/src
COPY --from=builder /relayer/.git /relayer/.git
# This cargo chef logic comes from https://github.com/LukeMathWalker/cargo-chef
# Inspired by Huff: https://github.com/huff-language/huff-rs/blob/main/Dockerfile