Skip to content

Commit

Permalink
feat: create docker container (#407)
Browse files Browse the repository at this point in the history
Co-authored-by: Nisheeth Barthwal <[email protected]>
Co-authored-by: Herman Obst Demaestri <[email protected]>
  • Loading branch information
3 people authored Jun 5, 2024
1 parent 0020999 commit 32b43da
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 16 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: docker

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
registry_image:
description: 'Registry image'
required: false

env:
REGISTRY_IMAGE: ${{ github.event.inputs.registry_image || 'ghcr.io/matter-labs/foundry-zksync' }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: './Dockerfile'
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 19 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM alpine:3.18 as build-environment
ARG TARGETARCH
WORKDIR /opt

RUN apk add clang lld curl build-base linux-headers git \
RUN apk add clang lld curl build-base linux-headers git pkgconfig openssl-dev perl \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh \
&& chmod +x ./rustup.sh \
&& ./rustup.sh -y
Expand All @@ -15,21 +15,24 @@ RUN [[ "$TARGETARCH" = "arm64" ]] && echo "export CFLAGS=-mno-outline-atomics" >
WORKDIR /opt/foundry
COPY . .

# This is necessary to compile librocksdb-sys
ENV RUSTFLAGS -Ctarget-feature=-crt-static

RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \
source $HOME/.profile && cargo build --release \
source $HOME/.profile && cargo build --profile local \
&& mkdir out \
&& mv target/release/forge out/forge \
&& mv target/release/cast out/cast \
&& mv target/release/anvil out/anvil \
&& mv target/release/chisel out/chisel \
&& mv target/local/forge out/forge \
&& mv target/local/cast out/cast \
&& mv target/local/anvil out/anvil \
&& mv target/local/chisel out/chisel \
&& strip out/forge \
&& strip out/cast \
&& strip out/chisel \
&& strip out/anvil;

FROM docker.io/frolvlad/alpine-glibc:alpine-3.16_glibc-2.34 as foundry-client
FROM alpine:3.18 as foundry-client

RUN apk add --no-cache linux-headers git
RUN apk add --no-cache linux-headers git clang openssl

COPY --from=build-environment /opt/foundry/out/forge /usr/local/bin/forge
COPY --from=build-environment /opt/foundry/out/cast /usr/local/bin/cast
Expand All @@ -42,11 +45,11 @@ ENTRYPOINT ["/bin/sh", "-c"]


LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Foundry" \
org.label-schema.description="Foundry" \
org.label-schema.url="https://getfoundry.sh" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/foundry-rs/foundry.git" \
org.label-schema.vendor="Foundry-rs" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
org.label-schema.name="Foundry" \
org.label-schema.description="Foundry" \
org.label-schema.url="https://getfoundry.sh" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/foundry-rs/foundry.git" \
org.label-schema.vendor="Foundry-rs" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"

0 comments on commit 32b43da

Please sign in to comment.