Skip to content

Commit

Permalink
chore: update docker build, ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Vid201 committed Dec 30, 2023
1 parent a05d4ef commit be3a68a
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 43 deletions.
25 changes: 15 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Generated by Cargo, executables
target

# GitHub workflows/actions
.github

# Folder containing files for bundler spec tests
bundler-spec-tests

# Documentation
docs

# Dockerfile
Dockerfile
# Scripts
scripts

# Folder containing files for bundler spec tests
bundler-spec-tests
# Generated by Cargo, executables
target

# Third party dependencies
crates/contracts/thirdparty/account-abstraction/*
tests/thirdparty/bundler/*
# Other files
.gitignore
CODEOWNERS
CONTRIBUTING.md
docker-compose.yml
Dockerfile
rustfmt.toml
tomlfmt.toml
14 changes: 14 additions & 0 deletions .github/scripts/install_geth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -eo pipefail

# install geth

GETH_VERSION="1.12.0-e501b3b0"

wget -c "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-$GETH_VERSION.tar.gz"
tar -xf "geth-linux-amd64-$GETH_VERSION.tar.gz"
mv geth-linux-amd64-$GETH_VERSION/geth /usr/local/bin/
chmod a+x /usr/local/bin/geth

geth version
13 changes: 13 additions & 0 deletions .github/scripts/install_solc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -eo pipefail

# install solc

SOLC_VERSION="v0.8.20"

wget -c "https://github.com/ethereum/solidity/releases/download/$SOLC_VERSION/solc-static-linux"
mv solc-static-linux /usr/local/bin/solc
chmod a+x /usr/local/bin/solc

solc --version
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ jobs:
components: clippy

- name: Setup Rust toolchain (nightly)
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-12-27
components: rustfmt

- name: Install cargo tools
Expand Down Expand Up @@ -62,16 +63,12 @@ jobs:
- name: Setup third-party dependencies
run: |
make setup-thirdparty
- name: Install Geth and solc
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
wget -c https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.12.0-e501b3b0.tar.gz
tar -xf geth-linux-amd64-1.12.0-e501b3b0.tar.gz
mv geth-linux-amd64-1.12.0-e501b3b0/geth /usr/local/bin/
chmod a+x /usr/local/bin/geth
- name: Install geth
run: .github/scripts/install_geth.sh

- name: Install solc
run: .github/scripts/install_solc.sh

- name: Build
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/publish_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ jobs:
run: |
echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV}
- name: Fetch third-party dependencies
run: |
make fetch-thirdparty
- name: Setup Yarn cache - submodule "thirdparty/account-abstraction"
uses: actions/setup-node@v3
with:
node-version: '16.17'
cache: 'yarn'
cache-dependency-path: crates/contracts/thirdparty/account-abstraction

- name: Setup Yarn cache - submodule "thirdparty/bundler"
uses: actions/setup-node@v3
with:
node-version: '16.17'
cache: 'yarn'
cache-dependency-path: tests/thirdparty/bundler

- name: Setup third-party dependencies
run: |
make setup-thirdparty
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
Expand Down
59 changes: 37 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
# build
FROM ubuntu:18.04 AS builder
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app

RUN apt-get update && apt-get -y upgrade && apt-get install -y build-essential software-properties-common ca-certificates curl gnupg git clang pkg-config libclang-dev libssl-dev
RUN add-apt-repository ppa:ethereum/ethereum && apt-get update && apt-get install -y solc
LABEL org.opencontainers.image.source=https://github.com/silius-rs/silius
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0"

# build cargo-chef plan
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json

RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Set the build profile to be release
ARG BUILD_PROFILE=release
ENV BUILD_PROFILE $BUILD_PROFILE

RUN apt-get update && apt-get install -y nodejs yarn
# Install system dependencies
RUN apt-get update && apt-get -y upgrade && apt-get install -y pkg-config libclang-dev libssl-dev

WORKDIR /rust
# Install solc
RUN wget -c "https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux"
RUN mv solc-static-linux /usr/local/bin/solc
RUN chmod a+x /usr/local/bin/solc

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:$PATH"
# Builds dependencies
RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json

WORKDIR /silius
# Build application
COPY . .
RUN cargo build --profile $BUILD_PROFILE --locked

RUN make fetch-thirdparty
RUN make setup-thirdparty
RUN make build
# Copy application
RUN cp /app/target/$BUILD_PROFILE/silius /app/silius

# run
FROM frolvlad/alpine-glibc:alpine-3.17
# Use alpine as a runtime image
FROM frolvlad/alpine-glibc:alpine-3.17 AS runtime

# Create data folder
RUN mkdir -p /data/silius

# Install system dependencies
RUN apk add openssl1.1-compat

COPY --from=builder /silius/target/release/silius /usr/local/bin/silius
# Copy silus binary
COPY --from=builder /app/silius /usr/local/bin/silius

# Copy licenses
COPY LICENSE-* ./

# Expose ports
EXPOSE 3000 3001

ENTRYPOINT ["/usr/local/bin/silius"]

LABEL org.opencontainers.image.source=https://github.com/silius-rs/silius

0 comments on commit be3a68a

Please sign in to comment.