Skip to content

Commit c242557

Browse files
committed
feat: Workflow to publish the docker image on a release
1 parent 7a662c7 commit c242557

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

.github/workflows/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Workflows
2+
23
This page contains some documentation on the workflows for this repository.
34

45
## build_test
6+
57
The workflow build_test is used to build and test the code (see build_test.yaml). Notice that the binaries are being cached so that the build process is sped up. Once the binaries are build the pipeline will run both the unit tests and the integration tests. This can take up to 30 minutes. The pipeline is ran on every commit to a PR and also when the PR has been merged with development. PRs should only be merged if the pipeline was green (if all tests passed).
68

7-
For performance reasons we are using a self hosted runner for running the pipeline. The runner will only run one pipeline at a time which means that all other runs will be queued. As the pipeline is ran on every commit it will thus also queue runs of consecutive pushed commits. We strongly advice to add `[skip ci]` to the commit messages whenever possible (when the run of a pipeline can be skipped). A pipeline can also be canceled [here](https://github.com/threefoldtech/tfchain/actions).
9+
For performance reasons we are using a self hosted runner for running the pipeline. The runner will only run one pipeline at a time which means that all other runs will be queued. As the pipeline is ran on every commit it will thus also queue runs of consecutive pushed commits. We strongly advice to add `[skip ci]` to the commit messages whenever possible (when the run of a pipeline can be skipped). A pipeline can also be canceled [here](https://github.com/threefoldtech/tfchain/actions).
810

911
### Docker image
12+
1013
We are using a custom docker image for building and testing the code. You can find the image on our [Docker Hub](https://hub.docker.com/repository/docker/threefolddev/tfchain). The dockerfile build_test.Dockerfile was used to build that image. If the image no longer meets the expectations please follow these steps:
1114

1215
1) Update the dockerfile as required (add what you need)
@@ -18,8 +21,11 @@ We are using a custom docker image for building and testing the code. You can fi
1821
4) Upload the image (you will need the credentials):
1922
> docker login
2023
> docker push threefolddev/tfchain:\<VERSION>
21-
5) Update the pipeline on the repository https://github.com/threefoldtech/tfchain under .github/workflows to use this new image
24+
5) Update the pipeline on the repository <https://github.com/threefoldtech/tfchain> under .github/workflows to use this new image
2225
6) Push your changes, create a PR and let the pipeline run. If it fails due to changes to the image you should start over the steps.
2326
7) Once the PR is landed please tag the repository so that we can trace back the dockerfile given the version:
2427
> git tag -a dockerfile-build-v\<VERSION> -m "new dockerfile version \<VERSION>"
2528
29+
## Publishing of a docker image
30+
31+
[publish_container_image.yml](./publish_container_image.yml) builds the docker container of a tfchain node and publishes it to the github container repository on a release.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-22.04
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- name: Checkout the repo
16+
uses: actions/checkout@v3
17+
18+
- name: Log in to the Container registry
19+
uses: docker/login-action@v2.1.0
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Extract metadata for Docker
26+
id: meta
27+
uses: docker/metadata-action@v4
28+
with:
29+
images: ghcr.io/${{ github.repository }}
30+
tags: |
31+
type=semver,pattern={{version}}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v3
35+
with:
36+
push: true
37+
context: ./substrate-node
38+
tags: ${{ steps.meta.outputs.tags }}
39+
labels: ${{ steps.meta.outputs.labels }}

substrate-node/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ RUN ldd /usr/local/bin/tfchain && \
2424

2525
# Install CA certificates not present in base image
2626
RUN apt-get update
27-
RUN apt-get install -y curl
2827
RUN apt-get install -y ca-certificates
28+
# curl is a handy tool when you need to make an rpc call inside the container
29+
RUN apt-get install -y curl
2930

3031
# Shrinking
3132
RUN rm -rf /usr/lib/python* && \

0 commit comments

Comments
 (0)