Skip to content

Commit f548fba

Browse files
committed
multi arch build
1 parent e221d3b commit f548fba

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

.github/workflows/build-and-push.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- main
77

88
env:
9-
IMAGE_NAME: flyio/mpg-operator-postgres
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}/mpg-operator-postgres
1011

1112
jobs:
1213
build-and-push:
@@ -19,35 +20,39 @@ jobs:
1920
- name: Checkout repository
2021
uses: actions/checkout@v4
2122

23+
# Set up QEMU for multi-architecture support
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v3
26+
2227
- name: Set up Docker Buildx
2328
uses: docker/setup-buildx-action@v3
29+
with:
30+
platforms: linux/amd64,linux/arm64
2431

25-
- name: Login to DockerHub
26-
if: github.event_name != 'pull_request'
27-
uses: docker/login-action@v1
32+
- name: Log in to the Container registry
33+
uses: docker/login-action@v3
2834
with:
29-
username: ${{ secrets.FLYIOBUILDS_DOCKERHUB_USERNAME }}
30-
password: ${{ secrets.FLYIOBUILDS_DOCKERHUB_TOKEN }}
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
3138

3239
- name: Extract metadata for Docker
3340
id: meta
3441
uses: docker/metadata-action@v5
3542
with:
36-
images: ${{ env.IMAGE_NAME }}
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3744
tags: |
3845
type=raw,value=latest
3946
type=sha,format=short
47+
type=raw,value={{date 'YYYYMMDD'}}
4048
4149
- name: Build and push Docker image
4250
uses: docker/build-push-action@v5
43-
id: docker_build
4451
with:
4552
context: .
53+
platforms: linux/amd64,linux/arm64
4654
push: true
4755
tags: ${{ steps.meta.outputs.tags }}
4856
labels: ${{ steps.meta.outputs.labels }}
4957
cache-from: type=gha
5058
cache-to: type=gha,mode=max
51-
52-
- name: Image digest
53-
run: echo ${{ steps.docker_build.outputs.digest }}

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This Docker image extends `percona/percona-postgresql-operator:2.6.0-ppg16.8-pos
88
- Uses a root-to-user approach to ensure proper privileges for OOM adjustment
99
- Intelligently identifies and protects the PostgreSQL postmaster process
1010
- Preserves the original container entrypoint and behavior
11+
- Multi-architecture support (amd64/x86_64 and arm64/aarch64)
1112

1213
## How It Works
1314

@@ -44,16 +45,19 @@ docker run -d --name postgres oom-protected-postgres
4445

4546
This repository includes a GitHub Action that automatically builds and pushes the Docker image to GitHub Container Registry (ghcr.io) whenever changes are pushed to the main branch.
4647

47-
### Automated Builds
48+
### Automated Multi-Architecture Builds
4849

4950
The workflow:
50-
1. Builds the Docker image
51-
2. Tags it with both `latest` and the short commit SHA
52-
3. Pushes it to GitHub Container Registry
51+
1. Builds the Docker image for multiple architectures (amd64 and arm64)
52+
2. Tags it with:
53+
- `latest` tag
54+
- Short SHA of the commit (e.g., `sha-a1b2c3d`)
55+
- Date in YYYYMMDD format
56+
3. Pushes it to GitHub Container Registry as a multi-architecture manifest
5357

5458
### Using the Pre-built Image
5559

56-
Once built, you can pull the image directly:
60+
Once built, you can pull the image directly, and Docker will automatically select the right architecture for your system:
5761

5862
```bash
5963
docker pull ghcr.io/[your-username]/mpg-postgres-image/oom-protected-postgres:latest

0 commit comments

Comments
 (0)