mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
GHW for building and publishing docker images (#1391)
* add ghw and scripts for docker image deployment * debug * add permissions for content * fix path to the bin folder * add tags * rename env * fix path to docker file * make polkadot-parachain executable * fix typo * fix more typos * test * revert back use of working directory * mke bin executable in the artifacts folder * use cd instead of working directory * change path to cash * fix path to cash * change cache key * delete old flows * addressed PR comments * fix path * reorg docker files
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
name: Release - Publish RC Container image
|
||||
# see https://github.com/paritytech/release-engineering/issues/97#issuecomment-1651372277
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_id:
|
||||
description: |
|
||||
Release ID.
|
||||
You can find it using the command:
|
||||
curl -s \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" https://api.github.com/repos/$OWNER/$REPO/releases | \
|
||||
jq '.[] | { name: .name, id: .id }'
|
||||
required: true
|
||||
type: string
|
||||
registry:
|
||||
description: "Container registry"
|
||||
required: true
|
||||
type: string
|
||||
default: docker.io
|
||||
owner:
|
||||
description: Owner of the container image repo
|
||||
required: true
|
||||
type: string
|
||||
default: parity
|
||||
|
||||
env:
|
||||
RELEASE_ID: ${{ inputs.release_id }}
|
||||
ENGINE: docker
|
||||
REGISTRY: ${{ inputs.registry }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DOCKER_OWNER: ${{ inputs.owner || github.repository_owner }}
|
||||
REPO: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
fetch-artifacts:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Fetch all artifacts
|
||||
run: |
|
||||
. ./scripts/ci/common/lib.sh
|
||||
fetch_release_artifacts
|
||||
|
||||
- name: Cache the artifacts
|
||||
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
|
||||
with:
|
||||
key: artifacts-${{ github.sha }}
|
||||
path: |
|
||||
./release-artifacts/**/*
|
||||
|
||||
build-container:
|
||||
runs-on: ubuntu-latest
|
||||
needs: fetch-artifacts
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
binary: ["polkadot", "staking-miner"]
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get artifacts from cache
|
||||
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
|
||||
with:
|
||||
key: artifacts-${{ github.sha }}
|
||||
fail-on-cache-miss: true
|
||||
path: |
|
||||
./release-artifacts/**/*
|
||||
|
||||
- name: Check sha256 ${{ matrix.binary }}
|
||||
working-directory: ./release-artifacts
|
||||
run: |
|
||||
. ../scripts/ci/common/lib.sh
|
||||
|
||||
echo "Checking binary ${{ matrix.binary }}"
|
||||
check_sha256 ${{ matrix.binary }} && echo "OK" || echo "ERR"
|
||||
|
||||
- name: Check GPG ${{ matrix.binary }}
|
||||
working-directory: ./release-artifacts
|
||||
run: |
|
||||
. ../scripts/ci/common/lib.sh
|
||||
import_gpg_keys
|
||||
check_gpg ${{ matrix.binary }}
|
||||
|
||||
- name: Fetch commit and tag
|
||||
id: fetch_refs
|
||||
run: |
|
||||
release=release-${{ inputs.release_id }} && \
|
||||
echo "release=${release}" >> $GITHUB_OUTPUT
|
||||
|
||||
commit=$(git rev-parse --short HEAD) && \
|
||||
echo "commit=${commit}" >> $GITHUB_OUTPUT
|
||||
|
||||
tag=$(git name-rev --tags --name-only $(git rev-parse HEAD)) && \
|
||||
[ "${tag}" != "undefined" ] && echo "tag=${tag}" >> $GITHUB_OUTPUT || \
|
||||
echo "No tag, doing without"
|
||||
|
||||
- name: Build Injected Container image for ${{ matrix.binary }}
|
||||
env:
|
||||
BIN_FOLDER: ./release-artifacts
|
||||
BINARY: ${{ matrix.binary }}
|
||||
TAGS: ${{join(steps.fetch_refs.outputs.*, ',')}}
|
||||
run: |
|
||||
echo "Building container for ${{ matrix.binary }}"
|
||||
./scripts/ci/dockerfiles/build-injected.sh
|
||||
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Push Container image for ${{ matrix.binary }}
|
||||
id: docker_push
|
||||
env:
|
||||
BINARY: ${{ matrix.binary }}
|
||||
run: |
|
||||
$ENGINE images | grep ${BINARY}
|
||||
$ENGINE push --all-tags ${REGISTRY}/${DOCKER_OWNER}/${BINARY}
|
||||
|
||||
- name: Check version for the published image for ${{ matrix.binary }}
|
||||
env:
|
||||
BINARY: ${{ matrix.binary }}
|
||||
RELEASE_TAG: ${{ steps.fetch_refs.outputs.release }}
|
||||
run: |
|
||||
echo "Checking tag ${RELEASE_TAG} for image ${REGISTRY}/${DOCKER_OWNER}/${BINARY}"
|
||||
$ENGINE run -i ${REGISTRY}/${DOCKER_OWNER}/${BINARY}:${RELEASE_TAG} --version
|
||||
@@ -1,51 +0,0 @@
|
||||
name: Release - Publish Docker image (manual dispatch)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: version to build/release
|
||||
default: v0.9.18
|
||||
required: true
|
||||
date:
|
||||
description: release date of version
|
||||
default: "2022-02-23T19:11:58Z"
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@95cb08cb2672c73d4ffd2f422e6d11953d2a9c70 # v2.1.0
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
file: scripts/ci/dockerfiles/polkadot/polkadot_injected_debian.Dockerfile
|
||||
tags: |
|
||||
parity/polkadot:latest
|
||||
parity/polkadot:${{ github.event.inputs.version }}
|
||||
build-args: |
|
||||
POLKADOT_VERSION=${{ github.event.inputs.version }}
|
||||
VCS_REF=${{ github.ref }}
|
||||
BUILD_DATE=${{ github.event.inputs.date }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
@@ -1,173 +0,0 @@
|
||||
# Using Containers
|
||||
|
||||
The following commands should work no matter if you use Docker or Podman. In general, Podman is recommended. All
|
||||
commands are "engine neutral" so you can use the container engine of your choice while still being able to copy/paste
|
||||
the commands below.
|
||||
|
||||
Let's start defining Podman as our engine:
|
||||
```
|
||||
ENGINE=podman
|
||||
```
|
||||
|
||||
If you prefer to stick with Docker, use:
|
||||
```
|
||||
ENGINE=docker
|
||||
```
|
||||
|
||||
## The easiest way
|
||||
|
||||
The easiest/faster option to run Polkadot in Docker is to use the latest release images. These are small images that use
|
||||
the latest official release of the Polkadot binary, pulled from our Debian package.
|
||||
|
||||
**_The following examples are running on westend chain and without SSL. They can be used to quick start and learn how
|
||||
Polkadot needs to be configured. Please find out how to secure your node, if you want to operate it on the internet. Do
|
||||
not expose RPC and WS ports, if they are not correctly configured._**
|
||||
|
||||
Let's first check the version we have. The first time you run this command, the Polkadot docker image will be
|
||||
downloaded. This takes a bit of time and bandwidth, be patient:
|
||||
|
||||
```bash
|
||||
$ENGINE run --rm -it parity/polkadot:latest --version
|
||||
```
|
||||
|
||||
You can also pass any argument/flag that Polkadot supports:
|
||||
|
||||
```bash
|
||||
$ENGINE run --rm -it parity/polkadot:latest --chain westend --name "PolkaDocker"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Once you are done experimenting and picking the best node name :) you can start Polkadot as daemon, exposes the Polkadot
|
||||
ports and mount a volume that will keep your blockchain data locally. Make sure that you set the ownership of your local
|
||||
directory to the Polkadot user that is used by the container.
|
||||
|
||||
Set user id 1000 and group id 1000, by running `chown 1000.1000 /my/local/folder -R` if you use a bind mount.
|
||||
|
||||
To start a Polkadot node on default rpc port 9933 and default p2p port 30333 use the following command. If you want to
|
||||
connect to rpc port 9933, then must add Polkadot startup parameter: `--rpc-external`.
|
||||
|
||||
```bash
|
||||
$ENGINE run -d -p 30333:30333 -p 9933:9933 \
|
||||
-v /my/local/folder:/polkadot \
|
||||
parity/polkadot:latest \
|
||||
--chain westend --rpc-external --rpc-cors all \
|
||||
--name "PolkaDocker
|
||||
```
|
||||
|
||||
If you also want to expose the webservice port 9944 use the following command:
|
||||
|
||||
```bash
|
||||
$ENGINE run -d -p 30333:30333 -p 9933:9933 -p 9944:9944 \
|
||||
-v /my/local/folder:/polkadot \
|
||||
parity/polkadot:latest \
|
||||
--chain westend --ws-external --rpc-external --rpc-cors all --name "PolkaDocker"
|
||||
```
|
||||
|
||||
## Using Docker compose
|
||||
|
||||
You can use the following docker-compose.yml file:
|
||||
|
||||
```bash
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
polkadot:
|
||||
container_name: polkadot
|
||||
image: parity/polkadot
|
||||
ports:
|
||||
- 30333:30333 # p2p port
|
||||
- 9933:9933 # rpc port
|
||||
- 9944:9944 # ws port
|
||||
- 9615:9615 # Prometheus port
|
||||
volumes:
|
||||
- /my/local/folder:/polkadot
|
||||
command: [
|
||||
"--name", "PolkaDocker",
|
||||
"--ws-external",
|
||||
"--rpc-external",
|
||||
"--prometheus-external",
|
||||
"--rpc-cors", "all"
|
||||
]
|
||||
```
|
||||
|
||||
With following `docker-compose.yml` you can set up a node and use `polkadot-js-apps` as the front end on port 80. After
|
||||
starting the node use a browser and enter your Docker host IP in the URL field: _<http://[YOUR_DOCKER_HOST_IP]>_
|
||||
|
||||
```bash
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
polkadot:
|
||||
container_name: polkadot
|
||||
image: parity/polkadot
|
||||
ports:
|
||||
- 30333:30333 # p2p port
|
||||
- 9933:9933 # rpc port
|
||||
- 9944:9944 # ws port
|
||||
- 9615:9615 # Prometheus port
|
||||
command: [
|
||||
"--name", "PolkaDocker",
|
||||
"--ws-external",
|
||||
"--rpc-external",
|
||||
"--prometheus-external",
|
||||
"--rpc-cors", "all"
|
||||
]
|
||||
|
||||
polkadotui:
|
||||
container_name: polkadotui
|
||||
image: jacogr/polkadot-js-apps
|
||||
environment:
|
||||
- WS_URL=ws://[YOUR_DOCKER_HOST_IP]:9944
|
||||
ports:
|
||||
- 80:80
|
||||
```
|
||||
|
||||
## Limiting Resources
|
||||
|
||||
Chain syncing will utilize all available memory and CPU power your server has to offer, which can lead to crashing.
|
||||
|
||||
If running on a low resource VPS, use `--memory` and `--cpus` to limit the resources used. E.g. To allow a maximum of
|
||||
512MB memory and 50% of 1 CPU, use `--cpus=".5" --memory="512m"`. Read more about limiting a container's resources
|
||||
[here](https://docs.docker.com/config/containers/resource_constraints).
|
||||
|
||||
|
||||
## Build your own image
|
||||
|
||||
There are 3 options to build a Polkadot container image:
|
||||
- using the builder image
|
||||
- using the injected "Debian" image
|
||||
- using the generic injected image
|
||||
|
||||
### Builder image
|
||||
|
||||
To get up and running with the smallest footprint on your system, you may use an existing Polkadot Container image.
|
||||
|
||||
You may also build a Polkadot container image yourself (it takes a while...) using the container specs
|
||||
`scripts/ci/dockerfiles/polkadot/polkadot_builder.Dockerfile`.
|
||||
|
||||
### Debian injected
|
||||
|
||||
The Debian injected image is how the official Polkadot container image is produced. It relies on the Debian package that
|
||||
is published upon each release. The Debian injected image is usually available a few minutes after a new release is
|
||||
published. It has the benefit of relying on the GPG signatures embedded in the Debian package.
|
||||
|
||||
### Generic injected
|
||||
|
||||
For simple testing purposes, the easiest option for Polkadot and also random binaries, is to use the
|
||||
`binary_injected.Dockerfile` container spec. This option is less secure since the injected binary is not checked at all
|
||||
but it has the benefit to be simple. This option requires to already have a valid `polkadot` binary, compiled for Linux.
|
||||
|
||||
This binary is then simply copied inside the `parity/base-bin` image.
|
||||
|
||||
## Reporting issues
|
||||
|
||||
If you run into issues with Polkadot when using docker, please run the following command (replace the tag with the
|
||||
appropriate one if you do not use latest):
|
||||
|
||||
```bash
|
||||
$ENGINE run --rm -it parity/polkadot:latest --version
|
||||
```
|
||||
|
||||
This will show you the Polkadot version as well as the git commit ref that was used to build your container. You can now
|
||||
paste the version information in a [new issue](https://github.com/paritytech/polkadot/issues/new/choose).
|
||||
@@ -51,7 +51,7 @@ to be installed. The trade-off however is that it takes a little longer to build
|
||||
tasks. You may build the multi-stage image the root of the Polkadot repository with:
|
||||
```
|
||||
TODO: UPDATE THAT
|
||||
docker build -t staking-miner -f scripts/ci/dockerfiles/staking-miner/staking-miner_builder.Dockerfile .
|
||||
docker build -t staking-miner -f docker/dockerfiles/staking-miner/staking-miner_builder.Dockerfile .
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
Reference in New Issue
Block a user