Skip to content

Commit ef55369

Browse files
committed
add dockerfile and workflow for container build
1 parent 4c75730 commit ef55369

File tree

2 files changed

+486
-0
lines changed

2 files changed

+486
-0
lines changed

.github/workflows/build_ci_image.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Create and publish the CI docker image
2+
3+
# Configures this workflow to run when triggered.
4+
on:
5+
push:
6+
tags:
7+
- v**
8+
workflow_dispatch:
9+
10+
# Defines two custom environment variables for the workflow. These are used for
11+
# the Container registry domain, and a name for the Docker image that this
12+
# workflow builds.
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: darth/orca-jedi/ci-almalinux9
16+
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
21+
permissions:
22+
contents: read
23+
packages: write
24+
attestations: write
25+
id-token: write
26+
#
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
# Uses the `docker/login-action` action to log in to the Container
31+
# registry registry using the account and password that will publish the
32+
# packages. Once published, the packages are scoped to the account
33+
# defined here.
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GH_PAT }}
40+
# This step uses
41+
# [docker/metadata-action](https://github.com/docker/metadata-action#about)
42+
# to extract tags and labels that will be applied to the specified image.
43+
# The `id` "meta" allows the output of this step to be referenced in a
44+
# subsequent step. The `images` value provides the base name for the tags
45+
# and labels.
46+
- name: Extract metadata (tags, labels) for Docker
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
# This step uses the `docker/build-push-action` action to build the
52+
# image, based on your repository's `Dockerfile`. If the build succeeds,
53+
# it pushes the image to GitHub Packages. It uses the `context`
54+
# parameter to define the build's context as the set of files located in
55+
# the specified path. For more information, see
56+
# "[Usage](https://github.com/docker/build-push-action#usage)" in the
57+
# README of the `docker/build-push-action` repository. It uses the
58+
# `tags` and `labels` parameters to tag and label the image with the
59+
# output from the "meta" step.
60+
- name: Build and push Docker image
61+
id: push
62+
uses: docker/build-push-action@v6
63+
with:
64+
context: .
65+
push: true
66+
file: ./ci/Dockerfile.almalinux9
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
70+
# This step generates an artifact attestation for the image, which is an
71+
# unforgeable statement about where and how it was built. It increases
72+
# supply chain security for people who consume the image. For more
73+
# information, see
74+
# "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
75+
- name: Generate artifact attestation
76+
uses: actions/attest-build-provenance@v1
77+
with:
78+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
79+
subject-digest: ${{ steps.push.outputs.digest }}
80+
push-to-registry: true

0 commit comments

Comments
 (0)