Skip to content

Commit d5c53ed

Browse files
authored
Merge pull request #3 from helloric/2-pipeline-to-build-an-push-image
2 pipeline to build an push image
2 parents 10f66e7 + b92466e commit d5c53ed

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# source: https://docs.github.com/en/actions/tutorials/publish-packages/publish-docker-images#publishing-images-to-github-packages
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches: ['main', '2-pipeline-to-build-an-push-image']
8+
9+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
ROS_DISTRO: jazzy
14+
15+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
16+
jobs:
17+
build-and-push-image:
18+
runs-on: ubuntu-latest
19+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
20+
permissions:
21+
contents: read
22+
packages: write
23+
attestations: write
24+
id-token: write
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v5
28+
with:
29+
submodules: recursive
30+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
31+
- name: Log in to the Container registry
32+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
# as suggested here: https://github.com/docker/build-push-action
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
43+
- name: Extract metadata (tags, labels) for Docker
44+
id: meta
45+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
46+
with:
47+
images: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}
48+
tags: |
49+
type=raw,value=${{ github.sha }}
50+
type=raw,value=latest
51+
labels: |
52+
labels: |
53+
org.opencontainers.image.title=HelloRic UI Communication Node
54+
org.opencontainers.image.description=Docker image for HelloRic UI Communication Node
55+
org.opencontainers.image.url=https://github.com/${{env.IMAGE_NAME}}
56+
org.opencontainers.image.vendor=DFKI RIC
57+
org.opencontainers.image.licenses=3-Clause BSD License
58+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
59+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
60+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
61+
- name: Build and push Docker image
62+
id: push
63+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
64+
with:
65+
build-args: |
66+
ROS_DISTRO=${{ env.ROS_DISTRO }}
67+
push: true
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
platforms: linux/arm64
71+
72+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
73+
- name: Generate artifact attestation
74+
uses: actions/attest-build-provenance@v3
75+
with:
76+
subject-name: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}
77+
subject-digest: ${{ steps.push.outputs.digest }}
78+
push-to-registry: true
79+

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG ROS_DISTRO
1+
ARG ROS_DISTRO=jazzy
22
FROM ros:${ROS_DISTRO}
33

44
RUN apt-get update -qq \
@@ -13,6 +13,9 @@ RUN apt-get update -qq \
1313
python3-pytest-cov \
1414
&& rm -rf /var/lib/apt/lists/*
1515

16+
# PEP 668: https://docs.ros.org/en/independent/api/rosdep/html/pip_and_pep_668.html
17+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
18+
1619
EXPOSE 7000
1720

1821
ENV APP=/app/helloric_ui_com

ric-messages

0 commit comments

Comments
 (0)