Skip to content

Commit

Permalink
feat(build): Dockerize trusted-sync (#299)
Browse files Browse the repository at this point in the history
* feat: dockerize trusted-sync

fix: tag image

chore: move dockerfiles to example dir

clean up dockerfile

fix: dockerfile

* feat: docker publish github action

* feat: docker publish github action
  • Loading branch information
refcell authored Jun 25, 2024
1 parent 28c8c7c commit 8d1c46e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release and version

on:
workflow_dispatch:

jobs:
publish:
name: Publish Trusted Sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.PERSONAL_DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.PERSONAL_DOCKERHUB_ACCESS_TOKEN_SECRET }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
file: examples/trusted-sync/Dockerfile
push: true
tags: refcell/trusted-sync:latest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Rust target
target/

# Environment Variables
.env
19 changes: 19 additions & 0 deletions examples/trusted-sync/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:latest as build

RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update && apt-get install -y musl-tools

COPY ./crates/ /kona/crates
COPY ./bin/ /kona/bin
COPY ./examples/ /kona/examples
COPY ./Cargo.toml /kona
COPY ./Cargo.lock /kona
COPY ./rustfmt.toml /kona
COPY ./README.md /kona
WORKDIR /kona

RUN cargo build --release --config net.git-fetch-with-cli=true -p trusted-sync
RUN cp /kona/target/release/trusted-sync /usr/local/bin/trusted-sync
RUN chmod +x ./examples/trusted-sync/run.sh

CMD ["./examples/trusted-sync/run.sh"]
10 changes: 10 additions & 0 deletions examples/trusted-sync/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/bash

/usr/local/bin/trusted-sync \
--l1-rpc-url $L1_RPC_URL \
--l2-rpc-url $L2_RPC_URL \
--beacon-url $BEACON_URL \
--start-l2-block $START_L2_BLOCK \
--metrics-server-addr $METRICS_SERVER_ADDR \
--metrics-server-port $METRICS_SERVER_PORT \
-vvv
17 changes: 17 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ alias l := lint
alias ln := lint-native
alias fmt := fmt-native-fix
alias b := build
alias d := docker-build-ts
alias r := docker-run-ts

# default recipe to display help information
default:
Expand Down Expand Up @@ -86,3 +88,18 @@ build-asterisc *args='':
-v `pwd`/:/workdir \
-w="/workdir" \
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build --workspace --all -Zbuild-std $@ --exclude kona-host --exclude trusted-sync

# Build the `trusted-sync` docker image
docker-build-ts *args='':
docker build -t trusted-sync -f examples/trusted-sync/Dockerfile . $@

# Run the `trusted-sync` docker container
docker-run-ts:
docker run -it \
-e L1_RPC_URL=$L1_RPC_URL \
-e L2_RPC_URL=$L2_RPC_URL \
-e BEACON_URL=$BEACON_URL \
-e START_L2_BLOCK=$START_L2_BLOCK \
-e METRICS_SERVER_ADDR=$METRICS_SERVER_ADDR \
-e METRICS_SERVER_PORT=$METRICS_SERVER_PORT \
trusted-sync

0 comments on commit 8d1c46e

Please sign in to comment.