-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker multi-arch support for arm32v7/arm64v8 (#79)
- Generate dockerfiles for arm32v7/arm64v8 - Use built binaries in release process
- Loading branch information
Showing
8 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,5 @@ Dockerfile | |
stuff | ||
scripts | ||
.git | ||
dist | ||
contrib | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Changing the `Dockerfile` requires running `scripts/docker-generate.sh` to generate the arm32v7/arm64v8 images. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# rust:1.49-slim | ||
FROM rust@sha256:58cb29151843a8ba8e0e78e3f80096ed2f9514cf81d4f85ef43727140631e67b as builder | ||
RUN apt-get update && apt-get install -y pkg-config libssl-dev | ||
WORKDIR /usr/src/bwt | ||
COPY . . | ||
ARG FEATURES=electrum,http,webhooks,track-spends | ||
ARG PREBUILT_BIN | ||
RUN if [ -n "$PREBUILT_BIN" ]; then cp $PREBUILT_BIN /usr/local/bin; \ | ||
else cargo install --locked --path . --root /usr/local/ --no-default-features --features "cli,$FEATURES"; fi | ||
|
||
# debian:buster-slim | ||
FROM debian@sha256:d31590f680577ffde6bd08943e9590eaabdc04529ea60f4bb6f58cddbc33f628 | ||
ARG FEATURES=electrum,http,webhooks,track-spends | ||
RUN echo $FEATURES | grep -v webhooks > /dev/null || (apt-get update && apt-get install -y libssl-dev) | ||
COPY --from=builder /usr/local/bin/bwt /usr/local/bin/ | ||
ENTRYPOINT [ "bwt", "--bitcoind-dir", "/bitcoin" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# rust:1.49-slim | ||
FROM rust@sha256:2a44876432ba0cfbe7f7fcddd9b16f316ee13abecdee43b25f0645529966bc40 as builder | ||
RUN apt-get update && apt-get install -y pkg-config libssl-dev | ||
WORKDIR /usr/src/bwt | ||
COPY . . | ||
ARG FEATURES=electrum,http,webhooks,track-spends | ||
ARG PREBUILT_BIN | ||
RUN if [ -n "$PREBUILT_BIN" ]; then cp $PREBUILT_BIN /usr/local/bin; \ | ||
else cargo install --locked --path . --root /usr/local/ --no-default-features --features "cli,$FEATURES"; fi | ||
|
||
# debian:buster-slim | ||
FROM debian@sha256:01b65c2928fed9427e59a679e287a75d98551ea2061cf03c61be0c7e1fc40fef | ||
ARG FEATURES=electrum,http,webhooks,track-spends | ||
RUN echo $FEATURES | grep -v webhooks > /dev/null || (apt-get update && apt-get install -y libssl-dev) | ||
COPY --from=builder /usr/local/bin/bwt /usr/local/bin/ | ||
ENTRYPOINT [ "bwt", "--bitcoind-dir", "/bitcoin" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -xeo pipefail | ||
|
||
# Generate the arm32v7/arm64v8 dockerfiles using the main dockerfile as a template | ||
generate_dockerfile() { | ||
local builder_image=$1 | ||
local runtime_image=$2 | ||
sed -r "s/^(FROM rust@sha256:)[^ ]+/\1$builder_image/; s/^(FROM debian@sha256:)[^ ]+/\1$runtime_image/;" dockerfiles/Dockerfile | ||
} | ||
|
||
# arm32v7/rust:1.49.0-slim and arm32v7/debian:buster-slim (10.7) | ||
# https://hub.docker.com/r/arm32v7/rust/tags?name=slim | ||
# https://hub.docker.com/r/arm32v7/debian/tags?name=buster-slim | ||
generate_dockerfile 58cb29151843a8ba8e0e78e3f80096ed2f9514cf81d4f85ef43727140631e67b \ | ||
d31590f680577ffde6bd08943e9590eaabdc04529ea60f4bb6f58cddbc33f628 \ | ||
> dockerfiles/arm32v7.Dockerfile | ||
|
||
# arm64v8/rust:1.49.0-slim and arm64v8/debian:buster-slim (10.7) | ||
# https://hub.docker.com/r/arm64v8/rust/tags?name=slim | ||
# https://hub.docker.com/r/arm64v8/debian/tags?name=buster-slim | ||
generate_dockerfile 2a44876432ba0cfbe7f7fcddd9b16f316ee13abecdee43b25f0645529966bc40 \ | ||
01b65c2928fed9427e59a679e287a75d98551ea2061cf03c61be0c7e1fc40fef \ | ||
> dockerfiles/arm64v8.Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -xeo pipefail | ||
shopt -s expand_aliases | ||
|
||
docker_name=shesek/bwt | ||
|
||
version=$(grep -E '^version =' Cargo.toml | cut -d'"' -f2) | ||
base_tag=$docker_name:$version | ||
|
||
docker_name=shesek/bwt-test | ||
base_tag=$docker_name:$version | ||
|
||
build_variant() { | ||
local docker_tag=$1 | ||
local docker_alias=$2 | ||
|
||
build $1-amd64 $2-amd64 $3 "$4" x86_64-linux Dockerfile | ||
build $1-arm32v7 $2-arm32v7 $3 "$4" arm32v7-linux arm32v7.Dockerfile | ||
build $1-arm64v8 $2-arm64v8 $3 "$4" arm64v8-linux arm64v8.Dockerfile | ||
|
||
# can't tag manifests to create an alias, need to create them separately instead | ||
for target in $docker_tag $docker_alias; do | ||
docker manifest create --amend $target $docker_tag-amd64 $docker_tag-arm32v7 $docker_tag-arm64v8 | ||
docker manifest annotate $target $docker_tag-amd64 --os linux --arch amd64 | ||
docker manifest annotate $target $docker_tag-arm32v7 --os linux --arch arm --variant v7 | ||
docker manifest annotate $target $docker_tag-arm64v8 --os linux --arch arm64 --variant v8 | ||
docker manifest push $target -p | ||
done | ||
} | ||
|
||
build() { | ||
local docker_tag=$1 | ||
local docker_alias=$2 | ||
local features=$3 | ||
local bin_variant=$4 | ||
local bin_platform=$5 | ||
local dockerfile=$6 | ||
|
||
docker build -t $docker_tag --build-arg FEATURES=$features \ | ||
--build-arg PREBUILT_BIN=dist/bwt-$version$bin_variant-$bin_platform/bwt \ | ||
-f dockerfiles/$dockerfile . | ||
|
||
docker tag $docker_tag $docker_alias | ||
docker push $docker_tag | ||
docker push $docker_alias | ||
} | ||
|
||
build_variant $base_tag $docker_name:latest http,electrum,webhooks,track-spends '' | ||
build_variant $base_tag-electrum $docker_name:electrum electrum '-electrum_only' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters