Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): build multiarch amd64,arm64 images #1104

Merged
merged 13 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defaults:
jobs:

test-cypress:
name: itk-wasm reference packages browser tests
name: browser tests
runs-on: ubuntu-22.04
strategy:
max-parallel: 3
Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:
pnpm run --aggregate-output --filter "@itk-wasm/${{ matrix.package }}-build" test:data:download

- name: Test with Chrome
if: ${{ matrix.package != 'dicom' }}
uses: cypress-io/github-action@v6
with:
browser: chrome
Expand All @@ -71,7 +72,7 @@ jobs:
if-no-files-found: ignore

- name: Test with Firefox
if: ${{ matrix.package != 'dicom' }}
if: ${{ matrix.package != 'dicom' && matrix.package != 'mesh-io' && matrix.package != 'image-io' && matrix.package != 'downsample' }}
uses: cypress-io/github-action@v6
with:
browser: firefox
Expand Down Expand Up @@ -109,6 +110,14 @@ jobs:
version: 8
run_install: true

- name: Build itk-wasm
run: |
pnpm run --aggregate-output --filter itk-wasm build

- name: Build build:gen:typescript
run: |
pnpm run --aggregate-output build:gen:typescript

- name: Build itk-wasm
run: |
pnpm run --aggregate-output --filter itk-wasm build
Expand All @@ -134,17 +143,16 @@ jobs:
path: packages/core/typescript/itk-wasm/cypress/videos
if-no-files-found: ignore

- name: Test with Firefox
if: ${{ matrix.package != 'dicom' }}
uses: cypress-io/github-action@v6
with:
browser: firefox
working-directory: packages/core/typescript/itk-wasm
install: false
config: video=true
start: pnpm start
wait-on: 'http://localhost:5173'
wait-on-timeout: 360
#- name: Test with Firefox
#uses: cypress-io/github-action@v6
#with:
#browser: firefox
#working-directory: packages/core/typescript/itk-wasm
#install: false
#config: video=true
#start: pnpm start
#wait-on: 'http://localhost:5173'
#wait-on-timeout: 360

- uses: actions/upload-artifact@v4
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
OCI_EXE: docker

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/javascript-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ defaults:
run:
shell: bash -leo pipefail {0} {0}

env:
OCI_EXE: docker

jobs:
itkwasm-node-js:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/toolchains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Toolchains

on: [push,pull_request]

env:
OCI_EXE: docker

jobs:
build-itk-wasm-base:
name: "Build itk-wasm-base"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ defaults:
run:
shell: bash -leo pipefail {0} {0}

env:
OCI_EXE: docker

jobs:
build-test:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -36,4 +39,4 @@ jobs:

- name: Test
run: |
pnpm run --aggregate-output test:wasi
pnpm run --aggregate-output test:wasi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const defaultImageTag = '20240305-51a93b5b'
const defaultImageTag = '20240408-db9afd60'
export default defaultImageTag
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/docker/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pnpm i
#
# echo $(date '+%Y%m%d')-$(git rev-parse --short HEAD)
#
./src/docker/build.sh --with-debug
./src/docker/build.sh --with-debug --multiarch
# DockerHub credential environmental variables must be set
./src/docker/push.sh
git add -- packages/core/typescript/itk-wasm/src/cli/default-image-tag.js
Expand Down
6 changes: 3 additions & 3 deletions src/docker/itk-wasm-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BASE_IMAGE=dockcross/web-wasm
FROM $BASE_IMAGE:20230622-7312d8f
ARG BASE_IMAGE=docker.io/dockcross/web-wasm
FROM $BASE_IMAGE:20240326-00e7558
ARG BASE_IMAGE

LABEL maintainer="Matt McCormick <matt.mccormick@kitware.com>"
Expand Down Expand Up @@ -93,7 +93,7 @@ RUN mkdir ITK-build && \
-DDO_NOT_BUILD_ITK_TEST_DRIVER:BOOL=ON \
-DOPJ_USE_THREAD:BOOL=OFF \
-DDCMTK_WITH_THREADS:BOOL=OFF \
-DDCMTK_BUILD_APPS:BOOL=ON \
-DDCMTK_BUILD_APPS:BOOL=OFF \
-DNO_FLOAT_EXCEPTIONS:BOOL=ON \
../ITK && \
ninja && \
Expand Down
49 changes: 37 additions & 12 deletions src/docker/itk-wasm-base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
debug=false
wasi=false
version_tag=false
build_cmd="build"
tag_flag="--tag"
create_manifest=false
for param; do
if [[ $param == '--with-debug' ]]; then
debug=true
elif [[ $param == '--with-wasi' ]]; then
wasi=true
elif [[ $param == '--multiarch' ]]; then
# Newer buildah (1.28.2) required for multiarch
exe=buildah
build_cmd="build --platform linux/amd64,linux/arm64"
tag_flag="--manifest"
create_manifest=true
elif [[ $param == '--version-tag' ]]; then
version_tag=true
else
Expand All @@ -36,15 +45,31 @@ emscripten_debug_c_flags="-fno-lto -Wno-warn-absolute-paths"
wasi_debug_ld_flags="-fno-lto -lwasi-emulated-process-clocks -lwasi-emulated-signal -lc-printscan-long-double"
wasi_debug_c_flags="-fno-lto -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL"

$exe build -t itkwasm/emscripten-base:latest \
if $create_manifest; then
for list in itkwasm/emscripten-base:latest \
itkwasm/emscripten-base:${TAG} \
itkwasm/emscripten-base:latest-debug \
itkwasm/emscripten-base:${TAG}-debug \
itkwasm/wasi-base:latest \
itkwasm/wasi-base:${TAG} \
itkwasm/wasi-base:latest-debug \
itkwasm/wasi-base:${TAG}-debug; do
if $(buildah manifest exists $list); then
buildah manifest rm $list
fi
buildah manifest create $list
done
fi

$exe $build_cmd $tag_flag itkwasm/emscripten-base:latest \
--build-arg IMAGE=itkwasm/emscripten-base \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/emscripten-base:${TAG} \
$exe $build_cmd $tag_flag itkwasm/emscripten-base:${TAG} \
--build-arg IMAGE=itkwasm/emscripten-base \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg VERSION=${TAG} \
Expand All @@ -55,25 +80,25 @@ if $version_tag; then
fi

if $wasi; then
$exe build -t itkwasm/wasi-base:latest \
$exe $build_cmd $tag_flag itkwasm/wasi-base:latest \
--build-arg IMAGE=itkwasm/wasi-base \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg BASE_IMAGE=dockcross/web-wasi \
--build-arg BASE_IMAGE=docker.io/dockcross/web-wasi \
--build-arg LDFLAGS="${wasi_ld_flags}" \
--build-arg CFLAGS="${wasi_c_flags}" \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/wasi-base:${TAG} \
$exe $build_cmd $tag_flag itkwasm/wasi-base:${TAG} \
--build-arg IMAGE=itkwasm/wasi-base \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg VERSION=${TAG} \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg BASE_IMAGE=dockcross/web-wasi \
--build-arg BASE_IMAGE=docker.io/dockcross/web-wasi \
--build-arg LDFLAGS="${wasi_ld_flags}" \
--build-arg CFLAGS="${wasi_c_flags}" \
$script_dir $@
Expand All @@ -82,7 +107,7 @@ fi


if $debug; then
$exe build -t itkwasm/emscripten-base:latest-debug \
$exe $build_cmd $tag_flag itkwasm/emscripten-base:latest-debug \
--build-arg IMAGE=itkwasm/emscripten-base \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg USE_DCMTK=OFF \
Expand All @@ -93,7 +118,7 @@ if $debug; then
--build-arg CFLAGS="${emscripten_debug_c_flags}" \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/emscripten-base:${TAG}-debug \
$exe $build_cmd $tag_flag itkwasm/emscripten-base:${TAG}-debug \
--build-arg IMAGE=itkwasm/emscripten-base \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg USE_DCMTK=OFF \
Expand All @@ -106,25 +131,25 @@ if $debug; then
$script_dir $@
fi
if $wasi; then
$exe build -t itkwasm/wasi-base:latest-debug \
$exe $build_cmd $tag_flag itkwasm/wasi-base:latest-debug \
--build-arg IMAGE=itkwasm/wasi-base \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg BASE_IMAGE=dockcross/web-wasi \
--build-arg BASE_IMAGE=docker.io/dockcross/web-wasi \
--build-arg LDFLAGS="${wasi_debug_ld_flags}" \
--build-arg CFLAGS="${wasi_debug_c_flags}" \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/wasi-base:${TAG}-debug \
$exe $build_cmd $tag_flag itkwasm/wasi-base:${TAG}-debug \
--build-arg IMAGE=itkwasm/wasi-base \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg VERSION=${TAG} \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg BASE_IMAGE=dockcross/web-wasi \
--build-arg BASE_IMAGE=docker.io/dockcross/web-wasi \
--build-arg LDFLAGS="${wasi_debug_ld_flags}" \
--build-arg CFLAGS="${wasi_debug_c_flags}" \
$script_dir $@
Expand Down
46 changes: 36 additions & 10 deletions src/docker/itk-wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
debug=false
wasi=false
version_tag=false
build_cmd="build"
tag_flag="--tag"
create_manifest=false
for param; do
if [[ $param == '--with-debug' ]]; then
debug=true
elif [[ $param == '--with-wasi' ]]; then
wasi=true
elif [[ $param == '--multiarch' ]]; then
# Newer buildah (1.28.2) required for multiarch
exe=buildah
build_cmd="build --platform linux/amd64,linux/arm64"
tag_flag="--manifest"
create_manifest=true
elif [[ $param == '--version-tag' ]]; then
version_tag=true
else
Expand All @@ -37,17 +46,36 @@ for param; do
done
set -- "${newparams[@]}" # overwrites the original positional params

$exe build -t itkwasm/emscripten:latest \
if $create_manifest; then
for list in itk-wasm/emscripten:latest \
itk-wasm/emscripten:${TAG} \
itk-wasm/emscripten:latest-debug \
itk-wasm/emscripten:${TAG}-debug \
itk-wasm/wasi:latest \
itk-wasm/wasi:${TAG} \
itk-wasm/wasi:latest-debug \
itk-wasm/wasi:${TAG}-debug; do
if $(buildah manifest exists $list); then
buildah manifest rm $list
fi
buildah manifest create $list
done
fi

$exe $build_cmd --pull=false $tag_flag itkwasm/emscripten:latest \
--build-arg IMAGE=itkwasm/emscripten \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg BASE_IMAGE=itkwasm/emscripten-base \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/emscripten:${TAG} \
$exe $build_cmd --pull=false $tag_flag itkwasm/emscripten:${TAG} \
--build-arg IMAGE=itkwasm/emscripten \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg BASE_IMAGE=itkwasm/emscripten-base \
--build-arg BASE_TAG=${TAG} \
--build-arg VERSION=${TAG} \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
Expand All @@ -56,7 +84,7 @@ if $version_tag; then
fi

if $wasi; then
$exe build -t itkwasm/wasi:latest \
$exe $build_cmd --pull=false $tag_flag itkwasm/wasi:latest \
--build-arg IMAGE=itkwasm/wasi \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg BASE_IMAGE=itkwasm/wasi-base \
Expand All @@ -65,7 +93,7 @@ if $wasi; then
--build-arg BUILD_DATE=${BUILD_DATE} \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/wasi:${TAG} \
$exe $build_cmd --pull=false $tag_flag itkwasm/wasi:${TAG} \
--build-arg IMAGE=itkwasm/wasi \
--build-arg CMAKE_BUILD_TYPE=Release \
--build-arg VERSION=${TAG} \
Expand All @@ -79,16 +107,15 @@ if $wasi; then
fi

if $debug; then
$exe build -t itkwasm/emscripten:latest-debug \
$exe $build_cmd --pull=false $tag_flag itkwasm/emscripten:latest-debug \
--build-arg IMAGE=itkwasm/emscripten \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg BASE_TAG=${TAG}-debug \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/emscripten:${TAG}-debug \
$exe $build_cmd --pull=false $tag_flag itkwasm/emscripten:${TAG}-debug \
--build-arg IMAGE=itkwasm/emscripten \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg VERSION=${TAG}-debug \
Expand All @@ -99,17 +126,16 @@ if $debug; then
$script_dir $@
fi
if $wasi; then
$exe build -t itkwasm/wasi:latest-debug \
$exe $build_cmd --pull=false $tag_flag itkwasm/wasi:latest-debug \
--build-arg IMAGE=itkwasm/wasi \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg BASE_IMAGE=itkwasm/wasi-base \
--build-arg BASE_TAG=${TAG}-debug \
--build-arg VCS_REF=${VCS_REF} \
--build-arg VCS_URL=${VCS_URL} \
--build-arg BUILD_DATE=${BUILD_DATE} \
$script_dir $@
if $version_tag; then
$exe build -t itkwasm/wasi:${TAG}-debug \
$exe $build_cmd --pull=false $tag_flag itkwasm/wasi:${TAG}-debug \
--build-arg IMAGE=itkwasm/wasi \
--build-arg CMAKE_BUILD_TYPE=Debug \
--build-arg VERSION=${TAG} \
Expand Down
Loading
Loading