Skip to content

Commit

Permalink
build-or-download.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
amazy committed Jun 24, 2023
1 parent 836025b commit 51d0ed8
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/all-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,7 @@ jobs:
secrets:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_token: ${{ secrets.DOCKERHUB_TOKEN }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}


7 changes: 7 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ on:
required: true
docker_hub_token:
required: true
aws_access_key_id:
required: true
aws_secret_access_key:
required: true



jobs:
build-docker:
name: build-docker
runs-on: "ubuntu-latest"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
strategy:
fail-fast: false
matrix:
Expand Down
17 changes: 9 additions & 8 deletions docker/orthanc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ FROM osimis/orthanc-builder-base:vcpkg-azure-${BASE_IMAGE_TAG} as build-plugin-o
FROM orthanc-builder-base as build-orthanc

ARG ORTHANC_COMMIT_ID
RUN hg clone https://hg.orthanc-server.com/orthanc/ -r $ORTHANC_COMMIT_ID /sources
WORKDIR /build

# note: building with static DCMTK while waiting for Debian bullseye to update to latest DCMTK issues (we need DCMTK 3.6.7: https://www.hipaajournal.com/warning-issued-about-3-high-severity-vulnerabilities-in-offis-dicom-software/)
# also force latest OpenSSL (and therefore, we need to force static libcurl)
RUN cmake -DALLOW_DOWNLOADS=ON -DCMAKE_BUILD_TYPE:STRING=Release -DSTANDALONE_BUILD=ON -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DUSE_SYSTEM_CIVETWEB=OFF -DUSE_SYSTEM_DCMTK=OFF -DUSE_SYSTEM_OPENSSL=OFF -DUSE_SYSTEM_CURL=OFF /sources/OrthancServer
RUN make -j 4
RUN /build/UnitTests
RUN /scripts/build-or-download.sh baseImage=$BASE_IMAGE_TAG target=orthanc commitId=$ORTHANC_COMMIT_ID preferDownloads=1 enableUploads=1
# RUN hg clone https://hg.orthanc-server.com/orthanc/ -r $ORTHANC_COMMIT_ID /sources
# WORKDIR /build

# # note: building with static DCMTK while waiting for Debian bullseye to update to latest DCMTK issues (we need DCMTK 3.6.7: https://www.hipaajournal.com/warning-issued-about-3-high-severity-vulnerabilities-in-offis-dicom-software/)
# # also force latest OpenSSL (and therefore, we need to force static libcurl)
# RUN cmake -DALLOW_DOWNLOADS=ON -DCMAKE_BUILD_TYPE:STRING=Release -DSTANDALONE_BUILD=ON -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DUSE_SYSTEM_CIVETWEB=OFF -DUSE_SYSTEM_DCMTK=OFF -DUSE_SYSTEM_OPENSSL=OFF -DUSE_SYSTEM_CURL=OFF /sources/OrthancServer
# RUN make -j 4
# RUN /build/UnitTests

########################## Orthanc GDCM

Expand Down
7 changes: 7 additions & 0 deletions docker/orthanc/Dockerfile.builder-base
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN apt-get --assume-yes install default-libmysqlclient-dev
# RUN apt-get --assume-yes install libmariadb-dev

RUN apt-get --assume-yes install cmake
RUN apt-get --assume-yes install awscli
# # install a recent cmake version (required later by recent vcpkg versions that we don't use now !)
# WORKDIR /tmp
# RUN wget https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1.tar.gz
Expand All @@ -46,3 +47,9 @@ RUN cmake --version

RUN mkdir -p /sources
RUN mkdir -p /build
RUN mkdir -p /scripts

ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY

COPY build-or-download.sh /scripts
110 changes: 110 additions & 0 deletions docker/orthanc/build-or-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env bash
set -ex

# This script is only meant to be run inside Docker during the build process.
# It builds all Orthanc components individually and possibly try to download
# the component before if it has already been built.
# It possibly also uploads the components to orthanc.osimis.io

# example
# for a CI build
# ./build-or-download baseImage=bullseye-20230522-slim commitId=xxxx target=orthanc preferDownloads=1 enableUploads=1
# for a local build
# ./build-or-download.sh target=orthanc baseImage=test commitId=68e15471b408 preferDownloads=1 enableUploads=1


# default arg values
target=unknown
preferDownloads=0
enableUploads=0
baseImage=unknown
commitId=xxx


for argument in "$@"
do
key=$(echo $argument | cut -f1 -d=)

key_length=${#key}
value="${argument:$key_length+1}"

export "$key"="$value"
done

echo "target = $target"
echo "preferDownloads = $preferDownloads"
echo "enableUploads = $enableUploads"
echo "baseImage = $baseImage"
echo "commitId = $commitId"

# while debugging the script on your local machine, you might want to change these paths
buildRootPath=/tmp/build
sourcesRootPath=/tmp/sources
dl=0

# rewrite pushd/popd such that they do not produce any output in bash functions (https://stackoverflow.com/questions/25288194/dont-display-pushd-popd-stack-across-several-bash-scripts-quiet-pushd-popd)
pushd () {
command pushd "$@" > /dev/null
}

popd () {
command popd "$@" > /dev/null
}

download() { # $1 file

mkdir -p $buildRootPath
already_built=$(($(curl --silent -I https://orthanc.osimis.io/docker-builds/$baseImage/$commitId-$1 | grep -E "^HTTP" | awk -F " " '{print $2}') == 200))
if [[ $already_built == 1 ]]; then
wget "https://orthanc.osimis.io/docker-builds/$baseImage/$commitId-$1" --output-document $buildRootPath/$1
echo 0
else
echo 1
fi
}

upload() { # $1 file
echo "uploading $1";

aws s3 --region eu-west-1 cp $buildRootPath/$1 s3://orthanc.osimis.io/docker-builds/$baseImage/$commitId-$1 --cache-control=max-age=1
}

if [[ $target == "orthanc" ]]; then

dl=$(expr $dl + $(download Orthanc))
dl=$(expr $dl + $(download libModalityWorklists.so))
dl=$(expr $dl + $(download libServeFolders.so))
dl=$(expr $dl + $(download libHousekeeper.so))
dl=$(expr $dl + $(download libConnectivityChecks.so))
dl=$(expr $dl + $(download libDelayedDeletion.so))
dl=$(expr $dl + $(download libMultitenantDicom.so))

if [[ $dl != 0 ]]; then

hg clone https://hg.orthanc-server.com/orthanc/ -r $commitId $sourcesRootPath
pushd $buildRootPath

# note: building with static DCMTK while waiting for Debian bullseye to update to latest DCMTK issues (we need DCMTK 3.6.7: https://www.hipaajournal.com/warning-issued-about-3-high-severity-vulnerabilities-in-offis-dicom-software/)
# also force latest OpenSSL (and therefore, we need to force static libcurl)
cmake -DALLOW_DOWNLOADS=ON -DCMAKE_BUILD_TYPE:STRING=Release -DSTANDALONE_BUILD=ON -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DUSE_SYSTEM_CIVETWEB=OFF -DUSE_SYSTEM_DCMTK=OFF -DUSE_SYSTEM_OPENSSL=OFF -DUSE_SYSTEM_CURL=OFF $sourcesRootPath/OrthancServer
make -j 4
$buildRootPath/UnitTests

upload Orthanc
fi

elif [[ $target == "orthanc-authorization" ]]; then

dl=$(expr $dl + $(download libOrthancAuthorization.so))

if [[ $dl != 0 ]]; then

hg clone https://hg.orthanc-server.com/orthanc-authorization/ -r $commitId $sourcesRootPath
pushd $buildRootPath
cmake -DALLOW_DOWNLOADS=ON -DCMAKE_BUILD_TYPE:STRING=Release -DUSE_SYSTEM_GOOGLE_TEST=ON -DUSE_SYSTEM_ORTHANC_SDK=OFF $sourcesRootPath
make -j 4
$buildRootPath/UnitTests

upload libOrthancAuthorization.so
fi
fi
2 changes: 2 additions & 0 deletions local-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ for target in $buildTargets; do
--build-arg ORTHANC_VOLVIEW_COMMIT_ID=$ORTHANC_VOLVIEW_COMMIT_ID \
--build-arg ORTHANC_OHIF_COMMIT_ID=$ORTHANC_OHIF_COMMIT_ID \
--build-arg BASE_IMAGE_TAG=$BASE_BUILDER_IMAGE_TAG \
--build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--build-arg AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
$from_cache_arg \
$to_cache_arg \
$push_load_arg \
Expand Down

0 comments on commit 51d0ed8

Please sign in to comment.