Skip to content

Commit

Permalink
build image for arm64 arch
Browse files Browse the repository at this point in the history
  • Loading branch information
tiero committed Dec 10, 2021
1 parent e4f5067 commit e0aa407
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 48 deletions.
40 changes: 18 additions & 22 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,32 @@ jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

permissions:
contents: read
packages: write
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file ./$VERSION/Dockerfile --tag $IMAGE_NAME

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
IMAGE_ID=ghcr.io/vulpemventures/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:latest
- name: Build image
run: >-
docker buildx build --push
--file ./$VERSION/Dockerfile
--tag ghcr.io/vulpemventures/$IMAGE_NAME:latest
--tag ghcr.io/vulpemventures/$IMAGE_NAME:$VERSION
--platform linux/arm64,linux/amd64 .
45 changes: 19 additions & 26 deletions 0.21.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
FROM debian:stable-slim AS builder
FROM debian:stretch-slim as builder

# VERSION of Elements Core to be build
# VERSION of Elements Core to be download
ARG VERSION=0.21.0
ARG TARGETPLATFORM

RUN apt-get update && apt-get install -y wget curl libzmq3-dev build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb-dev libdb++-dev libdb4.8
RUN set -ex \
&& if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export TARGETPLATFORM=x86_64-linux-gnu; fi \
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGETPLATFORM=aarch64-linux-gnu; fi \
&& apt-get update \
&& apt-get install -qq --no-install-recommends ca-certificates wget \
&& cd /tmp \
&& wget -qO elements.tar.gz "https://github.com/ElementsProject/elements/releases/download/elements-$VERSION/elements-elements-$VERSION-$TARGETPLATFORM.tar.gz" \
&& mkdir bin \
&& tar -xzvf elements.tar.gz -C /tmp/bin --strip-components=2 "elements-elements-$VERSION/bin/elements-cli" "elements-elements-$VERSION/bin/elementsd"

RUN wget -qO- https://github.com/ElementsProject/elements/archive/elements-$VERSION.tar.gz | tar -xvz -C /tmp
FROM debian:stretch-slim

RUN cd /tmp/elements-elements-$VERSION/depends && make NO_QT=1 NO_UPNP=1 && cd .. && \
./autogen.sh && \
./configure --without-gui --with-incompatible-bdb && \
make && \
mv ./src/elementsd /elementsd && \
mv ./src/elements-cli /elements-cli
COPY --from=builder "/tmp/bin" /usr/local/bin

FROM debian:stable-slim

RUN apt-get update && apt-get install -y libboost-filesystem-dev \
libboost-thread-dev \
libevent-dev \
libsodium-dev \
libzmq3-dev \
libdb-dev \
libdb++-dev

RUN useradd -ms /bin/bash elements
RUN groupadd -r elements && useradd -r -m -g elements elements

USER elements

COPY --from=builder /elementsd /usr/local/bin/elementsd
COPY --from=builder /elements-cli /usr/local/bin/elements-cli

# Prevents `VOLUME $HOME/.elements/` being created as owned by `root`
RUN mkdir -p "$HOME/.elements/"
RUN mkdir -p "$HOME/.elements/" \
&& chown -R elements:elements /home/elements/.elements

ENTRYPOINT [ "elementsd" ]


0 comments on commit e0aa407

Please sign in to comment.