Skip to content

Commit

Permalink
working images
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Jun 2, 2024
1 parent 1ae0cfd commit 88a2512
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 63 deletions.
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
13 changes: 8 additions & 5 deletions delegator.dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Use a Debian-based Linux distribution as the base image
FROM runtime AS base
# Use the base runtime image
FROM runtime

# Set the working directory
WORKDIR /sharp-p2p
# 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"]
CMD ["bash", "-ci", "cargo run --release --bin sharp-p2p-delegator"]
9 changes: 3 additions & 6 deletions devcontainer.dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Use a Debian-based Linux distribution as the base image
FROM runtime AS base

# Set the working directory
WORKDIR /workshop
# Use the base runtime image
FROM runtime

# Set the default command to run when the container starts
CMD ["bash"]
CMD ["bash"]
38 changes: 33 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +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

devcontainer:
build:
dockerfile: devcontainer.dockerfile
depends_on:
- runtime
- 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'
13 changes: 8 additions & 5 deletions executor.dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Use a Debian-based Linux distribution as the base image
FROM runtime AS base
# Use the base runtime image
FROM runtime

# Set the working directory
WORKDIR /sharp-p2p
# 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"]
CMD ["bash", "-ci", "cargo run --release --bin sharp-p2p-executor"]
76 changes: 36 additions & 40 deletions runtime.dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
# Use a Debian-based Linux distribution as the base image
# 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 \
RUN apt-get update && apt-get install -y \
curl \
gcc \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Rust using Rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Add Rust binaries to the PATH
ENV PATH="/root/.cargo/bin:${PATH}"

# Display installed Rust version
RUN rustc --version && cargo --version

# Install cargo-make
RUN cargo install --force cargo-make

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

# Install dependencies for Pyenv and Python
RUN apt-get update && \
apt-get install -y \
make \
build-essential \
libssl-dev \
Expand All @@ -35,7 +20,6 @@ RUN apt-get update && \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
Expand All @@ -49,29 +33,41 @@ RUN apt-get update && \
libdw1 \
&& rm -rf /var/lib/apt/lists/*

# Install Pyenv
RUN curl https://pyenv.run | bash
# 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

RUN echo 'export PATH="/root/.pyenv/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

SHELL ["/bin/bash", "-c"]

# Set Pyenv environment variables
ENV PATH="/root/.pyenv/bin:$PATH"

# Install Python 3.9.0 using Pyenv
RUN eval "$(pyenv init -)" && \
eval "$(pyenv virtualenv-init -)" && \
pyenv install 3.12.0 && \
pyenv global 3.12.0 && \
RUN pyenv install 3.9.0 && \
pyenv global 3.9.0 && \
pyenv --version && \
python -V && \
pip install --upgrade pip

# Install docker
RUN curl -fsSL https://get.docker.com | bash
# 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 . .

RUN mkdir -p /root/.local/bin
RUN echo 'export PATH="/root/.local/bin:$PATH"' >> /root/.bashrc
# Install requirements
RUN cargo make python-requirements-install && \
cargo make python-bootloader-install

0 comments on commit 88a2512

Please sign in to comment.