Skip to content

Commit a7f7f93

Browse files
author
s.toribio
committed
multi-arch-repo
1 parent 24f3200 commit a7f7f93

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/manual.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ jobs:
8787
username: ${{ secrets.DOCKER_USERNAME }}
8888
password: ${{ secrets.DOCKER_PASSWORD }}
8989

90+
# Enable QEMU so amd64 runner can build arm64 too
91+
- name: Set up QEMU
92+
uses: docker/setup-qemu-action@v2
93+
9094
- name: Set up Docker Buildx
9195
uses: docker/setup-buildx-action@v2 # Set up Docker Buildx for advanced building
9296

@@ -102,6 +106,8 @@ jobs:
102106
context: modules/docker/mongodb # Path to the directory with the Dockerfile
103107
file: modules/docker/mongodb/Docker/dockerfile # Path to the Dockerfile
104108
push: true # Push the image to Docker Hub
109+
# Multi-arch only for mongodb
110+
platforms: linux/amd64,linux/arm64
105111
tags: ${{ secrets.DOCKER_USERNAME }}/mongodb:latest # Tag for the Docker image
106112
build-args: |
107113
DOCKER_REGISTRY_CACHE=${{ vars.DOCKER_REGISTRY_CACHE }}

.github/workflows/schedule.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ jobs:
9494
username: ${{ secrets.DOCKER_USERNAME }} # Ensure this secret is set
9595
password: ${{ secrets.DOCKER_PASSWORD }} # Ensure this secret is set
9696

97+
# Enable QEMU so amd64 runner can build arm64 too
98+
- name: Set up QEMU
99+
uses: docker/setup-qemu-action@v2
100+
97101
- name: Set up Docker Buildx
98102
uses: docker/setup-buildx-action@v2 # Set up Docker Buildx for advanced building
99103

@@ -109,6 +113,8 @@ jobs:
109113
context: modules/docker/mongodb # Path to the directory with the Dockerfile
110114
file: modules/docker/mongodb/Docker/dockerfile # Path to the Dockerfile
111115
push: true # Push the image to Docker Hub
116+
# Multi-arch only for mongodb
117+
platforms: linux/amd64,linux/arm64
112118
tags: ${{ secrets.DOCKER_USERNAME }}/mongodb:latest # Tag for the Docker image
113119
build-args: |
114120
DOCKER_REGISTRY_CACHE=${{ vars.DOCKER_REGISTRY_CACHE }}

modules/docker/mongodb/Docker/dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
ARG DOCKER_REGISTRY_CACHE
22
ARG IMAGE_OPENSUSELEAP
33
FROM $DOCKER_REGISTRY_CACHE/$IMAGE_OPENSUSELEAP
4+
ARG TARGETARCH
5+
ARG TARGETOS
6+
ENV TARGETARCH=${TARGETARCH}
7+
ENV TARGETOS=${TARGETOS}
8+
49

510
# Expose MongoDB port
611
EXPOSE 27017
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#!/bin/bash
22
cd $project_path/modules/docker/mongodb
3-
docker compose up -d --build --force-recreate
3+
case "$1" in
4+
arm)
5+
echo "[mongodb] Starting in ARM64 mode..."
6+
export DOCKER_DEFAULT_PLATFORM=linux/arm64
7+
export DOCKER_BUILDKIT=1
8+
export COMPOSE_DOCKER_CLI_BUILD=1
9+
docker compose up -d --build --force-recreate
10+
;;
11+
*)
12+
echo "[mongodb] Starting in native amd64 mode..."
13+
docker compose up -d --build --force-recreate
14+
unset DOCKER_DEFAULT_PLATFORM
15+
unset DOCKER_BUILDKIT
16+
unset COMPOSE_DOCKER_CLI_BUILD
17+
;;
18+
esac
419
cd

0 commit comments

Comments
 (0)