Skip to content

Commit

Permalink
feat: docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jun 27, 2024
1 parent 867724e commit 883ca71
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
dockerfiles/
.dockerignore
*.tar.gz
24 changes: 15 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ name = "runehook"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "runehook"
path = "src/main.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# chainhook-sdk = { version = "0.12.10", features = ["zeromq"] }
chainhook-sdk = { version = "=0.12.10", path = "../chainhook/components/chainhook-sdk", features = ["zeromq"] }
chainhook-sdk = { version = "0.12.10", features = ["zeromq"] }
# chainhook-sdk = { version = "=0.12.10", path = "../chainhook/components/chainhook-sdk", features = ["zeromq"] }
bitcoin = { version = "0.30.1", features = ["rand"] }
lru = "0.12.3"
ordinals = "0.0.8"
Expand All @@ -31,3 +35,7 @@ num-traits = "0.2.14"

[dev-dependencies]
test-case = "3.1.0"

[features]
debug = ["hiro-system-kit/debug"]
release = ["hiro-system-kit/release"]
23 changes: 23 additions & 0 deletions dockerfiles/runehook.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM rust:bullseye as build

WORKDIR /app

RUN apt-get update && apt-get install -y ca-certificates pkg-config libssl-dev libclang-11-dev libunwind-dev libunwind8 curl gnupg
RUN rustup update 1.77.1 && rustup default 1.77.1

RUN mkdir /out
COPY ./Cargo.toml /app/Cargo.toml
COPY ./Cargo.lock /app/Cargo.lock
COPY ./src /app/src
COPY ./migrations /app/migrations

RUN cargo build --features release --release
RUN cp /app/target/release/runehook /out

FROM debian:bullseye-slim

COPY --from=build /out/runehook /bin/runehook

WORKDIR /workspace

ENTRYPOINT ["runehook"]
14 changes: 14 additions & 0 deletions dockerfiles/runes-api.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:18-alpine

WORKDIR /app
COPY ./api /app
COPY .git /app/.git

RUN apk add --no-cache --virtual .build-deps git
RUN npm ci --no-audit && \
npm run build && \
npm run generate:git-info && \
npm prune --production
RUN apk del .build-deps

CMD ["node", "./dist/src/index.js"]
4 changes: 2 additions & 2 deletions src/scan/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use chainhook_sdk::chainhooks::bitcoin::{
BitcoinChainhookOccurrence, BitcoinTriggerChainhook,
};
use chainhook_sdk::chainhooks::types::{
BitcoinChainhookSpecification, BitcoinPredicateType, RunesOperations,
BitcoinChainhookSpecification, BitcoinPredicateType,
};
use chainhook_sdk::indexer::bitcoin::{
build_http_client, download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
Expand Down Expand Up @@ -39,7 +39,7 @@ pub async fn scan_blocks(
end_block: None,
expired_at: None,
expire_after_occurrence: None,
predicate: BitcoinPredicateType::RunesProtocol(RunesOperations::Feed),
predicate: BitcoinPredicateType::Block,
action: chainhook_sdk::chainhooks::types::HookAction::Noop,
include_proof: false,
include_inputs: true,
Expand Down
15 changes: 12 additions & 3 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ pub async fn start_service(config: &Config, ctx: &Context) -> Result<(), String>
} else if bitcoind_chain_tip > chain_tip {
info!(
ctx.expect_logger(),
"Scanning on block range {} to {}",
chain_tip,
bitcoind_chain_tip
"Scanning on block range {} to {}", chain_tip, bitcoind_chain_tip
);
scan_blocks(
((chain_tip + 1)..bitcoind_chain_tip).collect(),
Expand Down Expand Up @@ -100,6 +98,17 @@ pub async fn start_service(config: &Config, ctx: &Context) -> Result<(), String>
index_block(&mut pg_client, &mut index_cache, block, ctx).await;
}
}
ObserverEvent::BitcoinChainEvent((
BitcoinChainEvent::ChainUpdatedWithReorg(mut event),
_,
)) => {
for block in event.blocks_to_rollback.iter() {
// rollback
}
for block in event.blocks_to_apply.iter() {
// apply
}
}
ObserverEvent::Terminate => {}
_ => {}
}
Expand Down

0 comments on commit 883ca71

Please sign in to comment.