Skip to content

Commit b2af98e

Browse files
committed
karak_docker_added
1 parent e3899ae commit b2af98e

File tree

140 files changed

+40254
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+40254
-132
lines changed

deploy.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
success
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,56 @@
11
FROM rust:1.83-slim AS builder
22

3+
# Set working directory in container
34
WORKDIR /app
45

5-
COPY . .
6+
# Copy workspace files
7+
COPY karak_offchain/Cargo.toml karak_offchain/Cargo.lock ./
68

7-
WORKDIR /app/aggregator
9+
# Modify workspace members to only include aggregator
10+
RUN sed -i 's/members = \["aggregator", "operator"\]/members = ["aggregator"]/' Cargo.toml
811

9-
# Install necessary dependencies in a single step
12+
# Copy aggregator package
13+
COPY karak_offchain/aggregator/Cargo.toml ./aggregator/
14+
COPY karak_offchain/aggregator/src ./aggregator/src
15+
16+
# Copy ABI files
17+
COPY karak_offchain/abi/ ./abi/
18+
19+
# Copy contracts
20+
COPY onchain/contracts/ ./onchain/contracts/
21+
22+
# Install system dependencies
1023
RUN apt-get update && \
1124
apt-get install -y --no-install-recommends \
1225
pkg-config \
1326
libssl-dev \
1427
ca-certificates \
15-
openssl \
16-
libterm-readline-perl-perl && \
28+
openssl && \
1729
rm -rf /var/lib/apt/lists/*
1830

19-
RUN cargo build --release --bin square-number-dss-aggregator
31+
# Build only the aggregator
32+
RUN cargo build --release --package square-number-dss-aggregator
2033

2134
# ---- Runtime stage ----
2235
FROM debian:bookworm-slim
2336

2437
WORKDIR /app
2538

26-
# Set environment to avoid interactive prompts
27-
ENV DEBIAN_FRONTEND=noninteractive
28-
29-
# Install necessary runtime dependencies
39+
# Install runtime dependencies
3040
RUN apt-get update && \
31-
apt-get install -y --no-install-recommends curl ca-certificates && \
41+
apt-get install -y --no-install-recommends \
42+
libssl3 \
43+
ca-certificates && \
3244
rm -rf /var/lib/apt/lists/*
3345

34-
COPY --from=builder /app/target/release/square-number-dss-aggregator /app/square-number-dss-aggregator
35-
COPY --from=builder /app/onchain /app/onchain
46+
# Copy built binary
47+
COPY --from=builder \
48+
/app/target/release/square-number-dss-aggregator \
49+
/app/
3650

51+
# Copy contract artifacts
52+
COPY --from=builder \
53+
/app/onchain/contracts \
54+
/app/onchain/contracts
3755

38-
ENTRYPOINT ["/app/square-number-dss-aggregator"]
56+
ENTRYPOINT ["/app/square-number-dss-aggregator"]

karak_offchain/aggregator/src/contract.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@ use crate::TaskError;
1717
sol!(
1818
#[sol(rpc)]
1919
SquareNumberDSS,
20-
"../abi/SquareNumberDSS.json",
20+
"/app/abi/SquareNumberDSS.json",
2121
);
2222

23-
2423
sol!(
2524
#[sol(rpc)]
2625
TxnVerifier,
27-
"../abi/TxnVerifier.json",
26+
"/app/abi/TxnVerifier.json",
2827
);
2928

29+
30+
3031
sol!(
3132
#[sol(rpc)]
3233
#[allow(clippy::too_many_arguments)]
3334
VaultAbi,
34-
"../abi/Vault.json",
35+
"/app/abi/Vault.json",
3536
);
3637

3738
type RecommendedProvider = FillProvider<

karak_offchain/docker-compose.yaml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ services:
33
image: ghcr.io/foundry-rs/foundry:nightly
44
platform: linux/amd64
55
ports:
6-
- "8545:8545"
6+
- "8546:8545"
77
volumes:
8-
- ./:/dss
8+
- ../:/dss
99
environment:
1010
- ANVIL_IP_ADDR=0.0.0.0
11-
working_dir: /dss/contracts
11+
working_dir: /dss/onchain/contracts
1212
command: anvil --no-cors
1313

1414
contract-builder:
1515
image: node:22.5-slim
16+
user: "node"
1617
platform: linux/amd64
1718
volumes:
18-
- ./:/dss
19-
working_dir: /dss/contracts
19+
- ../:/dss
20+
working_dir: /dss/onchain/contracts
2021
depends_on:
2122
- anvil
2223
entrypoint:
@@ -29,10 +30,11 @@ services:
2930
3031
contract-deployer:
3132
image: ghcr.io/foundry-rs/foundry:nightly
33+
user: "root"
3234
platform: linux/amd64
3335
volumes:
34-
- ./:/dss
35-
working_dir: /dss/contracts
36+
- ../:/dss
37+
working_dir: /dss/onchain/contracts
3638
depends_on:
3739
- anvil
3840
entrypoint:
@@ -50,11 +52,12 @@ services:
5052
aggregator:
5153
image: square-number-dss-aggregator
5254
build:
53-
context: .
54-
dockerfile: aggregator/Dockerfile
55+
# Change context to parent directory which contains the workspace root
56+
context: ..
57+
dockerfile: karak_offchain/aggregator/Dockerfile
5558
platform: linux/amd64
5659
volumes:
57-
- ./:/dss
60+
- ../:/dss
5861
ports:
5962
- "3000:3000"
6063
healthcheck:
@@ -72,7 +75,7 @@ services:
7275
- COMMON_RATE_LIMIT_WINDOW_MS=1000
7376
- COMMON_RATE_LIMIT_MAX_REQUESTS=10000
7477
- PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
75-
- BLOCK_NUMBER_STORE=/dss/contracts/block-number-store.json
78+
- BLOCK_NUMBER_STORE=/dss/onchain/contracts/block-number-store.json
7679
- RUST_LOG=info
7780
- SQUARE_NUMBER_DSS_ADDRESS=0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE
7881
- TXN_VERIFIER_ADDRESS=0x3Aa5ebB10DC797CAC828524e59A333d0A371443c
@@ -83,9 +86,12 @@ services:
8386
operator-1:
8487
image: square-number-dss-operator
8588
build:
86-
context: .
87-
dockerfile: operator/Dockerfile
89+
# Change context to parent directory which contains the workspace root
90+
context: ..
91+
dockerfile: karak_offchain/operator/Dockerfile
8892
platform: linux/amd64
93+
volumes:
94+
- ../:/dss
8995
ports:
9096
- "8080:8080"
9197
environment:
@@ -111,9 +117,12 @@ services:
111117
operator-2:
112118
image: square-number-dss-operator
113119
build:
114-
context: .
115-
dockerfile: operator/Dockerfile
120+
# Change context to parent directory which contains the workspace root
121+
context: ..
122+
dockerfile: karak_offchain/operator/Dockerfile
116123
platform: linux/amd64
124+
volumes:
125+
- ../:/dss
117126
ports:
118127
- "8081:8081"
119128
environment:
@@ -134,4 +143,4 @@ services:
134143
- RUST_BACKTRACE=full
135144
depends_on:
136145
aggregator:
137-
condition: service_healthy
146+
condition: service_healthy

karak_offchain/operator/Dockerfile

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
11
FROM rust:1.83-slim AS builder
22

3+
# Set working directory in container
34
WORKDIR /app
45

5-
COPY . .
6+
# Copy workspace root files
7+
COPY karak_offchain/Cargo.toml karak_offchain/Cargo.lock ./
68

7-
WORKDIR /app/operator
9+
# Modify workspace members to only include operator
10+
RUN sed -i 's/members = \["aggregator", "operator"\]/members = ["operator"]/' Cargo.toml
811

9-
# Install necessary dependencies in a single step
12+
# Copy operator package
13+
COPY karak_offchain/operator/Cargo.toml ./operator/
14+
COPY karak_offchain/operator/src ./operator/src
15+
16+
# Copy ABI files
17+
COPY karak_offchain/abi/ ./abi/
18+
19+
# Copy contracts
20+
COPY onchain/contracts/ ./onchain/contracts/
21+
22+
# Install system dependencies
1023
RUN apt-get update && \
1124
apt-get install -y --no-install-recommends \
1225
pkg-config \
1326
libssl-dev \
1427
ca-certificates \
15-
openssl \
16-
libterm-readline-perl-perl && \
28+
openssl && \
1729
rm -rf /var/lib/apt/lists/*
1830

19-
RUN cargo build --release --bin square-number-dss-operator
31+
# Build only the operator
32+
RUN cargo build --release --package square-number-dss-operator
2033

2134
# ---- Runtime stage ----
2235
FROM debian:bookworm-slim
2336

2437
WORKDIR /app
2538

26-
# Set environment to avoid interactive prompts
27-
ENV DEBIAN_FRONTEND=noninteractive
28-
29-
# Install necessary runtime dependencies
39+
# Install runtime dependencies
3040
RUN apt-get update && \
31-
apt-get install -y --no-install-recommends libssl3 ca-certificates && \
41+
apt-get install -y --no-install-recommends \
42+
libssl3 \
43+
ca-certificates && \
3244
rm -rf /var/lib/apt/lists/*
3345

34-
COPY --from=builder /app/target/release/square-number-dss-operator /app/square-number-dss-operator
46+
# Copy built binary
47+
COPY --from=builder /app/target/release/square-number-dss-operator /app/
48+
49+
# Copy contract artifacts
50+
COPY --from=builder /app/onchain/contracts /app/onchain/contracts
3551

36-
ENTRYPOINT ["/app/square-number-dss-operator"]
52+
ENTRYPOINT ["/app/square-number-dss-operator"]

karak_offchain/operator/src/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use alloy::sol;
33
sol!(
44
#[sol(rpc)]
55
SquareNumberDSS,
6-
"../abi/SquareNumberDSS.json",
6+
"/app/abi/SquareNumberDSS.json",
77
);
88

99
sol!(
1010
#[sol(rpc)]
1111
TxnVerifier,
12-
"../abi/TxnVerifier.json",
12+
"/app/abi/TxnVerifier.json",
1313
);
1414

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
FOUNDRY_PROFILE: ci
7+
8+
jobs:
9+
check:
10+
strategy:
11+
fail-fast: true
12+
13+
name: Foundry project
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
with:
23+
version: nightly
24+
25+
- name: Run Forge build
26+
run: |
27+
forge --version
28+
forge build --sizes
29+
id: build
30+
31+
- name: Run Forge tests
32+
run: |
33+
forge test -vvv
34+
id: test

onchain/contracts/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

onchain/contracts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# DSS Contract
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"block_number": 0
3+
}

0 commit comments

Comments
 (0)