Skip to content

Commit 2dea54e

Browse files
authored
Merge pull request #208 from guggero/docker
Add Dockerfile to prepare for packaging as Umbrel app
2 parents e9dba25 + 69c5c28 commit 2dea54e

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Start with a Golang builder image.
2+
FROM golang:1.24.6-alpine3.22@sha256:c8c5f95d64aa79b6547f3b626eb84b16a7ce18a139e3e9ca19a8c078b85ba80d AS golangbuilder
3+
4+
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
5+
# be built from a specified Git state.
6+
ARG checkout="master"
7+
8+
# Install dependencies and install/build chantools.
9+
RUN apk add --no-cache --update alpine-sdk make \
10+
&& git clone https://github.com/lightninglabs/chantools /go/src/github.com/lightninglabs/chantools \
11+
&& cd /go/src/github.com/lightninglabs/chantools \
12+
&& git checkout $checkout \
13+
&& make install
14+
15+
# Start a new, final image to reduce size.
16+
FROM alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 AS final
17+
18+
# Define a root volume for data persistence.
19+
VOLUME /chantools
20+
WORKDIR /chantools
21+
22+
# We'll use the default / directory as the home directory, since the /chantools
23+
# folder will be overwritten if a volume is mounted there.
24+
ENV HOME=/
25+
26+
# We'll expect the lnd data directory to be mounted here.
27+
VOLUME /lnd
28+
29+
# Copy the binaries and entrypoint from the builder image.
30+
COPY ./docker/docker-entrypoint.sh /bin/
31+
COPY ./docker/bash-wrapper.sh /usr/local/bin/bash
32+
COPY --from=golangbuilder /go/bin/chantools /bin/
33+
34+
# Make the wrapper executable.
35+
RUN chmod 0777 /usr/local/bin/bash
36+
37+
# Add bash.
38+
RUN apk add --no-cache \
39+
bash \
40+
jq \
41+
ca-certificates
42+
43+
# We'll want to just start a shell, but also give the user some info on how to
44+
# use this image, which we do with a shell script.
45+
ENTRYPOINT ["/bin/docker-entrypoint.sh"]

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ release:
8181
rm -rf chantools-v*
8282
./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_LDFLAGS)"
8383

84+
docker-release:
85+
@$(call print, "Creating docker release of chantools.")
86+
./release.sh docker-release "$(VERSION_TAG)"
87+
8488
docker-tools:
8589
@$(call print, "Building tools docker image.")
8690
docker build -q -t chantools-tools $(TOOLS_DIR)

docker/bash-wrapper.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
echo "Welcome to the chantools command line interface."
4+
echo "Type 'chantools --help' (without quotes) to see available commands."
5+
echo ""
6+
echo "You might also want to visit https://www.node-recovery.com/chantools/"
7+
echo "for the reference documentation and an interactive tool that helps you"
8+
echo "build the command you might want to run."
9+
echo ""
10+
echo "Also, keep in mind that you don't have to run chantools inside this"
11+
echo "container. You can also install it directly on any machine you want,"
12+
echo "since there is no direct interaction with your Lightning node required"
13+
echo "and for most command you don't even need anything other than your seed"
14+
echo "phrase."
15+
echo ""
16+
17+
exec /bin/bash

docker/docker-entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
echo "Starting background shell, this container doesn't do anything on its own."
4+
echo "You can connect to it using: docker exec -it <container_name> bash"
5+
6+
sleep infinity

release.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
set -e
1111

1212
PKG="github.com/lightninglabs/chantools"
13+
DOCKER_USER="guggero"
1314
PACKAGE=chantools
1415

1516
# green prints one line of green text (if the terminal supports it).
@@ -79,6 +80,13 @@ function build_release() {
7980
shasum -a 256 * >manifest-$tag.txt
8081
}
8182

83+
# docker_release builds the Docker images for all supported platforms.
84+
# arguments: <version-tag>
85+
function docker_release() {
86+
local tag=$1
87+
docker buildx build --platform linux/arm64,linux/amd64 --tag $DOCKER_USER/$PACKAGE:$tag --output "type=registry" .
88+
}
89+
8290
# usage prints the usage of the whole script.
8391
function usage() {
8492
red "Usage: "
@@ -103,6 +111,10 @@ build-release)
103111
green "Building release"
104112
build_release "$@"
105113
;;
114+
docker-release)
115+
green "Building docker release"
116+
docker_release "$@"
117+
;;
106118
*)
107119
usage
108120
exit 1

0 commit comments

Comments
 (0)