Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build on-demand docker images for testing on devnets #4667

Merged
merged 41 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4099572
ci: build alpha action
strophy Jan 3, 2022
85f71ee
ci: use self-hosted runner
strophy Jan 3, 2022
7775e58
ci: build faster
strophy Jan 3, 2022
507b704
ci: multicore dash build
strophy Jan 3, 2022
fa57b40
chore: copy build, dockerize and push
strophy Jan 5, 2022
db4b2e0
chore: dockerize build
strophy Jan 5, 2022
58a556b
chore: remove unnecessary cachedir and checkout steps
strophy Jan 5, 2022
fb8b7f9
chore: disable qemu
strophy Jan 5, 2022
ecda587
chore: remove buildx steps now included in AMI
strophy Jan 6, 2022
6a2a5cd
chore: move binaries in to place for second stage copy
strophy Jan 6, 2022
c9a7001
fix: runner using incorrect build driver
strophy Jan 10, 2022
8dc2b17
chore: debug builder info
strophy Jan 10, 2022
58d4275
chore: more detailed debug
strophy Jan 10, 2022
ee25f80
chore: install qemu and buildx in actions
strophy Jan 10, 2022
b1d3b02
fix: indentation
strophy Jan 10, 2022
3851f0d
fix: remove debug code
strophy Jan 10, 2022
f2d50d8
feat: multi-arch cross-compiling dockerfile
strophy Jan 11, 2022
15ebdeb
chore: remove unnecessary docker layers
strophy Jan 12, 2022
8562532
chore: add debug output
strophy Jan 12, 2022
1fe0c35
chore: dump context
strophy Jan 12, 2022
acdfb0b
fix: use event inputs tag for docker_meta
strophy Jan 12, 2022
2818864
chore: dump context again
strophy Jan 12, 2022
100a596
fix: context reference syntax
strophy Jan 12, 2022
ff8b98c
Merge branch 'master' into gha-aws-build-on-demand
strophy Jan 18, 2022
a1505e8
feat: attempt to use gitian builder
strophy Jan 19, 2022
b724667
Merge remote-tracking branch 'upstream/develop' into gha-aws-build-on…
strophy Mar 2, 2022
daece1c
chore: ff changes from other branches
strophy Mar 8, 2022
b2afa22
chore: disable macOS build
strophy Mar 8, 2022
89f59f3
Merge remote-tracking branch 'upstream/develop' into gha-aws-build-on…
strophy Mar 9, 2022
d72c971
Revert "chore: ff changes from other branches"
strophy Mar 10, 2022
2b0b295
chore: restore GHA changes to fix incorrect merge
strophy Mar 10, 2022
4207f62
chore: remove duplicate code
strophy Mar 14, 2022
4c6ec8f
chore: bump buildx version to latest
strophy Mar 14, 2022
0ef27b6
chore: try to build without signing
strophy Mar 15, 2022
f8995f7
chore: setup tmate to find build
strophy Mar 15, 2022
6c4b255
chore: run tmate on failure
strophy Mar 15, 2022
c40aa51
fix: invalid path to binaries on copy
strophy Mar 15, 2022
365b76f
chore: remove unnecessary GPG steps
strophy Mar 28, 2022
f3bde3f
chore: replace strophy with dashpay
strophy Mar 28, 2022
7337cb2
fix: gha cache not providing speedup
strophy Mar 31, 2022
eaf74de
Update .github/workflows/release_alpha.yml
UdjinM6 Apr 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions .github/workflows/release_alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Build and push image

on:
workflow_dispatch:
inputs:
tag:
description: 'Docker tag'
required: true

jobs:
build:
name: Run Gitian build
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: dash

UdjinM6 marked this conversation as resolved.
Show resolved Hide resolved
- name: Checkout Gitian builder
uses: actions/checkout@v2
with:
repository: devrandom/gitian-builder
path: gitian-builder

- name: Checkout detached sigs
uses: actions/checkout@v2
with:
repository: dashpay/dash-detached-sigs
path: dash-detached-sigs

- name: Checkout gitian sigs
uses: actions/checkout@v2
with:
repository: dashpay/gitian.sigs
path: gitian.sigs

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
strophy marked this conversation as resolved.
Show resolved Hide resolved

- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"

- name: Checkout
uses: actions/checkout@v2
with:
path: dash

- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: devrandom/gitian-builder
path: gitian-builder

- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: dashpay/dash-detached-sigs
path: dash-detached-sigs

- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: dashpay/gitian.sigs
path: gitian.sigs
strophy marked this conversation as resolved.
Show resolved Hide resolved

# - name: Clone macOS SDK
# run: |
# mkdir gitian-builder/inputs
# wget -q -O gitian-builder/inputs/MacOSX10.11.sdk.tar.gz https://bitcoincore.org/depends-sources/sdks/MacOSX10.11.sdk.tar.gz

- name: Import GPG key
run: echo ${{GPG_PRIVATE_KEY}} | gpg --import
strophy marked this conversation as resolved.
Show resolved Hide resolved

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: strophy/dashd
strophy marked this conversation as resolved.
Show resolved Hide resolved
tags: |
type=semver,pattern={{version}},value=${{ github.event.inputs.tag }}
type=raw,value=latest-dev
flavor: |
latest=false

- name: Install apt-cacher-ng
run: sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-cacher-ng

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5

- name: Prepare Gitian
run: dash/contrib/gitian-build.py --setup "strophy" "${{ steps.branch-name.outputs.current_branch }}"
strophy marked this conversation as resolved.
Show resolved Hide resolved

- uses: pat-s/always-upload-cache@v2
id: ccache
with:
path: /opt/actions-runner/_work/dash/dash/gitian-builder/cache/dash-linux-0.17
key: ${{ runner.os }}-ccache-${{ hashFiles('**/ccache.tar') }}
restore-keys: ${{ runner.os }}-ccache-

- name: Run Gitian build
run: |
export GPG_TTY=$(tty)
dash/contrib/gitian-build.py -c -b -n -o l \
-u https://github.com/strophy/dash \
strophy marked this conversation as resolved.
Show resolved Hide resolved
-j $(nproc) -m `awk '/^Mem/ {print $7}' <(free -m)` \
strophy ${{ steps.branch-name.outputs.current_branch }}
strophy marked this conversation as resolved.
Show resolved Hide resolved

- name: Set up QEMU to run multi-arch builds
uses: docker/setup-qemu-action@v1

- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: v0.7.0
install: true

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: ${{ github.workspace }}
file: ./dash/contrib/containers/deploy/Dockerfile.GitHubActions.Gitian
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
TAG=${{ steps.docker_meta.outputs.version }}
BRANCH=${{ steps.branch-name.outputs.current_branch }}
24 changes: 4 additions & 20 deletions .github/workflows/release_docker_hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand All @@ -52,22 +44,14 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./docker
file: ./contrib/containers/deploy/Dockerfile.GitHubActions
file: ./contrib/containers/deploy/Dockerfile.GitHubActions.Release
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: TAG=${{ steps.docker_meta.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
platforms: linux/amd64,linux/arm64,linux/arm/v7

- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
80 changes: 80 additions & 0 deletions contrib/containers/deploy/Dockerfile.GitHubActions.Dispatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# syntax=docker/dockerfile:1.3

FROM --platform=$BUILDPLATFORM ubuntu:focal as builder
RUN apt-get update && \
apt-get -y install --no-install-recommends \
automake \
autotools-dev \
bsdmainutils \
build-essential \
ca-certificates \
curl \
g++-arm-linux-gnueabihf \
libtool \
pkg-config \
python3 \
wget \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /dash

COPY . .

ARG TARGETPLATFORM

RUN case "$TARGETPLATFORM" in \
"linux/arm64") make HOST=arm-linux-gnueabihf -C depends -j`nproc | awk '{x=$1/2; print x}'` ;; \
"linux/amd64") make HOST=x86_64-pc-linux-gnu -C depends -j`nproc | awk '{x=$1/2; print x}'` ;; \
*) exit 1 ;; \
esac

RUN ./autogen.sh && \
case "$TARGETPLATFORM" in \
"linux/arm64") ./configure --prefix=`pwd`/depends/arm-linux-gnueabihf ;; \
"linux/amd64") ./configure --prefix=`pwd`/depends/x86_64-pc-linux-gnu ;; \
esac

RUN make -j`nproc | awk '{x=$1/2; print x}'` && make install

RUN mkdir built-target && \
case "$TARGETPLATFORM" in \
"linux/arm64") cp depends/arm-linux-gnueabihf/bin/dash* /dash/built-target ;; \
"linux/amd64") cp depends/x86_64-pc-linux-gnu/bin/dash* /dash/built-target ;; \
esac

FROM ubuntu:focal
LABEL maintainer="Dash Developers <dev@dash.org>"
LABEL description="Dockerised DashCore"

ARG USER_ID
ARG GROUP_ID
ARG TAG

ENV HOME /dash

# add user with specified (or default) user/group ids
ENV USER_ID ${USER_ID:-1000}
ENV GROUP_ID ${GROUP_ID:-1000}
RUN groupadd -g ${GROUP_ID} dash && \
useradd -u ${USER_ID} -g dash -s /bin/bash -m -d /dash dash && \
mkdir /dash/.dashcore && \
chown dash:dash -R /dash

RUN apt-get update && \
apt-get -y install --no-install-recommends \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /dash/built-target/dash* /usr/local/bin

USER dash

VOLUME ["/dash"]

COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 9998 9999 19998 19999

WORKDIR /dash
46 changes: 46 additions & 0 deletions contrib/containers/deploy/Dockerfile.GitHubActions.Gitian
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1.3
FROM ubuntu:focal
LABEL maintainer="Dash Developers <dev@dash.org>"
LABEL description="Dockerised DashCore"

ARG USER_ID
ARG GROUP_ID
ARG TAG
ARG BRANCH

ENV HOME /dash

# add user with specified (or default) user/group ids
ENV USER_ID ${USER_ID:-1000}
ENV GROUP_ID ${GROUP_ID:-1000}
RUN groupadd -g ${GROUP_ID} dash && \
useradd -u ${USER_ID} -g dash -s /bin/bash -m -d /dash dash && \
mkdir /dash/.dashcore && \
chown dash:dash -R /dash

RUN apt-get update && \
apt-get -y install --no-install-recommends \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY dashcore-binaries/${BRANCH}/dashcore* /dash

RUN mach=$(uname -m) \
&& case $mach in aarch64) arch="aarch64-linux-gnu"; ;; x86_64) arch="x86_64-linux-gnu"; ;; *) echo "ERROR: Machine type $mach not supported."; ;; esac \
&& cd /dash \
&& tar xvzf dashcore*$arch.tar.gz \
&& echo $(ls -1 /dash) \
&& cp dashcore-0.17.0/bin/* /usr/local/bin \
&& rm -rf dash*

USER dash

VOLUME ["/dash"]

COPY dash/contrib/containers/deploy/docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 9998 9999 19998 19999

WORKDIR /dash