Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/actions/build-push-image/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: "build and push image"
description: "Build a Docker image and push it to GCP and DockerHub registries"

inputs:
dockerfile:
description: "dockerfile to build"
Expand All @@ -7,9 +9,11 @@ inputs:
description: "image name (without registry)"
required: true
username:
description: "DockerHub username for authentication"
required: false
default: ""
password:
description: "DockerHub password for authentication"
required: false
default: ""
outputs:
Expand Down
117 changes: 111 additions & 6 deletions .github/workflows/release-build-binary.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Binary Build
name: Binary and Docker image Build for testing
# This workflow can be used to build a binary like polkadot + workers, omninode or polkadot-parachain
# from any branch with release or profuction profile to be later used for testing.
# ⚠️ IT should not be used for release purposes!
# from any revision with release or profuction profile to be later used for testing.
# Also this workflow builds a Docker image for the binary and pushes it to dockerhub.io/paritypr registry
# ⚠️ IT should not be used for release purposes!

on:
workflow_dispatch:
inputs:
revision:
description: The revision to build the binary from
required: true
type: string
binary:
required: true
default: "polkadot"
Expand All @@ -24,7 +29,6 @@ on:
description: "Features to enable when building the binary (must be a list of comma-separated features)"

jobs:

setup:
# GitHub Actions allows using 'env' in a container context.
# However, env variables don't work for forks: https://github.com/orgs/community/discussions/44322
Expand Down Expand Up @@ -53,14 +57,18 @@ jobs:
echo "RUNNER=ubuntu-latest" >> $GITHUB_OUTPUT
fi

build:
build-binary:
needs: [setup]
runs-on: ${{ needs.setup.outputs.RUNNER }}
container:
image: ${{ needs.setup.outputs.IMAGE }}
steps:
- name: Checkout
env:
INPUT_REVISION: ${{ inputs.revision }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ env.INPUT_REVISION }}

- name: Build binary
env:
Expand All @@ -82,7 +90,104 @@ jobs:
fi

- name: Upload ${{ inputs.binary }} artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ${{ inputs.binary }}
path: /artifacts/**

build-docker-image:
needs: [build-binary]
runs-on: parity-default
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.binary }}
path: artifacts-raw

- name: Flatten artifacts
env:
INPUT_BINARY: ${{ inputs.binary }}
run: |
# build-linux-release.sh produces /artifacts/<binary>/<binary>
# Debug Dockerfiles expect ./artifacts/<binary> (flat structure)
mkdir -p artifacts
if [ "$INPUT_BINARY" = "polkadot" ]; then
for bin in polkadot polkadot-prepare-worker polkadot-execute-worker; do
cp "artifacts-raw/${bin}/${bin}" "artifacts/${bin}"
done
else
cp "artifacts-raw/${INPUT_BINARY}/${INPUT_BINARY}" "artifacts/${INPUT_BINARY}"
fi
# Copy entrypoint script (needed by binary_injected_debug.Dockerfile)
cp docker/scripts/entrypoint.sh artifacts/
chmod a+x artifacts/*
ls -la artifacts/

- name: Prepare docker image tag
id: docker_tag
env:
INPUT_REVISION: ${{ inputs.revision }}
run: |
SHORT_SHA=$(echo "$INPUT_REVISION" | head -c 8)
echo "tag=${SHORT_SHA}" >> $GITHUB_OUTPUT

- name: Build Docker image for polkadot
if: ${{ inputs.binary == 'polkadot' }}
run: |
# Create empty runtimes dir (debug Dockerfile expects it, but this workflow doesn't build runtimes)
mkdir -p artifacts/runtimes
docker build \
--build-arg VCS_REF="${GITHUB_SHA}" \
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
--build-arg IMAGE_NAME="polkadot-debug" \
-t "docker.io/paritypr/polkadot-debug:${{ steps.docker_tag.outputs.tag }}" \
-f docker/dockerfiles/polkadot/polkadot_injected_debug.Dockerfile \
.

- name: Build Docker image for polkadot-parachain
if: ${{ inputs.binary == 'polkadot-parachain' }}
run: |
docker build \
--build-arg VCS_REF="${GITHUB_SHA}" \
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
--build-arg IMAGE_NAME="polkadot-parachain-debug" \
-t "docker.io/paritypr/polkadot-parachain-debug:${{ steps.docker_tag.outputs.tag }}" \
-f docker/dockerfiles/polkadot-parachain/polkadot-parachain-debug_unsigned_injected.Dockerfile \
.

- name: Build Docker image for ${{ inputs.binary }}
if: ${{ inputs.binary != 'polkadot' && inputs.binary != 'polkadot-parachain' }}
env:
INPUT_BINARY: ${{ inputs.binary }}
run: |
docker build \
--build-arg VCS_REF="${GITHUB_SHA}" \
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
--build-arg IMAGE_NAME="${INPUT_BINARY}" \
--build-arg BINARY="${INPUT_BINARY}" \
-t "docker.io/paritypr/${INPUT_BINARY}:${{ steps.docker_tag.outputs.tag }}" \
-f docker/dockerfiles/binary_injected_debug.Dockerfile \
.

- name: Login to DockerHub
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
username: ${{ secrets.PARITYPR_DOCKERHUB_USERNAME }}
password: ${{ secrets.PARITYPR_DOCKERHUB_PASSWORD }}

- name: Push Docker image
env:
INPUT_BINARY: ${{ inputs.binary }}
run: |
if [ "$INPUT_BINARY" = "polkadot" ] || [ "$INPUT_BINARY" = "polkadot-parachain" ]; then
IMAGE_NAME="${INPUT_BINARY}-debug"
else
IMAGE_NAME="${INPUT_BINARY}"
fi
docker images | grep "${IMAGE_NAME}"
docker push --all-tags "docker.io/paritypr/${IMAGE_NAME}"
57 changes: 57 additions & 0 deletions docker/dockerfiles/binary_injected_debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM docker.io/library/ubuntu:20.04

# This file allows building a Generic debug container image
# based on one or multiple pre-built Linux binaries.
# Some defaults are set to polkadot but all can be overridden.

SHELL ["/bin/bash", "-c"]

# metadata
ARG VCS_REF
ARG BUILD_DATE
ARG IMAGE_NAME
ARG BINARY=polkadot

ARG DOC_URL=https://github.com/paritytech/polkadot-sdk
ARG DESCRIPTION="Polkadot: a platform for web3"
ARG AUTHORS="devops-team@parity.io"
ARG VENDOR="Parity Technologies"

LABEL io.parity.image.authors=${AUTHORS} \
io.parity.image.vendor="${VENDOR}" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.title="${IMAGE_NAME}" \
io.parity.image.created="${BUILD_DATE}" \
io.parity.image.documentation="${DOC_URL}" \
io.parity.image.description="${DESCRIPTION}" \
io.parity.image.source="https://github.com/paritytech/polkadot-sdk/blob/${VCS_REF}/docker/dockerfiles/binary_injected_debug.Dockerfile"

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates && \
# apt cleanup
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user
useradd -m -u 1000 -U -s /bin/sh -d /data polkadot && \
mkdir -p /data && \
chown -R polkadot:polkadot /data

# add binary to docker image
COPY ./artifacts/* /usr/local/bin/
RUN chmod -R a+rx "/usr/local/bin"

USER polkadot
ENV BINARY=${BINARY}

EXPOSE 30333 9933 9944 9615
VOLUME ["/data"]

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["--help"]
Loading