Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Nov 12, 2023
2 parents 72c0add + 77fb579 commit abbe02b
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

*.log

# Circuits
packages/circuits/build
packages/circuits/inputs
packages/circuits/*.ptau
*.r1cs
*.sym
*.wasm
*.c

# Contracts
packages/contracts/broadcast
packages/contracts/cache
packages/contracts/out
packages/contracts/cache
packages/contracts/test/build_integration/*.json
packages/contracts/test/build_integration/*.zkey
packages/contracts/test/build_integration/*.wasm
packages/contracts/test/build_integration/*.txt

# Relayer
packages/relayer/sendgrid.env
target
packages/relayer/db/*
packages/relayer/*.db
packages/relayer/received_eml/*.eml
packages/relayer/received_eml/*.json
packages/relayer/proofs
sql_database.db
.sqlx

# Prover
packages/prover/build/*
packages/prover/params/*
packages/prover/__pycache__/*

# Subgraphs
packages/subgraph/build

# Subgraphs
packages/subgraph/build

# Subgraphs
packages/subgraph/build

# Mac
.DS_Store

# mdbook
book

# Vs code settings
.vscode
53 changes: 53 additions & 0 deletions Relayer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ------------------ 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 packages/relayer ./packages/relayer
COPY packages/utils ./packages/utils
COPY packages/scripts ./packages/scripts

# Create a lockfile for cargo chef
RUN cargo +nightly chef prepare --recipe-path recipe.json

# ------------------ Builder stage -------------------
FROM chef AS builder
WORKDIR /relayer

# Copy over our lock file
COPY --from=planner /app /relayer

# Build for any AWS machine. Same as cargo build but caches dependencies with the chef to make builds faster.
RUN cargo chef cook --release --recipe-path recipe.json

### Above this all dependencies should be cached as long as our lock file stays the same

# Build binary
RUN cargo build --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 /relayer/target/release/relayer
COPY --from=builder /relayer/Cargo.toml /relayer/Cargo.toml
COPY --from=builder /relayer/Cargo.lock /relayer/Cargo.lock

EXPOSE 4500

CMD ["relayer/target/release/relayer"]

# 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

0 comments on commit abbe02b

Please sign in to comment.