build: simplify detection of the target platform

It can be done within the container, rather than having to compute it in
the Makefile and then pass it as an argument.
This commit is contained in:
Saúl Ibarra Corretgé
2024-01-15 11:48:36 +01:00
parent 21f04ead6e
commit d31e164656
4 changed files with 15 additions and 32 deletions

View File

@@ -2,20 +2,9 @@ FORCE_REBUILD ?= 0
JITSI_RELEASE ?= stable JITSI_RELEASE ?= stable
JITSI_BUILD ?= unstable JITSI_BUILD ?= unstable
JITSI_REPO ?= jitsi JITSI_REPO ?= jitsi
NATIVE_ARCH ?= $(shell uname -m)
JITSI_SERVICES := base base-java web prosody jicofo jvb jigasi jibri JITSI_SERVICES := base base-java web prosody jicofo jvb jigasi jibri
ifeq ($(NATIVE_ARCH),x86_64)
TARGETPLATFORM := linux/amd64
else ifeq ($(NATIVE_ARCH),aarch64)
TARGETPLATFORM := linux/arm64
else ifeq ($(NATIVE_ARCH),arm64)
TARGETPLATFORM := linux/arm64
else
TARGETPLATFORM := unsupported
endif
BUILD_ARGS := \ BUILD_ARGS := \
--build-arg JITSI_REPO=$(JITSI_REPO) \ --build-arg JITSI_REPO=$(JITSI_REPO) \
--build-arg JITSI_RELEASE=$(JITSI_RELEASE) --build-arg JITSI_RELEASE=$(JITSI_RELEASE)
@@ -43,19 +32,12 @@ buildx:
$(addprefix buildx_,$(JITSI_SERVICES)): $(addprefix buildx_,$(JITSI_SERVICES)):
$(MAKE) --no-print-directory JITSI_SERVICE=$(patsubst buildx_%,%,$@) buildx $(MAKE) --no-print-directory JITSI_SERVICE=$(patsubst buildx_%,%,$@) buildx
ifeq ($(TARGETPLATFORM), unsupported)
build: build:
@echo "Unsupported native architecture"
@exit 1
else
build:
@echo "Building for $(TARGETPLATFORM)"
docker build \ docker build \
$(BUILD_ARGS) --build-arg TARGETPLATFORM=$(TARGETPLATFORM) \ $(BUILD_ARGS) \
--progress plain \ --progress plain \
--tag $(JITSI_REPO)/$(JITSI_SERVICE) \ --tag $(JITSI_REPO)/$(JITSI_SERVICE) \
$(JITSI_SERVICE) $(JITSI_SERVICE)
endif
$(addprefix build_,$(JITSI_SERVICES)): $(addprefix build_,$(JITSI_SERVICES)):
$(MAKE) --no-print-directory JITSI_SERVICE=$(patsubst build_%,%,$@) build $(MAKE) --no-print-directory JITSI_SERVICE=$(patsubst build_%,%,$@) build

View File

@@ -1,18 +1,16 @@
FROM docker.io/library/debian:bullseye-slim FROM docker.io/library/debian:bullseye-slim
ARG JITSI_RELEASE=stable ARG JITSI_RELEASE=stable
ARG TARGETPLATFORM
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
COPY rootfs / COPY rootfs /
RUN case ${TARGETPLATFORM} in \ RUN \
"linux/amd64") TPL_ARCH=amd64 ;; \ dpkgArch="$(dpkg --print-architecture)" && \
"linux/arm64") TPL_ARCH=arm64 ;; \ case "${dpkgArch##*-}" in \
esac && \ "amd64") TPL_ARCH=amd64; S6_ARCH=amd64 ;; \
case ${TARGETPLATFORM} in \ "arm64") TPL_ARCH=arm64; S6_ARCH=aarch64 ;; \
"linux/amd64") S6_ARCH=amd64 ;; \ *) echo "unsupported architecture"; exit 1 ;; \
"linux/arm64") S6_ARCH=aarch64 ;; \
esac && \ esac && \
apt-dpkg-wrap apt-get update && \ apt-dpkg-wrap apt-get update && \
apt-dpkg-wrap apt-get install -y apt-transport-https apt-utils ca-certificates gnupg wget && \ apt-dpkg-wrap apt-get install -y apt-transport-https apt-utils ca-certificates gnupg wget && \

View File

@@ -8,7 +8,6 @@ LABEL org.opencontainers.image.url="https://github.com/jitsi/jibri"
LABEL org.opencontainers.image.source="https://github.com/jitsi/docker-jitsi-meet" LABEL org.opencontainers.image.source="https://github.com/jitsi/docker-jitsi-meet"
LABEL org.opencontainers.image.documentation="https://jitsi.github.io/handbook/" LABEL org.opencontainers.image.documentation="https://jitsi.github.io/handbook/"
ARG TARGETPLATFORM
ARG USE_CHROMIUM=0 ARG USE_CHROMIUM=0
#ARG CHROME_RELEASE=latest #ARG CHROME_RELEASE=latest
# https://googlechromelabs.github.io/chrome-for-testing/ # https://googlechromelabs.github.io/chrome-for-testing/
@@ -21,9 +20,11 @@ RUN apt-dpkg-wrap apt-get update && \
/usr/bin/install-chrome.sh && \ /usr/bin/install-chrome.sh && \
apt-cleanup && \ apt-cleanup && \
adduser jibri rtkit && \ adduser jibri rtkit && \
case ${TARGETPLATFORM} in \ dpkgArch="$(dpkg --print-architecture)" && \
"linux/amd64") SC_ARCH=x86_64 ;; \ case "${dpkgArch##*-}" in \
"linux/arm64") SC_ARCH=aarch64 ;; \ "amd64") SC_ARCH=x86_64 ;; \
"arm64") SC_ARCH=aarch64 ;; \
*) echo "unsupported architecture"; exit 1 ;; \
esac && \ esac && \
wget -qO /usr/bin/shm-check https://github.com/saghul/shm-check/releases/download/v1.0.0/shm-check-${SC_ARCH} && \ wget -qO /usr/bin/shm-check https://github.com/saghul/shm-check/releases/download/v1.0.0/shm-check-${SC_ARCH} && \
chmod +x /usr/bin/shm-check chmod +x /usr/bin/shm-check

View File

@@ -2,7 +2,9 @@
set -o pipefail -xeu set -o pipefail -xeu
if [ "${USE_CHROMIUM}" = 1 -o "${TARGETPLATFORM}" = "linux/arm64" ]; then dpkgArch="$(dpkg --print-architecture)"
if [ "${USE_CHROMIUM}" = 1 -o "${dpkgArch##*-}" = "arm64" ]; then
echo "Using Debian's Chromium" echo "Using Debian's Chromium"
apt-dpkg-wrap apt-get install -y chromium chromium-driver chromium-sandbox apt-dpkg-wrap apt-get install -y chromium chromium-driver chromium-sandbox
chromium --version chromium --version