Skip to content

Commit

Permalink
feat: simple anvil runner
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlcibiades committed Nov 13, 2023
1 parent ff567f9 commit 96877e8
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @valorem-labs-inc/devops
29 changes: 29 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Deploy container to latest tag'

on:
push:
branches:
- main

jobs:
build-latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the container to GitHub Container Registry using the latest tag
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/arm64
tags: ghcr.io/valorem-labs-inc/anvil-runner:latest
push: true
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Validate Repo'

on: pull_request

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- name: Install pylint
run: pip install pylint
- name: Run pre-commit
uses: pre-commit/action@v2.0.0
32 changes: 32 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Deploy container to named tag'

on:
push:
tags:
- '*.*.*'

jobs:
build-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract tag name
id: extract_tag
run: echo "::set-output name=tag::${GITHUB_REF/refs\/tags\//}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the container to GitHub Container Registry using the repo tag
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/arm64
tags: ghcr.io/valorem-labs-inc/anvil-runner:${{ steps.extract_tag.outputs.tag }}
push: true
251 changes: 251 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
################
## Sublime Text
################

*.sublime-workspace

#################
## JetBrain IDEs
#################

## Directory-based project format
.idea/
# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml

## File-based project format
*.ipr
*.iml
*.iws

## Additional for IntelliJ
out/

# generated by mpeltonen/sbt-idea plugin
.idea_modules/

# generated by JIRA plugin
atlassian-ide-plugin.xml

# generated by Crashlytics plugin (for Android Studio and Intellij)
com_crashlytics_export_strings.xml

#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

###############
## Common Keys
###############

# Ansible vault key
vault.key

####################
## Windows detritus
####################

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

################
## Mac detritus
################

.DS_Store

#################
## Chef detritus
#################

# Berkshelf
.vagrant
/cookbooks
Berksfile.lock

# Bundler
Gemfile.lock
bin/*
.bundle/*

.kitchen/
.kitchen.local.yml

####################
## Ansible detritus
####################

#Retry files
*.retry

######################
## Terraform detritus
######################

# Local Terraform states
.terraform/


####################
## Generic detritus
####################

*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
pkg/

####################
## Pytohn detritus
####################

# Virtual environments
pyenv/
venv/
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.72.1 as chef
WORKDIR /opt

FROM chef as planner

# Get the foundry project
RUN git clone https://github.com/foundry-rs/foundry.git

WORKDIR /opt/foundry

# Compute a lock-like file for our project
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as builder

WORKDIR /opt/foundry

# Get the foundry project
COPY --from=planner /opt/foundry /opt/foundry
# Get the lock-like file
COPY --from=planner /opt/foundry/recipe.json recipe.json


# Build our project dependencies, not our application!
RUN cargo chef cook --release --recipe-path recipe.json
# Up to this point, if our dependency tree stays the same,
# all layers should be cached.
RUN cargo build --release

FROM debian:bookworm-slim AS foundry-environment

# Foundry tools
COPY --from=builder /opt/foundry/target/release/forge /usr/local/bin/forge
COPY --from=builder /opt/foundry/target/release/cast /usr/local/bin/cast
COPY --from=builder /opt/foundry/target/release/anvil /usr/local/bin/anvil
COPY --from=builder /opt/foundry/target/release/chisel /usr/local/bin/chisel

RUN useradd -u 1001 -m foundry

USER foundry

# TODO(User and group here)

ENTRYPOINT ["/bin/sh", "-c"]

FROM foundry-environment as anvil

# At this point we have the entire toolchain for foundry

# Start a clean anvil chain
EXPOSE 8545

ENTRYPOINT ["/usr/local/bin/anvil"]
Loading

0 comments on commit 96877e8

Please sign in to comment.