Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.
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 .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
target
Cargo.lock
devenv/*
!devenv/sbtc/docker/entrypoint
coverage
romeo/testing/
romeo/asset-contract/.test
romeo/asset-contract/.coverage

39 changes: 23 additions & 16 deletions devenv/sbtc/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
FROM rust:alpine as build
FROM rust:bookworm as clarinet

WORKDIR /romeo
RUN apt update && apt install -y pkg-config libssl-dev clang && \
rm -rf /var/lib/apt/lists/*

RUN apk add --no-cache g++ musl-dev git openssl-dev clang-dev libsecp256k1-dev
RUN cargo install clarinet-cli --bin clarinet --branch develop --locked --git https://github.com/hirosystems/clarinet.git

RUN cargo install --version 0.36.13 cargo-make
FROM rust:bookworm as romeo

RUN rustup component add rustfmt

COPY . .
RUN apt update && apt install -y g++ libssl-dev clang libsecp256k1-dev && \
rm -rf /var/lib/apt/lists/*

RUN RUSTFLAGS="-C target-feature=-crt-static" cargo install --path sbtc-cli
RUN cargo install --locked cargo-make

RUN RUSTFLAGS="-C target-feature=-crt-static" cargo install --path romeo

FROM alpine:latest
RUN rustup component add rustfmt

RUN apk add --no-cache openssl libsecp256k1 g++
COPY . .
ENV RUSTFLAGS "-C target-feature=-crt-static"
RUN cargo install --locked --path sbtc-cli
RUN cargo install --locked --path romeo

COPY --from=build /usr/local/cargo/bin/sbtc /usr/local/bin
COPY --from=build /usr/local/cargo/bin/romeo /usr/local/bin
FROM rust:slim-bookworm

ENTRYPOINT ["romeo"]
CMD ["-c", "/romeo/config.json"]
RUN apt update && apt install -y openssl libsecp256k1-dev curl jq && \
rm -rf /var/lib/apt/lists/*

COPY --from=clarinet /usr/local/cargo/bin/clarinet /usr/local/bin
COPY --from=romeo /usr/local/cargo/bin/sbtc /usr/local/bin
COPY --from=romeo /usr/local/cargo/bin/romeo /usr/local/bin
ADD devenv/sbtc/docker/entrypoint /usr/local/bin
RUN chmod a+x /usr/local/bin/entrypoint
ADD romeo/asset-contract /asset-contract

ENTRYPOINT ["entrypoint"]
27 changes: 27 additions & 0 deletions devenv/sbtc/docker/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -euo >/dev/null

API_URL=http://stacks:20443/v2/info

echo "Waiting on Stacks API $API_URL"
while ! curl -s $API_URL >/dev/null; do
sleep 1
done

# stacks ready to take contracts
STACKS_HEIGHT=1
echo "Waiting on Stacks height $STACKS_HEIGHT"
while [ "$(curl -s $API_URL | jq '.stacks_tip_height')" -lt $STACKS_HEIGHT ]; do
sleep 2
done

# deploy the contracts
cd asset-contract
sed -i "s/localhost:20443/stacks:20443/" deployments/default.devnet-plan.yaml
sed -i "s/localhost:18443/bitcoin:18443/" deployments/default.devnet-plan.yaml
clarinet deployments apply --no-dashboard -d -p deployments/default.devnet-plan.yaml
cd -

#launch romeo
romeo -c /romeo/config.json
5 changes: 2 additions & 3 deletions devenv/up.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash

./build.sh
if [ $? -eq 0 ]
then
docker compose up -d
docker compose up -d
else
echo "Build failed, not starting devenv"
echo "Build failed, not starting devenv"
fi
4 changes: 3 additions & 1 deletion devenv/utils/mine_btc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ if [[ -z "$num_blocks" ]]; then
exit 1
fi

btc_address=$(source $dir/get_credentials.sh | jq -r '.credentials["0"].bitcoin.p2wpkh.address')
$dir/../bitcoin/bin/bitcoin-cli generatetoaddress 1 $btc_address
echo "Mined 1 BTC to $btc_address"
btc_address=$(source $dir/get_credentials.sh | jq -r '.credentials["1"].bitcoin.p2wpkh.address')

$dir/../bitcoin/bin/bitcoin-cli generatetoaddress $num_blocks $btc_address
echo "Mined $num_blocks BTC to $btc_address"