Skip to content

Commit

Permalink
Merge pull request #44 from louneskmt/docker
Browse files Browse the repository at this point in the history
feat: add Dockerfile
  • Loading branch information
dr-orlovsky authored Jul 18, 2022
2 parents b42d8dd + 0f610e6 commit 812c0e3
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 3 deletions.
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This image uses cargo-chef to build the application in order to compile
# the dependencies apart from the main application. This allows the compiled
# dependencies to be cached in the Docker layer and greatly reduce the
# build time when there isn't any dependency changes.
#
# https://github.com/LukeMathWalker/cargo-chef

ARG SRC_DIR=/usr/local/src/bp-descriptor-wallet
ARG BUILDER_DIR=/srv/bp-descriptor-wallet

# Base image
FROM rust:1.59.0-slim-bullseye as chef

ARG SRC_DIR
ARG BUILDER_DIR

RUN rustup default stable
RUN rustup update
RUN cargo install cargo-chef --locked

WORKDIR $SRC_DIR

# Cargo chef step that analyzes the project to determine the minimum subset of
# files (Cargo.lock and Cargo.toml manifests) required to build it and cache
# dependencies
FROM chef AS planner

COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder

ARG SRC_DIR
ARG BUILDER_DIR

COPY --from=planner "${SRC_DIR}/recipe.json" recipe.json

# Build dependencies - this is the caching Docker layer
RUN cargo chef cook --release --recipe-path recipe.json --target-dir "${BUILDER_DIR}"

# Copy all files and build application
COPY . .
RUN cargo build --release --target-dir "${BUILDER_DIR}" --bins --all-features

# Final image with binaries
FROM debian:bullseye-slim as final

ARG BUILDER_DIR
ARG BIN_DIR=/usr/local/bin
ARG DATA_DIR=/var/lib/bp-descriptor-wallet
ARG USER=bp

RUN adduser --home "${DATA_DIR}" --shell /bin/bash --disabled-login \
--gecos "${USER} user" ${USER}

COPY --from=builder --chown=${USER}:${USER} \
"${BUILDER_DIR}/release" "${BIN_DIR}"

WORKDIR "${BIN_DIR}"

# Remove build artifacts in order to keep only the binaries
RUN rm -rf */ *.d .[^.] .??*

USER ${USER}
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Apache2 licensed](https://img.shields.io/badge/license-Apache%202-blue)](./LICENSE)

Library for building descriptor-based bitcoin wallets. Everything a modern
cold and hot bitcoin wallet needs, but which is not (yet) a part of
cold and hot bitcoin wallet needs, but which is not (yet) a part of
[rust-bitcoin](https://crates.io/bitcoin) library.

The library clearly separates parts requiring access to private keys from
Expand All @@ -23,15 +23,16 @@ command-line `btc-hot` and `btc-cold` wallets in [`bin`](bin) directory for an
example of how this can be done.

Library provides

- efficient manipulations with BIP-32 derivation paths, separating derivations
requiring private key access from those, which will always operate without;
- miniscript & classical bitcoin descriptors;
- PSBT constructor using input descriptors, which allow to specify custom
- PSBT constructor using input descriptors, which allow to specify custom
information about RBFs, previous public key P2C tweaks and custom hash types
on a per-input basis;
- PSBT signer, supporting RBFs, relative and absolute timelocks, all sighash
types, complex scripts, including witness- and taproot-based;
- script templates allowing embedding extended pubkeys into bitcoin script
- script templates allowing embedding extended pubkeys into bitcoin script
assembly;
- lexicographic ordering of transaction & PSBT inputs & oututs;
- script type system;
Expand All @@ -47,6 +48,7 @@ Library provides

One may install command-line wallets with the following command (requires
rust compiler and `rustup` tools to be already installed on a system):

```console
$ rustup default stable
$ rustup update
Expand All @@ -58,3 +60,35 @@ $ cargo install --path . --locked --all-features
This will add `btc-hot` and `btc-cold` commands to the system.

[bin]: https://github.com/BP-WG/descriptor-wallet/tree/master/src/bin

### Install with Docker

#### Build

Clone the repository and checkout to the desired version (here `v0.8.0`):

```console
$ git clone https://github.com/BP-WG/descriptor-wallet
$ cd descriptor-wallet
$ git checkout v0.8.0
```

Build and tag the Docker image:

```console
$ docker build -t descriptor-wallet:v0.8.0 .
```

#### Usage

```console
$ docker run descriptor-wallet:v0.8.0 btc-hot --help
$ docker run descriptor-wallet:v0.8.0 btc-cold --help
```

#### Examples with files

```console
$ docker run -v $PWD/data:/data descriptor-wallet:v0.8.0 btc-hot seed /data/testnet.seed
$ docker run -v $PWD/data:/data descriptor-wallet:v0.8.0 btc-hot derive --testnet /data/testnet.seed /data/testnet
```

0 comments on commit 812c0e3

Please sign in to comment.