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

feat : added docker build and updated docker compose #141

Merged
merged 8 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Ignore target directory
target/

# Ignore version control files
.git
.gitignore

# Ignore editor and IDE files
.vscode/
.idea/
*.swp
*.swo

# Ignore log files
*.log

# TODO : uncomment this
# Ignore any local environment files
# .env
# *.env

# Ignore any test or documentation directories
tests/
docs/

# Ignore Rust-specific files
Cargo.lock

# Ignore any temporary files
*.tmp
*.bak

# Ignore OS-specific files
.DS_Store
Thumbs.db
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Added

- added dockerfile
- `SnosJob` implementation and e2e
- Telemetry tracing and metrics.
- e2e flow test
Expand Down
74 changes: 74 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM rust:1.81 AS builder

# Set the working directory in the container
WORKDIR /usr/src/madara-orchestrator

# Install system dependencies
RUN apt update && apt install -y \
libgmp3-dev \
software-properties-common \
wget \
bash

# Install Python 3.9
RUN wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz \
&& tar xzf Python-3.9.16.tgz \
&& cd Python-3.9.16 \
&& ./configure --enable-optimizations \
&& make altinstall \
&& cd .. \
&& rm -rf Python-3.9.16 Python-3.9.16.tgz

# Install pip
RUN wget https://bootstrap.pypa.io/get-pip.py \
&& python3.9 get-pip.py \
&& rm get-pip.py

# Set up Python environment and install Cairo
RUN python3.9 -m venv /usr/local/cairo_venv
RUN pip3.9 install ecdsa fastecdsa sympy
RUN pip3.9 install cairo-lang

RUN python3.9 --version && pip3.9 --version

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


# Check rust version (this also installs version from rust-toolchain file)
RUN rustup show

# #############################################################
# TODO : remove this step after snos build is sorted
# Build cairo lang
RUN cargo fetch
RUN bash -c "cd /usr/local/cargo/git/checkouts \
&& cd snos-* \
&& cd * \
&& source /usr/local/cairo_venv/bin/activate \
&& ./scripts/setup-tests.sh"
# #############################################################

WORKDIR /usr/src/madara-orchestrator

# Build the project
RUN cargo build --release


FROM debian:bookworm

# Install runtime dependencies
RUN apt-get -y update && \
apt-get install -y openssl ca-certificates &&\
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /usr/local/bin

# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/madara-orchestrator/target/release/orchestrator .

# Set the entrypoint
ENTRYPOINT ["./orchestrator"]
74 changes: 66 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,74 @@
services:
app:
build: .
ports:
- "${PORT}:3000"
environment:
- HOST=${HOST:-127.0.0.1}
- PORT=${PORT:-3000}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION:-us-east-1}
- AWS_ENDPOINT_URL=${AWS_ENDPOINT_URL}
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-localhost}
- DATA_STORAGE=${DATA_STORAGE:-s3}
- AWS_S3_BUCKET_NAME=${AWS_S3_BUCKET_NAME}
- QUEUE_PROVIDER=${QUEUE_PROVIDER:-sqs}
- SQS_JOB_PROCESSING_QUEUE_URL=${SQS_JOB_PROCESSING_QUEUE_URL}
- SQS_JOB_VERIFICATION_QUEUE_URL=${SQS_JOB_VERIFICATION_QUEUE_URL}
- SQS_JOB_HANDLE_FAILURE_QUEUE_URL=${SQS_JOB_HANDLE_FAILURE_QUEUE_URL}
- SQS_WORKER_TRIGGER_QUEUE_URL=${SQS_WORKER_TRIGGER_QUEUE_URL}
- ALERTS=${ALERTS:-sns}
- AWS_SNS_ARN=${AWS_SNS_ARN}
- AWS_SNS_ARN_NAME=${AWS_SNS_ARN_NAME}
- DATABASE=${DATABASE:-mongodb}
- MONGODB_CONNECTION_STRING=${MONGODB_CONNECTION_STRING}
- PROVER_SERVICE=${PROVER_SERVICE:-sharp}
- SHARP_CUSTOMER_ID=${SHARP_CUSTOMER_ID}
- SHARP_URL=${SHARP_URL}
- SHARP_USER_CRT=${SHARP_USER_CRT}
- SHARP_USER_KEY=${SHARP_USER_KEY}
- SHARP_SERVER_CRT=${SHARP_SERVER_CRT}
- SHARP_PROOF_LAYOUT=${SHARP_PROOF_LAYOUT:-small}
- DA_LAYER=${DA_LAYER:-ethereum}
- SETTLEMENT_LAYER=${SETTLEMENT_LAYER:-ethereum}
- SETTLEMENT_RPC_URL=${SETTLEMENT_RPC_URL}
- MADARA_RPC_URL=${MADARA_RPC_URL}
- MEMORY_PAGES_CONTRACT_ADDRESS=${MEMORY_PAGES_CONTRACT_ADDRESS}
- ETHEREUM_PRIVATE_KEY=${ETHEREUM_PRIVATE_KEY}
- L1_CORE_CONTRACT_ADDRESS=${L1_CORE_CONTRACT_ADDRESS}
- RPC_FOR_SNOS=${RPC_FOR_SNOS}
- STARKNET_PRIVATE_KEY=${STARKNET_PRIVATE_KEY}
- STARKNET_ACCOUNT_ADDRESS=${STARKNET_ACCOUNT_ADDRESS}
- MADARA_BINARY_PATH=${MADARA_BINARY_PATH}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-madara_orchestrator}
- OTEL_COLLECTOR_ENDPOINT=${OTEL_COLLECTOR_ENDPOINT}
- TRACING_LEVEL=${TRACING_LEVEL:-info}
- STARKNET_OPERATOR_ADDRESS=${STARKNET_OPERATOR_ADDRESS}
depends_on:
- mongodb
- localstack
networks:
- app-network

mongodb:
image: mongo:latest
ports:
- "27017:27017"
networks:
- app-network

localstack:
image: localstack/localstack
container_name: localstack
ports:
- "4566:4566"
environment:
- DEFAULT_REGION=us-east-1
- AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY
ports:
- "4566:4566"
networks:
- app-network

mongodb:
image: mongo:latest
container_name: mongodb
ports:
- "27017:27017"
networks:
app-network:
driver: bridge
Loading