Skip to content
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
11 changes: 8 additions & 3 deletions src/docker/itk-wasm-base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ if [[ -n "$local_itk" ]]; then
local_itk_build_arg="--build-arg USE_LOCAL_ITK=1"
fi

# Cleanup function to restore ITKLocalCopy to placeholder state
cleanup_local_itk() {
# Generate environment variables file for Docker
"$script_dir/generate-env-vars.sh"

# Cleanup function to restore ITKLocalCopy to placeholder state and remove generated files
cleanup_build_artifacts() {
if [[ -n "$local_itk" ]]; then
rm -rf "$script_dir/ITKLocalCopy"/*
touch "$script_dir/ITKLocalCopy/.gitkeep"
fi
# Remove generated env vars file
rm -f "$script_dir/itk_wasm_env_vars.sh"
}
trap cleanup_local_itk EXIT
trap cleanup_build_artifacts EXIT

$exe $build_cmd $tag_flag quay.io/itkwasm/emscripten-base:latest-$host_arch \
--build-arg IMAGE=quay.io/itkwasm/emscripten-base \
Expand Down
44 changes: 44 additions & 0 deletions src/docker/itk-wasm-base/generate-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# Generate itk_wasm_env_vars.sh for use in Docker builds
# This script sources the root itk_wasm_env.bash and extracts only
# the variables needed by the Dockerfile

set -eo pipefail

script_dir="$(cd "$(dirname "$0")" && pwd)"
root_dir="$(cd "$script_dir/../../.." && pwd)"

# Source the main environment file
# Note: We need to handle the fact that itk_wasm_env.bash tries to parse
# package.json files which may not work in all contexts
export ITK_WASM_DEV_DOCKER_TAG="${ITK_WASM_DEV_DOCKER_TAG:-latest}"

# Extract the core variables we need
source "$root_dir/itk_wasm_env.bash" 2>/dev/null || {
# If sourcing fails (e.g., due to jq commands), extract manually
ITK_WASM_DCMTK_REPOSITORY="${ITK_WASM_DCMTK_REPOSITORY:-https://github.com/InsightSoftwareConsortium/DCMTK}"
ITK_WASM_DCMTK_GIT_TAG="${ITK_WASM_DCMTK_GIT_TAG:-2fe4dacbe9c343dba350fcff6eab365241636623}"
ITK_WASM_ITK_REPOSITORY="${ITK_WASM_ITK_REPOSITORY:-https://github.com/thewtex/ITK}"
ITK_WASM_ITK_BRANCH="${ITK_WASM_ITK_BRANCH:-itkwasm-2025-03-19-25d3162371}"
}

# Generate the env vars file for Docker
cat > "$script_dir/itk_wasm_env_vars.sh" << EOF
#!/usr/bin/env sh
# Auto-generated by generate-env-vars.sh - DO NOT EDIT
# Generated from: $root_dir/itk_wasm_env.bash

export ITK_WASM_DCMTK_REPOSITORY="${ITK_WASM_DCMTK_REPOSITORY}"
export ITK_WASM_DCMTK_GIT_TAG="${ITK_WASM_DCMTK_GIT_TAG}"
export ITK_WASM_ITK_REPOSITORY="${ITK_WASM_ITK_REPOSITORY}"
export ITK_WASM_ITK_BRANCH="${ITK_WASM_ITK_BRANCH}"
EOF

chmod +x "$script_dir/itk_wasm_env_vars.sh"

echo "Generated $script_dir/itk_wasm_env_vars.sh with:"
echo " ITK_WASM_ITK_REPOSITORY=${ITK_WASM_ITK_REPOSITORY}"
echo " ITK_WASM_ITK_BRANCH=${ITK_WASM_ITK_BRANCH}"
echo " ITK_WASM_DCMTK_REPOSITORY=${ITK_WASM_DCMTK_REPOSITORY}"
echo " ITK_WASM_DCMTK_GIT_TAG=${ITK_WASM_DCMTK_GIT_TAG}"
Loading