Skip to content

Commit

Permalink
Switch to multi-arch build for docker container. (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
r12f authored Aug 6, 2022
1 parent 01eb201 commit e3a6fa7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/azure-pipeline/workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ stages:

- script: just pack-docker-all
displayName: Pack divoom docker package sources
condition: and(succeeded(), eq(variables['target_os'], 'linux'))
condition: and(succeeded(), eq(variables['target_os'], 'linux'), eq(variables['target_arch'], 'x86_64'))
env:
BUILD_PROFILE: "release"
BUILD_ARCH: $(target_arch)
Expand Down
7 changes: 5 additions & 2 deletions build/package-templates/docker/divoom_gateway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#
# Build container
#
FROM busybox AS builder
FROM --platform=$BUILDPLATFORM busybox AS builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM

# Install fonts
RUN mkdir -p /usr/share/fonts/truetype/
Expand All @@ -21,7 +24,7 @@ RUN if [ -f *.ttf ]; then install -m644 *.ttf /usr/share/fonts/truetype; fi
RUN if [ -f *.ttf ]; then rm ./*.ttf; fi

# Install divoom-gateway binary
RUN wget http://github.com/r12f/divoom/releases/download/{build.version}/divoom-gateway.{build.version}.linux.{build.arch}.tar.gz -O divoom-gateway.tar.gz
RUN case "${TARGETPLATFORM}" in "linux/386") PKG_ARCH="x86"; ;; "linux/amd64") PKG_ARCH="x64"; ;; "linux/arm64") PKG_ARCH="arm64"; ;; *) PKG_ARCH="arm"; ;; esac; wget "http://github.com/r12f/divoom/releases/download/{build.version}/divoom-gateway.{build.version}.linux.${PKG_ARCH}.tar.gz" -O divoom-gateway.tar.gz
RUN tar zxvf divoom-gateway.tar.gz
RUN rm divoom-gateway.tar.gz

Expand Down
2 changes: 1 addition & 1 deletion build/post-build/post-build.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pack-docker:
if (Test-Path "{{RELEASE_DOCKER_FOLDER}}") { Remove-Item -Path "{{RELEASE_DOCKER_FOLDER}}" -Recurse -Force }
New-Item -ItemType Directory -Path "{{RELEASE_DOCKER_FOLDER}}" -Force | Out-Null

Get-ChildItem ./{{BUILD_FOLDER_PREFIX}}*/*/docker-source/* -Attributes Directory | Copy-Item -Destination "{{RELEASE_DOCKER_FOLDER}}" -Recurse -PassThru
Get-ChildItem ./{{BUILD_FOLDER_PREFIX}}linuxx64/*/docker-source/* -Attributes Directory | Copy-Item -Destination "{{RELEASE_DOCKER_FOLDER}}" -Recurse -PassThru

#
# Prepare packages for crate.io release
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ pack-docker PACKAGE="divoom_gateway":
@Write-Host "Current invocation directory: {{invocation_directory()}}"

if (Test-Path "{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source") { Remove-Item -Path "{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source" -Recurse -Force }
New-Item -ItemType Directory -Path "{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source/{{replace(PACKAGE, '_', '-')}}.{{BUILD_ARCH}}" -Force | Out-Null
New-Item -ItemType Directory -Path "{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source/{{replace(PACKAGE, '_', '-')}}" -Force | Out-Null

just eval-template "{{justfile_directory()}}/build/package-templates/docker/{{PACKAGE}}.Dockerfile" \
"{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source/{{replace(PACKAGE, '_', '-')}}.{{BUILD_ARCH}}/Dockerfile" \
"{{PUBLISH_DIR}}/{{PACKAGE}}/docker-source/{{replace(PACKAGE, '_', '-')}}/Dockerfile" \
"{{PUBLISH_DIR}}/{{PACKAGE}}/template-parameters" \
"{{PUBLISH_CHECKSUMS_DIR}}"

Expand Down

0 comments on commit e3a6fa7

Please sign in to comment.