Skip to content

Commit 10cd9d7

Browse files
committed
chore: add db-2 ticketsystem
1 parent abee012 commit 10cd9d7

5 files changed

Lines changed: 237 additions & 175 deletions

File tree

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Build and Push Container
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
context:
7+
required: true
8+
type: string
9+
dockerfile:
10+
default: Dockerfile
11+
type: string
12+
image:
13+
default: database-development
14+
type: string
15+
tag:
16+
required: true
17+
type: string
18+
latest:
19+
default: false
20+
type: boolean
21+
push:
22+
default: false
23+
type: boolean
24+
architectures:
25+
description: "List of architectures as JSON-array"
26+
type: string
27+
default: '["amd64","arm64"]'
28+
29+
permissions:
30+
contents: read
31+
packages: write
32+
33+
jobs:
34+
build:
35+
name: Build image
36+
runs-on: ubuntu-24.04
37+
strategy:
38+
matrix:
39+
platform: ${{ fromJSON(inputs.architectures) }}
40+
steps:
41+
- name: Install qemu dependency
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y qemu-user-static
45+
46+
- name: Checkout repository
47+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
48+
49+
- name: Setup environment variables
50+
run: |
51+
echo "CONTEXT=${CONTEXT}" >> ${GITHUB_ENV}
52+
echo "IMAGE=${IMAGE}" >> ${GITHUB_ENV}
53+
echo "PLATFORM=${PLATFORM}" >> ${GITHUB_ENV}
54+
[ "${PLATFORM}" = "amd64" ] && echo "BUILDAH_ARCH=linux/amd64" >> ${GITHUB_ENV} || true
55+
[ "${PLATFORM}" = "arm64" ] && echo "BUILDAH_ARCH=linux/arm64/v8" >> ${GITHUB_ENV} || true
56+
echo "DOCKERFILE=${DOCKERFILE}" >> ${GITHUB_ENV}
57+
echo "TAG=${TAG}" >> ${GITHUB_ENV}
58+
env:
59+
PLATFORM: ${{ matrix.platform }}
60+
CONTEXT: ${{ inputs.context }}
61+
IMAGE: ${{ inputs.image }}
62+
DOCKERFILE: ${{ inputs.dockerfile }}
63+
TAG: ${{ inputs.tag }}
64+
65+
- name: Build image with buildah
66+
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
67+
with:
68+
image: erhardtconsulting/${{ env.IMAGE }}
69+
tags: ${{ env.TAG }}-${{ env.PLATFORM }}
70+
platform: ${{ env.BUILDAH_ARCH }}
71+
context: ${{ env.CONTEXT }}
72+
containerfiles: |
73+
${{ env.DOCKERFILE }}
74+
75+
- name: Create tar image
76+
run: |
77+
buildah push erhardtconsulting/${IMAGE}:${TAG}-${PLATFORM} oci-archive:/tmp/${IMAGE}-${TAG}-${PLATFORM}.tar
78+
79+
- name: Upload container
80+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
81+
with:
82+
name: ${{ env.IMAGE }}-${{ env.TAG }}-${{ env.PLATFORM }}
83+
path: /tmp/${{ env.IMAGE }}-${{ env.TAG }}-${{ env.PLATFORM }}.tar
84+
if-no-files-found: error
85+
retention-days: 3
86+
87+
push:
88+
if: ${{ inputs.push }}
89+
name: Push image
90+
runs-on: ubuntu-24.04
91+
needs: build
92+
steps:
93+
- name: Setup environment variables
94+
run: |
95+
echo "IMAGE=${IMAGE}" >> ${GITHUB_ENV}
96+
echo "TAG=${TAG}" >> ${GITHUB_ENV}
97+
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
98+
env:
99+
IMAGE: ${{ inputs.image }}
100+
TAG: ${{ inputs.tag }}
101+
102+
- name: Download all artifacts
103+
run: |
104+
ARCHS=$(echo '${{ inputs.architectures }}' | jq -r '.[]')
105+
mkdir -p /tmp
106+
for arch in $ARCHS; do
107+
echo "==> Downloading artifact: $arch"
108+
gh run --repo github.com/erhardtconsulting/database-development download ${GITHUB_RUN_ID} --name "${IMAGE}-${TAG}-$arch" --dir /tmp
109+
done
110+
env:
111+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: List images
114+
run: ls -lh /tmp
115+
116+
- name: Create multiarch-manifest
117+
run: |
118+
ARCHS=$(echo '${{ inputs.architectures }}' | jq -r '.[]')
119+
buildah manifest create erhardtconsulting/${IMAGE}:${TAG}
120+
for arch in $ARCHS; do
121+
echo "==> Adding: $arch"
122+
buildah manifest add erhardtconsulting/${IMAGE}:${TAG} oci-archive:/tmp/${IMAGE}-${TAG}-${arch}.tar
123+
done
124+
125+
- name: Add tags
126+
run: |
127+
for registry in "ghcr.io"; do
128+
buildah tag erhardtconsulting/${IMAGE}:${TAG} ${registry}/erhardtconsulting/${IMAGE}:${TAG}
129+
done
130+
echo "PUSH_TAGS=${TAG}" >> $GITHUB_ENV
131+
132+
- name: Tag image as latest
133+
if: ${{ inputs.latest }}
134+
run: |
135+
for registry in "ghcr.io"; do
136+
buildah tag erhardtconsulting/${IMAGE}:${TAG} ${registry}/erhardtconsulting/${IMAGE}:latest
137+
done
138+
echo "PUSH_TAGS=${TAG} latest" >> $GITHUB_ENV
139+
140+
- name: Log in to ghcr.io
141+
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1
142+
with:
143+
registry: ghcr.io/erhardtconsulting
144+
username: ${{ github.actor }}
145+
password: ${{ github.token }}
146+
147+
- name: Push image to ghcr.io
148+
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2
149+
with:
150+
registry: ghcr.io/erhardtconsulting
151+
image: ${{ env.IMAGE }}
152+
tags: ${{ env.PUSH_TAGS }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "PG Ticket-System: Build Container Image / Pull Request"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- 'postgres/**'
9+
- '.github/workflows/build-container.yml'
10+
- '.github/workflows/build-pg-ticket-system-pr.yml'
11+
- '.github/workflows/build-pg-ticket-system.yml'
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
jobs:
18+
get-version:
19+
runs-on: ubuntu-24.04
20+
outputs:
21+
postgres: ${{ steps.postgres_version.outputs.POSTGRES_VERSION }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
25+
26+
- name: Get Postgres version
27+
id: postgres_version
28+
run: |
29+
echo "POSTGRES_VERSION=$(grep -E '^FROM docker.io/library/postgres:[0-9]+\.[0-9]+' postgres/ticket_system.Dockerfile | sed -E 's|.*postgres:([0-9]+\.[0-9]+).*|\1|')" >> $GITHUB_OUTPUT
30+
31+
call-build-workflow:
32+
name: Build
33+
needs: get-version
34+
uses: erhardtconsulting/database-development/.github/workflows/build-container.yml@main
35+
with:
36+
context: "postgres"
37+
dockerfile: "postgres/ticket_system.Dockerfile"
38+
image: "database-development"
39+
tag: ticket-system-${{ needs.get-version.outputs.postgres }}
40+
latest: false
41+
push: false
42+
secrets: inherit
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "PG Ticket-System: Build & Push Container Image"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'postgres/**'
9+
- '.github/workflows/build-container.yml'
10+
- '.github/workflows/build-pg-ticket-system.yml'
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
get-version:
18+
runs-on: ubuntu-24.04
19+
outputs:
20+
postgres: ${{ steps.postgres_version.outputs.POSTGRES_VERSION }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
24+
25+
- name: Get Postgres version
26+
id: postgres_version
27+
run: |
28+
echo "POSTGRES_VERSION=$(grep -E '^FROM docker.io/library/postgres:[0-9]+\.[0-9]+' postgres/ticket_system.Dockerfile | sed -E 's|.*postgres:([0-9]+\.[0-9]+).*|\1|')" >> $GITHUB_OUTPUT
29+
30+
call-build-workflow:
31+
name: Build & Push
32+
needs: get-version
33+
uses: erhardtconsulting/database-development/.github/workflows/build-container.yml@main
34+
with:
35+
context: "postgres"
36+
dockerfile: "postgres/ticket_system.Dockerfile"
37+
image: "database-development"
38+
tag: ticket-system-${{ needs.get-version.outputs.postgres }}
39+
latest: false
40+
push: true
41+
secrets: inherit

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Verbindungsdaten:
7575
- Benutzer: `ticket_user`
7676
- Passwort: `ticket_user`
7777

78+
Das Container-Image wird über GitHub Actions als `ghcr.io/erhardtconsulting/database-development:ticket-system-17.9` gebaut.
79+
7880
## Lizenz
7981

8082
Dieses Werk steht unter der Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA 4.0).

0 commit comments

Comments
 (0)