Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit e813323

Browse files
chevdorMira Ressel
authored andcommitted
Publish RC container images (#7556)
* WIP * Add missing checkout * Add debuggin * Fix VAR name * Bug fix * Rework jobs * Revert "Rework jobs" This reverts commit 2bfa79f. * Add cache * Add temp default for testing * Add missing checkout * Fix patch * Comment out the GPG check for now * Rename polkadot_injected_release into a more appropriate polkadot_injected_debian * Refactoring / renaming * Introduce a generic image for binary injection * Flag files to be deleted and changes to be done * WIP * Fix multi binaries images * Add test build scripts * Remove old file, add polkadot build-injected script * Fix doc * Fix tagging * Add build of the injected container * Fix for docker * Remove the need for TTY * Handling container publishing * Fix owner and registry * Fix vars * Fix repo * Fix var naming * Fix case when there is no tag * Fix case with no tag * Handle error * Fix spacings * Fix tags * Remove unnecessary grep that may fail * Add final check * Clean up and introduce GPG check * Add doc * Add doc * Update doc/docker.md Co-authored-by: Mira Ressel <mira@parity.io> * type Co-authored-by: Mira Ressel <mira@parity.io> * Fix used VAR * Improve doc * ci: Update .build-push-image jobs to use the new build-injected.sh * ci: fix path to build-injected.sh script * Rename the release artifacts folder to prevent confusion due to a similar folder in the gitlab CI * ci: check out polkadot repo in .build-push-image This seems far cleaner than copying the entire scripts/ folder into our job artifacts. * feat(build-injected.sh): make PROJECT_ROOT configurable This lets us avoid a dependency on git in our CI image. * ci: build injected images with buildah * ci: pass full image names to zombienet * Add missing ignore --------- Co-authored-by: Mira Ressel <mira@parity.io>
1 parent 0f27b6c commit e813323

35 files changed

+661
-323
lines changed

.github/workflows/check-licenses.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-22.04
99
steps:
1010
- name: Checkout sources
11-
uses: actions/checkout@v3.3.0
11+
uses: actions/checkout@v3
1212
- uses: actions/setup-node@v3.7.0
1313
with:
1414
node-version: '18.x'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Release - Publish RC Container image
2+
# see https://github.com/paritytech/release-engineering/issues/97#issuecomment-1651372277
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
release_id:
8+
description: |
9+
Release ID.
10+
You can find it using the command:
11+
curl -s \
12+
-H "Authorization: Bearer ${GITHUB_TOKEN}" https://api.github.com/repos/$OWNER/$REPO/releases | \
13+
jq '.[] | { name: .name, id: .id }'
14+
required: true
15+
type: string
16+
registry:
17+
description: "Container registry"
18+
required: true
19+
type: string
20+
default: docker.io
21+
owner:
22+
description: Owner of the container image repo
23+
required: true
24+
type: string
25+
default: parity
26+
27+
env:
28+
RELEASE_ID: ${{ inputs.release_id }}
29+
ENGINE: docker
30+
REGISTRY: ${{ inputs.registry }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
DOCKER_OWNER: ${{ inputs.owner || github.repository_owner }}
33+
REPO: ${{ github.repository }}
34+
ARTIFACT_FOLDER: release-artifacts
35+
36+
jobs:
37+
fetch-artifacts:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: Checkout sources
42+
uses: actions/checkout@v3
43+
44+
- name: Fetch all artifacts
45+
run: |
46+
. ./scripts/ci/common/lib.sh
47+
fetch_release_artifacts
48+
49+
- name: Cache the artifacts
50+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
51+
with:
52+
key: artifacts-${{ github.sha }}
53+
path: |
54+
${ARTIFACT_FOLDER}/**/*
55+
56+
build-container:
57+
runs-on: ubuntu-latest
58+
needs: fetch-artifacts
59+
60+
strategy:
61+
matrix:
62+
binary: ["polkadot", "staking-miner"]
63+
64+
steps:
65+
- name: Checkout sources
66+
uses: actions/checkout@v3
67+
68+
- name: Get artifacts from cache
69+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
70+
with:
71+
key: artifacts-${{ github.sha }}
72+
path: |
73+
${ARTIFACT_FOLDER}/**/*
74+
75+
- name: Check sha256 ${{ matrix.binary }}
76+
working-directory: ${ARTIFACT_FOLDER}
77+
run: |
78+
. ../scripts/ci/common/lib.sh
79+
80+
echo "Checking binary ${{ matrix.binary }}"
81+
check_sha256 ${{ matrix.binary }} && echo "OK" || echo "ERR"
82+
83+
- name: Check GPG ${{ matrix.binary }}
84+
working-directory: ${ARTIFACT_FOLDER}
85+
run: |
86+
. ../scripts/ci/common/lib.sh
87+
import_gpg_keys
88+
check_gpg ${{ matrix.binary }}
89+
90+
- name: Fetch commit and tag
91+
id: fetch_refs
92+
run: |
93+
release=release-${{ inputs.release_id }} && \
94+
echo "release=${release}" >> $GITHUB_OUTPUT
95+
96+
commit=$(git rev-parse --short HEAD) && \
97+
echo "commit=${commit}" >> $GITHUB_OUTPUT
98+
99+
tag=$(git name-rev --tags --name-only $(git rev-parse HEAD)) && \
100+
[ "${tag}" != "undefined" ] && echo "tag=${tag}" >> $GITHUB_OUTPUT || \
101+
echo "No tag, doing without"
102+
103+
- name: Build Injected Container image for ${{ matrix.binary }}
104+
env:
105+
BIN_FOLDER: ${ARTIFACT_FOLDER}
106+
BINARY: ${{ matrix.binary }}
107+
TAGS: ${{join(steps.fetch_refs.outputs.*, ',')}}
108+
run: |
109+
echo "Building container for ${{ matrix.binary }}"
110+
./scripts/ci/dockerfiles/build-injected.sh
111+
112+
- name: Login to Dockerhub
113+
uses: docker/login-action@v2
114+
with:
115+
username: ${{ inputs.owner }}
116+
password: ${{ secrets.DOCKERHUB_TOKEN }}
117+
118+
- name: Push Container image for ${{ matrix.binary }}
119+
id: docker_push
120+
env:
121+
BINARY: ${{ matrix.binary }}
122+
run: |
123+
$ENGINE images | grep ${BINARY}
124+
$ENGINE push --all-tags ${REGISTRY}/${DOCKER_OWNER}/${BINARY}
125+
126+
- name: Check version for the published image for ${{ matrix.binary }}
127+
env:
128+
BINARY: ${{ matrix.binary }}
129+
RELEASE_TAG: ${{ steps.fetch_refs.outputs.release }}
130+
run: |
131+
echo "Checking tag ${RELEASE_TAG} for image ${REGISTRY}/${DOCKER_OWNER}/${BINARY}"
132+
$ENGINE run -i ${REGISTRY}/${DOCKER_OWNER}/${BINARY}:${RELEASE_TAG} --version

.github/workflows/release-50_publish-docker-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: docker/build-push-action@v4
3131
with:
3232
push: true
33-
file: scripts/ci/dockerfiles/polkadot_injected_release.Dockerfile
33+
file: scripts/ci/dockerfiles/polkadot/polkadot_injected_debian.Dockerfile
3434
tags: |
3535
parity/polkadot:latest
3636
parity/polkadot:${{ github.event.release.tag_name }}

.github/workflows/release-51_publish-docker-manual.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: docker/build-push-action@v4
3838
with:
3939
push: true
40-
file: scripts/ci/dockerfiles/polkadot_injected_release.Dockerfile
40+
file: scripts/ci/dockerfiles/polkadot/polkadot_injected_debian.Dockerfile
4141
tags: |
4242
parity/polkadot:latest
4343
parity/polkadot:${{ github.event.inputs.version }}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ polkadot.*
1010
!polkadot.service
1111
.DS_Store
1212
.env
13+
14+
artifacts
15+
release-artifacts
16+
release.json

.gitlab-ci.yml

+22-14
Original file line numberDiff line numberDiff line change
@@ -159,31 +159,39 @@ default:
159159
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
160160

161161
.build-push-image:
162+
variables:
163+
CI_IMAGE: "${BUILDAH_IMAGE}"
164+
165+
REGISTRY: "docker.io"
166+
DOCKER_OWNER: "paritypr"
167+
DOCKER_USER: "${PARITYPR_USER}"
168+
DOCKER_PASS: "${PARITYPR_PASS}"
169+
IMAGE: "${REGISTRY}/${DOCKER_OWNER}/${IMAGE_NAME}"
170+
171+
ENGINE: "${BUILDAH_COMMAND}"
172+
BUILDAH_FORMAT: "docker"
173+
SKIP_IMAGE_VALIDATION: 1
174+
175+
PROJECT_ROOT: "."
176+
BIN_FOLDER: "./artifacts"
177+
VCS_REF: "${CI_COMMIT_SHA}"
178+
162179
before_script:
163180
- !reference [.common-before-script, before_script]
164181
- test -s ./artifacts/VERSION || exit 1
165182
- test -s ./artifacts/EXTRATAG || exit 1
166-
- VERSION="$(cat ./artifacts/VERSION)"
183+
- export VERSION="$(cat ./artifacts/VERSION)"
167184
- EXTRATAG="$(cat ./artifacts/EXTRATAG)"
168185
- echo "Polkadot version = ${VERSION} (EXTRATAG = ${EXTRATAG})"
169186
script:
170187
- test "$DOCKER_USER" -a "$DOCKER_PASS" ||
171188
( echo "no docker credentials provided"; exit 1 )
172-
- cd ./artifacts
173-
- $BUILDAH_COMMAND build
174-
--format=docker
175-
--build-arg VCS_REF="${CI_COMMIT_SHA}"
176-
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
177-
--build-arg IMAGE_NAME="${IMAGE_NAME}"
178-
--tag "$IMAGE_NAME:$VERSION"
179-
--tag "$IMAGE_NAME:$EXTRATAG"
180-
--file ${DOCKERFILE} .
181-
# The job will success only on the protected branch
189+
- TAGS="${VERSION},${EXTRATAG}" scripts/ci/dockerfiles/build-injected.sh
182190
- echo "$DOCKER_PASS" |
183-
buildah login --username "$DOCKER_USER" --password-stdin docker.io
191+
buildah login --username "$DOCKER_USER" --password-stdin "${REGISTRY}"
184192
- $BUILDAH_COMMAND info
185-
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:$VERSION"
186-
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:$EXTRATAG"
193+
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE:$VERSION"
194+
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE:$EXTRATAG"
187195
after_script:
188196
- buildah logout --all
189197

doc/docker.md

+54-32
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,58 @@
1-
# Using Docker
1+
# Using Containers
2+
3+
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.
4+
5+
Let's start defining Podman as our engine:
6+
```
7+
ENGINE=podman
8+
```
9+
10+
If you prefer to stick with Docker, use:
11+
```
12+
ENGINE=docker
13+
```
214

315
## The easiest way
416

5-
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 package repository.
17+
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.
618

7-
**_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._**
19+
**_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._**
820

921
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:
1022

1123
```bash
12-
docker run --rm -it parity/polkadot:latest --version
24+
$ENGINE run --rm -it parity/polkadot:latest --version
1325
```
1426

1527
You can also pass any argument/flag that Polkadot supports:
1628

1729
```bash
18-
docker run --rm -it parity/polkadot:latest --chain westend --name "PolkaDocker"
30+
$ENGINE run --rm -it parity/polkadot:latest --chain westend --name "PolkaDocker"
1931
```
2032

2133
## Examples
2234

23-
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.
24-
25-
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`.
35+
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.
2636

27-
```bash
28-
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/polkadot parity/polkadot:latest --chain westend --rpc-external --rpc-cors all
29-
```
37+
Set user id 1000 and group id 1000, by running `chown 1000.1000 /my/local/folder -R` if you use a bind mount.
3038

31-
Additionally if you want to have custom node name you can add the `--name "YourName"` at the end
39+
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`.
3240

3341
```bash
34-
docker 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"
42+
$ENGINE run -d -p 30333:30333 -p 9933:9933 \
43+
-v /my/local/folder:/polkadot \
44+
parity/polkadot:latest \
45+
--chain westend --rpc-external --rpc-cors all \
46+
--name "PolkaDocker
3547
```
3648
3749
If you also want to expose the webservice port 9944 use the following command:
3850
3951
```bash
40-
docker 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"
52+
$ENGINE run -d -p 30333:30333 -p 9933:9933 -p 9944:9944 \
53+
-v /my/local/folder:/polkadot \
54+
parity/polkadot:latest \
55+
--chain westend --ws-external --rpc-external --rpc-cors all --name "PolkaDocker"
4156
```
4257
4358
## Using Docker compose
@@ -55,17 +70,19 @@ services:
5570
- 30333:30333 # p2p port
5671
- 9933:9933 # rpc port
5772
- 9944:9944 # ws port
73+
- 9615:9615 # Prometheus port
5874
volumes:
5975
- /my/local/folder:/polkadot
6076
command: [
6177
"--name", "PolkaDocker",
6278
"--ws-external",
6379
"--rpc-external",
80+
"--prometheus-external",
6481
"--rpc-cors", "all"
6582
]
6683
```
6784
68-
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>_
85+
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]>_
6986
7087
```bash
7188
version: '2'
@@ -78,10 +95,12 @@ services:
7895
- 30333:30333 # p2p port
7996
- 9933:9933 # rpc port
8097
- 9944:9944 # ws port
98+
- 9615:9615 # Prometheus port
8199
command: [
82100
"--name", "PolkaDocker",
83101
"--ws-external",
84102
"--rpc-external",
103+
"--prometheus-external",
85104
"--rpc-cors", "all"
86105
]
87106
@@ -100,36 +119,39 @@ Chain syncing will utilize all available memory and CPU power your server has to
100119
101120
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).
102121
103-
Start a shell session with the daemon:
104122
105-
```bash
106-
docker exec -it $(docker ps -q) bash;
107-
```
123+
## Build your own image
108124
109-
Check the current version:
125+
There are 3 options to build a polkadot container image:
126+
- using the builder image
127+
- using the injected "Debian" image
128+
- using the generic injected image
110129
111-
```bash
112-
polkadot --version
113-
```
130+
### Builder image
114131
115-
## Build your own image
132+
To get up and running with the smallest footprint on your system, you may use an existing Polkadot Container image.
116133
117-
To get up and running with the smallest footprint on your system, you may use the Polkadot Docker image.
118-
You can build it yourself (it takes a while...) in the shell session of the daemon:
134+
You may also build a polkadot container image yourself (it takes a while...) using the container specs `scripts/ci/dockerfiles/polkadot/polkadot_builder.Dockerfile`.
119135
120-
```bash
121-
cd scripts/ci/dockerfiles/polkadot
122-
./build.sh
123-
```
136+
### Debian injected
137+
138+
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.
139+
It has the benefit of relying on the GPG signatures embedded in the Debian package.
140+
141+
### Generic injected
142+
143+
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.
144+
145+
This binary is then simply copied inside the `parity/base-bin` image.
124146
125147
## Reporting issues
126148
127149
If you run into issues with Polkadot when using docker, please run the following command
128150
(replace the tag with the appropriate one if you do not use latest):
129151
130152
```bash
131-
docker run --rm -it parity/polkadot:latest --version
153+
$ENGINE run --rm -it parity/polkadot:latest --version
132154
```
133155
134156
This will show you the Polkadot version as well as the git commit ref that was used to build your container.
135-
Just paste that in the issue you create.
157+
You can now paste the version information in a [new issue](https://github.com/paritytech/polkadot/issues/new/choose).

0 commit comments

Comments
 (0)