Skip to content

Commit 913ae8e

Browse files
committed
Add container image
1 parent a97867f commit 913ae8e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

.github/workflows/image.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build container image
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
env:
15+
# Use docker.io for Docker Hub if empty
16+
REGISTRY: ghcr.io
17+
# github.repository as <account>/<repo>
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
image:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-tags: true
28+
ref: ${{ inputs.release-version }}
29+
30+
# Login against a Docker registry except on PR
31+
# https://github.com/docker/login-action
32+
- name: Log into registry ${{ env.REGISTRY }}
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
# Extract metadata (tags, labels) for Docker
41+
# https://github.com/docker/metadata-action
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
context: git
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
tags: |
49+
type=semver,pattern=v{{version}}
50+
type=semver,pattern=v{{major}}.{{minor}}
51+
type=semver,pattern=v{{major}}
52+
type=ref,event=branch
53+
type=ref,event=pr
54+
type=ref,event=tag
55+
type=sha
56+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
57+
58+
# Build and push Docker image with Buildx (don't push on PR)
59+
# https://github.com/docker/build-push-action
60+
- name: Build and push Docker image
61+
uses: docker/build-push-action@v6
62+
with:
63+
context: .
64+
file: Containerfile
65+
push: ${{ github.event_name != 'pull_request' }}
66+
tags: ${{ steps.meta.outputs.tags }}
67+
labels: ${{ steps.meta.outputs.labels }}

Containerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3
2+
3+
ADD https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz /tmp/openshift-client.tar.gz
4+
RUN tar -C /usr/local/bin -xf /tmp/openshift-client.tar.gz
5+
6+
# Install uv
7+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
8+
9+
RUN apt -y update && apt -y install rsync && apt clean
10+
WORKDIR /work
11+
COPY pyproject.toml uv.lock ./
12+
RUN uv sync --all-extras

0 commit comments

Comments
 (0)