Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit bd756a8

Browse files
committed
initial container and build
1 parent b38b2f7 commit bd756a8

File tree

7 files changed

+323
-0
lines changed

7 files changed

+323
-0
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build.sh
2+
README.md
3+
LICENSE
4+
CHANGELOG.md

.github/workflows/ci-image.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build Image CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- "*"
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v3
19+
-
20+
name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
-
23+
name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
-
27+
name: Login to GitHub Container Registry
28+
uses: docker/login-action@v2
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
-
34+
name: Build
35+
uses: docker/build-push-action@v3
36+
with:
37+
context: .
38+
platforms: linux/amd64
39+
push: false
40+
build-args: |
41+
VERSION=latest

.github/workflows/ghcr-image.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Image CI
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
concurrency:
9+
group: "docker-image"
10+
cancel-in-progress: true
11+
12+
env:
13+
DOCKER_BUILDKIT: "1"
14+
15+
jobs:
16+
docker:
17+
runs-on: ubuntu-latest
18+
steps:
19+
-
20+
name: Checkout
21+
uses: actions/checkout@v3
22+
-
23+
name: Set up QEMU
24+
uses: docker/setup-qemu-action@v2
25+
-
26+
name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
-
30+
name: Login to GitHub Container Registry
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
-
37+
name: Generate repository name
38+
run: |
39+
echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV}
40+
echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-7 )" >> ${GITHUB_ENV}
41+
-
42+
name: Build and Push
43+
uses: docker/build-push-action@v3
44+
with:
45+
context: .
46+
platforms: linux/amd64
47+
push: true
48+
build-args: |
49+
VERSION=${{ github.ref_name }}
50+
tags: |
51+
ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }}
52+
ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }}
53+
ghcr.io/${{ env.REPOSITORY_PATH }}:latest
54+
-
55+
name: GitHub Release
56+
uses: actions/create-release@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
draft: false
61+
prerelease: false
62+
tag_name: ${{ github.ref_name }}
63+
release_name: v${{ github.ref_name }}
64+
body_path: CHANGELOG.md

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.0.0 (2023-09-08)
2+
3+
* fork from collectivexyz/foundry

Dockerfile

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
FROM debian:stable-slim as go-builder
2+
# defined from build kit
3+
# DOCKER_BUILDKIT=1 docker build . -t ...
4+
ARG TARGETARCH
5+
6+
RUN export DEBIAN_FRONTEND=noninteractive && \
7+
apt update && \
8+
apt install -y -q --no-install-recommends \
9+
git curl gnupg2 build-essential coreutils \
10+
openssl libssl-dev pkg-config \
11+
ca-certificates apt-transport-https \
12+
python3 && \
13+
apt clean && \
14+
rm -rf /var/lib/apt/lists/*
15+
16+
## Go Lang
17+
ARG GO_VERSION=1.21.1
18+
ADD https://go.dev/dl/go${GO_VERSION}.linux-$TARGETARCH.tar.gz /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz
19+
RUN echo 'SHA256 of this go source package...'
20+
RUN cat /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz | sha256sum
21+
RUN tar -C /usr/local -xzf /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz
22+
ENV PATH=$PATH:/usr/local/go/bin
23+
RUN go version
24+
25+
## Go Ethereum
26+
WORKDIR /go-ethereum
27+
ARG ETH_VERSION=1.12.2
28+
ADD https://github.com/ethereum/go-ethereum/archive/refs/tags/v${ETH_VERSION}.tar.gz /go-ethereum/go-ethereum-${ETH_VERSION}.tar.gz
29+
RUN echo 'SHA256 of this go-ethereum package...'
30+
RUN cat /go-ethereum/go-ethereum-${ETH_VERSION}.tar.gz | sha256sum
31+
RUN tar -zxf go-ethereum-${ETH_VERSION}.tar.gz -C /go-ethereum
32+
WORKDIR /go-ethereum/go-ethereum-${ETH_VERSION}
33+
RUN go mod download
34+
RUN go run build/ci.go install
35+
36+
FROM debian:stable-slim as foundry-builder
37+
# defined from build kit
38+
# DOCKER_BUILDKIT=1 docker build . -t ...
39+
ARG TARGETARCH
40+
ARG MAXIMUM_THREADS=2
41+
42+
RUN export DEBIAN_FRONTEND=noninteractive && \
43+
apt update && \
44+
apt install -y -q --no-install-recommends \
45+
git curl gnupg2 build-essential \
46+
linux-headers-${TARGETARCH} libc6-dev \
47+
openssl libssl-dev pkg-config \
48+
ca-certificates apt-transport-https \
49+
python3 && \
50+
apt clean && \
51+
rm -rf /var/lib/apt/lists/*
52+
53+
RUN useradd --create-home -s /bin/bash xmtp
54+
RUN usermod -a -G sudo xmtp
55+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
56+
57+
58+
WORKDIR /rustup
59+
## Rust
60+
ADD https://sh.rustup.rs /rustup/rustup.sh
61+
RUN chmod 755 /rustup/rustup.sh
62+
63+
ENV USER=xmtp
64+
USER xmtp
65+
RUN /rustup/rustup.sh -y --default-toolchain stable --profile minimal
66+
67+
## Foundry
68+
WORKDIR /build
69+
70+
# latest https://github.com/foundry-rs/foundry
71+
ENV PATH=$PATH:~xmtp/.cargo/bin
72+
RUN git clone https://github.com/foundry-rs/foundry
73+
74+
WORKDIR /build/foundry
75+
RUN git pull && LATEST_TAG=$(git describe --tags --abbrev=0) || LATEST_TAG=master && \
76+
echo "building tag ${LATEST_TAG}" && \
77+
git -c advice.detachedHead=false checkout nightly && \
78+
. $HOME/.cargo/env && \
79+
THREAD_NUMBER=$(cat /proc/cpuinfo | grep -c ^processor) && \
80+
MAX_THREADS=$(( THREAD_NUMBER > ${MAXIMUM_THREADS} ? ${MAXIMUM_THREADS} : THREAD_NUMBER )) && \
81+
echo "building with ${MAX_THREADS} threads" && \
82+
cargo build --jobs ${MAX_THREADS} --release && \
83+
objdump -j .comment -s target/release/forge && \
84+
strip target/release/forge && \
85+
strip target/release/cast && \
86+
strip target/release/anvil && \
87+
strip target/release/chisel
88+
89+
RUN git rev-parse HEAD > /build/foundry_commit_sha256
90+
91+
FROM debian:stable-slim as node18-slim
92+
93+
RUN export DEBIAN_FRONTEND=noninteractive && \
94+
apt update && \
95+
apt install -y -q --no-install-recommends \
96+
build-essential git gnupg2 curl \
97+
ca-certificates apt-transport-https && \
98+
apt clean && \
99+
rm -rf /var/lib/apt/lists/*
100+
101+
RUN mkdir -p /usr/local/nvm
102+
ENV NVM_DIR=/usr/local/nvm
103+
104+
ENV NODE_VERSION=v18.17.1
105+
106+
ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh
107+
RUN bash /usr/local/etc/nvm/install.sh && \
108+
bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default"
109+
110+
ENV NVM_NODE_PATH ${NVM_DIR}/versions/node/${NODE_VERSION}
111+
ENV NODE_PATH ${NVM_NODE_PATH}/lib/node_modules
112+
ENV PATH ${NVM_NODE_PATH}/bin:$PATH
113+
114+
RUN npm install npm -g
115+
RUN npm install yarn -g
116+
117+
FROM node18-slim
118+
ARG TARGETARCH
119+
120+
RUN export DEBIAN_FRONTEND=noninteractive && \
121+
apt update && \
122+
apt install -y -q --no-install-recommends \
123+
libz3-dev z3 build-essential \
124+
ca-certificates apt-transport-https \
125+
sudo ripgrep procps \
126+
python3 python3-pip python3-dev && \
127+
apt clean && \
128+
rm -rf /var/lib/apt/lists/*
129+
130+
RUN echo "building platform $(uname -m)"
131+
132+
RUN useradd --create-home -s /bin/bash xmtp
133+
RUN usermod -a -G sudo xmtp
134+
RUN echo '%xmtp ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
135+
136+
# SOLC
137+
COPY --from=ghcr.io/jac18281828/solc:latest /usr/local/bin/solc /usr/local/bin
138+
COPY --from=ghcr.io/jac18281828/solc:latest /usr/local/bin/yul-phaser /usr/local/bin
139+
RUN solc --version
140+
141+
## Rust
142+
COPY --chown=xmtp:xmtp --from=foundry-builder /home/xmtp/.cargo /home/xmtp/.cargo
143+
144+
# GO LANG
145+
COPY --from=go-builder /usr/local/go /usr/local/go
146+
147+
## GO Ethereum Binaries
148+
ARG ETH_VERSION=1.12.2
149+
COPY --from=go-builder /go-ethereum/go-ethereum-${ETH_VERSION}/build/bin /usr/local/bin
150+
151+
# Foundry
152+
COPY --from=foundry-builder /build/foundry_commit_sha256 /usr/local/etc/foundry_commit_sha256
153+
COPY --from=foundry-builder /build/foundry/target/release/forge /usr/local/bin/forge
154+
COPY --from=foundry-builder /build/foundry/target/release/cast /usr/local/bin/cast
155+
COPY --from=foundry-builder /build/foundry/target/release/anvil /usr/local/bin/anvil
156+
COPY --from=foundry-builder /build/foundry/target/release/chisel /usr/local/bin/chisel
157+
158+
LABEL org.label-schema.build-date=$BUILD_DATE \
159+
org.label-schema.name="foundry" \
160+
org.label-schema.description="Foundry RS Development Container" \
161+
org.label-schema.url="https://github.com/xmtp/foundry" \
162+
org.label-schema.vcs-ref=$VCS_REF \
163+
org.label-schema.vcs-url="git@github.com:xmtp/foundry.git" \
164+
org.label-schema.vendor="XMTP Labs" \
165+
org.label-schema.version=$VERSION \
166+
org.label-schema.schema-version="1.0" \
167+
org.opencontainers.image.description="Foundry and Ethereum Development Container for Visual Studio Code"

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, XMTP
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# install a local version of this image - useful on arm64 where there are currently no public
4+
# distributions
5+
6+
VERSION=$(git rev-parse HEAD | cut -c 1-8)
7+
8+
PROJECT=xmtp/$(basename ${PWD})
9+
10+
# cross platform okay:
11+
# --platform=amd64 or arm64
12+
DOCKER_BUILDKIT=1 docker build --progress plain . -t ${PROJECT}:${VERSION} \
13+
--build-arg VERSION=${VERSION} --build-arg MAXIMUM_THREADS=2 && \
14+
docker tag ${PROJECT}:${VERSION} ${PROJECT}:latest && \
15+
docker tag ${PROJECT}:${VERSION} ghcr.io/${PROJECT}:latest

0 commit comments

Comments
 (0)