Skip to content

Commit

Permalink
Merge pull request #48 from nyanmisaka/fix-docker-target-platform
Browse files Browse the repository at this point in the history
Explicitly set the target platform of Docker builds
  • Loading branch information
joshuaboniface authored Nov 14, 2024
2 parents 543b323 + aef8d0f commit 878d8e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def build_docker(
DOTNET_ARCH = configurations["docker"]["archmaps"][_build_arch]["DOTNET_ARCH"]
QEMU_ARCH = configurations["docker"]["archmaps"][_build_arch]["QEMU_ARCH"]
IMAGE_ARCH = configurations["docker"]["archmaps"][_build_arch]["IMAGE_ARCH"]
TARGET_ARCH = configurations["docker"]["archmaps"][_build_arch]["TARGET_ARCH"]

# Use a unique docker image name for consistency
if is_stable:
Expand All @@ -327,10 +328,10 @@ def build_docker(

# Build the dockerfile
log(
f">>> {docker_build_cmd} --build-arg PACKAGE_ARCH={PACKAGE_ARCH} --build-arg DOTNET_ARCH={DOTNET_ARCH} --build-arg QEMU_ARCH={QEMU_ARCH} --build-arg IMAGE_ARCH={IMAGE_ARCH} --build-arg JELLYFIN_VERSION={jellyfin_version} --file {repo_root_dir}/{dockerfile} --tag {imagename} {repo_root_dir}"
f">>> {docker_build_cmd} --build-arg PACKAGE_ARCH={PACKAGE_ARCH} --build-arg DOTNET_ARCH={DOTNET_ARCH} --build-arg QEMU_ARCH={QEMU_ARCH} --build-arg IMAGE_ARCH={IMAGE_ARCH} --build-arg TARGET_ARCH={TARGET_ARCH} --build-arg JELLYFIN_VERSION={jellyfin_version} --file {repo_root_dir}/{dockerfile} --tag {imagename} {repo_root_dir}"
)
ret = os.system(
f"{docker_build_cmd} --build-arg PACKAGE_ARCH={PACKAGE_ARCH} --build-arg DOTNET_ARCH={DOTNET_ARCH} --build-arg QEMU_ARCH={QEMU_ARCH} --build-arg IMAGE_ARCH={IMAGE_ARCH} --build-arg JELLYFIN_VERSION={jellyfin_version} --file {repo_root_dir}/{dockerfile} --tag {imagename} {repo_root_dir}"
f"{docker_build_cmd} --build-arg PACKAGE_ARCH={PACKAGE_ARCH} --build-arg DOTNET_ARCH={DOTNET_ARCH} --build-arg QEMU_ARCH={QEMU_ARCH} --build-arg IMAGE_ARCH={IMAGE_ARCH} --build-arg TARGET_ARCH={TARGET_ARCH} --build-arg JELLYFIN_VERSION={jellyfin_version} --file {repo_root_dir}/{dockerfile} --tag {imagename} {repo_root_dir}"
)
if ret > 0:
exit(1)
Expand Down
3 changes: 3 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,19 @@ docker:
IMAGE_ARCH: amd64
PACKAGE_ARCH: amd64
QEMU_ARCH: x86_64
TARGET_ARCH: amd64
arm64:
DOTNET_ARCH: arm64
IMAGE_ARCH: arm64v8
PACKAGE_ARCH: arm64
QEMU_ARCH: aarch64
TARGET_ARCH: arm64/v8
armhf:
DOTNET_ARCH: arm
IMAGE_ARCH: arm32v7
PACKAGE_ARCH: armhf
QEMU_ARCH: arm
TARGET_ARCH: arm/v7
dockerfile: docker/Dockerfile
imagename: jellyfin/jellyfin

Expand Down
6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ ARG PACKAGE_ARCH
ARG DOTNET_ARCH
# QEMU architecture (x86_64, aarch64, arm), set by build script
ARG QEMU_ARCH
# Base Image archiecture (amd64, arm64v8, arm32v7), set by build script
# Base Image architecture (amd64, arm64v8, arm32v7), set by build script
ARG IMAGE_ARCH
# Target platform architecture (amd64, arm64/v8, arm/v7), set by build script
ARG TARGET_ARCH

# Jellyfin version
ARG JELLYFIN_VERSION
Expand Down Expand Up @@ -86,7 +88,7 @@ RUN dotnet publish Jellyfin.Server --configuration Release \
# Build the final combined image
#
FROM multiarch/qemu-user-static:x86_64-${QEMU_ARCH} as qemu
FROM ${IMAGE_ARCH}/debian:${OS_VERSION}-slim as combined
FROM --platform=linux/${TARGET_ARCH} ${IMAGE_ARCH}/debian:${OS_VERSION}-slim as combined

ARG OS_VERSION
ARG FFMPEG_PACKAGE
Expand Down

0 comments on commit 878d8e1

Please sign in to comment.