Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker runtimes #19

Merged
merged 4 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "devcontainer.dockerfile"
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
Expand Down
83 changes: 0 additions & 83 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ args = ["fmt"]
[tasks.cairo-format]
workspace = false
script = [
"find cairo -name '*.cairo' ! -path 'cairo/build/*' -exec sh -c 'cairo-format -i \"$1\"; echo \"Formatted: $1\"' _ {} \\;"
'for file in $(find cairo -name "*.cairo" ! -path "cairo/build/*"); do cairo-format -i $file && echo \"Formatted: $file\"; done'
]

[tasks.full-format]
Expand Down
4 changes: 2 additions & 2 deletions crates/peer/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl SwarmRunner {
swarm.behaviour_mut().gossipsub.subscribe(topic)?;
}

swarm.listen_on("/ip4/0.0.0.0/udp/0/quic-v1".parse()?)?;
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
swarm.listen_on("/ip4/0.0.0.0/udp/5678/quic-v1".parse()?)?;
swarm.listen_on("/ip4/0.0.0.0/tcp/5679".parse()?)?;

Ok(SwarmRunner { swarm, cancellation_token: CancellationToken::new() })
}
Expand Down
11 changes: 11 additions & 0 deletions delegator.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Use the base runtime image
FROM runtime

# Build
RUN cargo build --release --bin sharp-p2p-delegator

# Expose necessary ports
EXPOSE 5678/udp 5679/tcp

# Set the default command to run when the container starts
CMD ["bash", "-ci", "cargo run --release --bin sharp-p2p-delegator"]
5 changes: 5 additions & 0 deletions devcontainer.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Use the base runtime image
FROM runtime

# Set the default command to run when the container starts
CMD ["bash"]
51 changes: 51 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
services:
stone-prover:
build:
context: stone-prover
dockerfile: Dockerfile
image: stone-prover
deploy:
resources:
limits:
cpus: '4'
memory: '10G'

runtime:
build:
dockerfile: runtime.dockerfile
image: runtime
depends_on:
- stone-prover
deploy:
resources:
limits:
cpus: '2'
memory: '10G'

delegator:
build:
dockerfile: delegator.dockerfile
depends_on:
- runtime
ports:
- "5678:5678/udp"
- "5679:5679/tcp"
deploy:
resources:
limits:
cpus: '8'
memory: '10G'

executor:
build:
dockerfile: executor.dockerfile
depends_on:
- runtime
ports:
- "5698:5678/udp"
- "5699:5679/tcp"
deploy:
resources:
limits:
cpus: '8'
memory: '10G'
11 changes: 11 additions & 0 deletions executor.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Use the base runtime image
FROM runtime

# Build
RUN cargo build --release --bin sharp-p2p-executor

# Expose necessary ports
EXPOSE 5678/udp 5679/tcp

# Set the default command to run when the container starts
CMD ["bash", "-ci", "cargo run --release --bin sharp-p2p-executor"]
73 changes: 73 additions & 0 deletions runtime.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Stage 1: Use the stone-prover image to copy the executable
FROM stone-prover AS stone-prover

# Stage 2: Use a Debian-based Linux distribution as the base image
FROM --platform=linux/amd64 debian:stable-slim

# Set the default shell to bash
SHELL ["/bin/bash", "-ci"]

# Install necessary packages for Rust and Python development
RUN apt-get update && apt-get install -y \
curl \
gcc \
libc6-dev \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
git \
libgmp-dev \
libdw1 \
&& rm -rf /var/lib/apt/lists/*

# Install Rust using Rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
echo 'export PATH="/root/.cargo/bin:$PATH"' >> /root/.bashrc

# Install cargo-make and cargo-nextest
RUN cargo install --force cargo-make && \
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

# Install Pyenv
RUN curl https://pyenv.run | bash && \
echo 'export PATH="/root/.pyenv/bin:$PATH"' >> /root/.bashrc && \
echo 'eval "$(pyenv init -)"' >> /root/.bashrc && \
echo 'eval "$(pyenv virtualenv-init -)"' >> /root/.bashrc

# Install Python 3.9.0 using Pyenv
RUN pyenv install 3.9.0 && \
pyenv global 3.9.0 && \
pyenv --version && \
python -V && \
pip install --upgrade pip

# Add Python and cargo executables to PATH
RUN mkdir -p /root/.local/bin && \
echo 'export PATH="/root/.local/bin:$PATH"' >> /root/.bashrc

# Copy the executable from stone-prover image
COPY --from=stone-prover /bin/cpu_air_prover /root/.local/bin/
COPY --from=stone-prover /bin/cpu_air_verifier /root/.local/bin/

# Set the working directory
WORKDIR /sharp-p2p

# Copy the current directory content into the container
COPY . .

# Install requirements
RUN cargo make python-requirements-install && \
cargo make python-bootloader-install
Loading