Skip to content

Commit 3b21f8f

Browse files
committed
chore(build): add support for multi-arch container
Allows to build a container image for i386 and arm32. Additionally, using an explicit registry, so that it's compatible with Podman out of the box.
1 parent d562e99 commit 3b21f8f

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/echo run with: docker build . -f
22
# -*- coding: utf-8 -*-
33

4-
FROM arm32v7/debian:stretch AS base
5-
ENV target_debian_arch=armhf
4+
ARG ARCH=arm32v7
5+
ARG TARGET_DEBIAN_ARCH=armhf
6+
7+
FROM docker.io/${ARCH}/debian:stretch AS base
8+
ARG TARGET_DEBIAN_ARCH=armhf
9+
ENV target_debian_arch=${TARGET_DEBIAN_ARCH}
610

711
LABEL maintainer="Laudin Molina Troconis <laudin.molinatroconis@silabs.com>"
812

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
services:
44
dev:
5-
image: zipgateway-dev
5+
image: zipgateway-dev-${ARCH:-arm32v7}
66
build:
77
context: .
88
target: dev
9+
args:
10+
ARCH: ${ARCH:-arm32v7}
11+
TARGET_DEBIAN_ARCH: ${TARGET_DEBIAN_ARCH:-armhf}
912
volumes:
1013
- .:/usr/local/src/zipgateway
1114
working_dir: /usr/local/src/zipgateway
@@ -18,6 +21,9 @@ services:
1821
build:
1922
context: .
2023
target: runtime
24+
args:
25+
ARCH: ${ARCH:-arm32v7}
26+
TARGET_DEBIAN_ARCH: ${TARGET_DEBIAN_ARCH:-armhf}
2127
command: tests
2228
devices:
2329
- /dev/ttyACM0:/dev/ttyACM0

helper.mk

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ default: help all
1111
SELF?=${CURDIR}/helper.mk
1212
sudo?=sudo
1313
build_dir?=build
14+
compose?=docker-compose
1415

1516
# TODO: adapt for arm and support 64bits
1617
target_debian_arch?=$(shell dpkg --print-architecture || echo 'i386')
1718

19+
# Map Debian arch name to Docker image arch prefix
20+
docker_arch_armhf=arm32v7
21+
docker_arch_i386=i386
22+
docker_arch?=$(docker_arch_${target_debian_arch})
23+
1824
packages?=make cmake time file git sudo
1925
packages+=build-essential pkg-config bison flex python
2026
packages+=libusb-1.0-0-dev libssl-dev libxml2-dev libjson-c-dev
@@ -130,8 +136,17 @@ tests: ${build_dir}
130136
cd ${build_dir} && ctest V=1
131137

132138
docker-compose/up: docker-compose.yml
133-
docker version
134-
docker-compose --version
135-
docker-compose up --build
139+
${compose} --version
140+
ARCH=${docker_arch} TARGET_DEBIAN_ARCH=${target_debian_arch} \
141+
${compose} up --build
136142

137143
docker/run: docker-compose/up
144+
145+
docker/build/dev: docker-compose.yml
146+
${compose} --version
147+
ARCH=${docker_arch} TARGET_DEBIAN_ARCH=${target_debian_arch} \
148+
${compose} up dev --build
149+
150+
docker/run/dev: docker-compose.yml
151+
ARCH=${docker_arch} TARGET_DEBIAN_ARCH=${target_debian_arch} \
152+
${compose} run dev

0 commit comments

Comments
 (0)