From 26b9f216f47e44422f962a3bcc09bd06551540ad Mon Sep 17 00:00:00 2001 From: jackschofield23 <56344499+jackschofield23@users.noreply.github.com> Date: Tue, 9 Aug 2022 15:12:46 +0100 Subject: [PATCH] add task manager dockerfile (#309) * add task manager dockerfile Signed-off-by: Jack Schofield --- .github/workflows/publish.yml | 32 +++++- TaskManager.Dockerfile | 60 ++++++++++++ Dockerfile => WorkflowManager.Dockerfile | 120 +++++++++++------------ build.sh | 7 +- 4 files changed, 153 insertions(+), 66 deletions(-) create mode 100644 TaskManager.Dockerfile rename Dockerfile => WorkflowManager.Dockerfile (97%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2026ccd50..a458eb6b9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,14 +37,20 @@ jobs: export VERSION=`cat VERSION` ./build.sh docker tag monai/workflow-manager:$VERSION monai/workflow-manager:${{ github.sha }} + docker tag monai/task-manager:$VERSION monai/task-manager:${{ github.sha }} - - name: Scan image with Azure Container Scan + - name: Scan Workflow Manager image with Azure Container Scan uses: Azure/container-scan@v0 with: image-name: monai/workflow-manager:${{ github.sha }} - - name: Scan image with Anchore - id: scan + - name: Scan Task Manager image with Azure Container Scan + uses: Azure/container-scan@v0 + with: + image-name: monai/task-manager:${{ github.sha }} + + - name: Scan Workflow Manager image with Anchore + id: scan-workflow-manager uses: anchore/scan-action@v2 with: image: monai/workflow-manager:${{ github.sha }} @@ -52,7 +58,23 @@ jobs: severity-cutoff: high acs-report-enable: true - - name: upload Anchore scan SARIF report + - name: upload Workflow Manager Anchore scan SARIF report + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: ${{ steps.scan-workflow-manager.outputs.sarif }} + category: workflow-manager + + - name: Scan Task Manager image with Anchore + id: scan-task-manager + uses: anchore/scan-action@v2 + with: + image: monai/task-manager:${{ github.sha }} + fail-build: true + severity-cutoff: high + acs-report-enable: true + + - name: upload Task Manager Anchore scan SARIF report uses: github/codeql-action/upload-sarif@v1 with: - sarif_file: ${{ steps.scan.outputs.sarif }} + sarif_file: ${{ steps.scan-task-manager.outputs.sarif }} + category: task-manager diff --git a/TaskManager.Dockerfile b/TaskManager.Dockerfile new file mode 100644 index 000000000..0bd6933be --- /dev/null +++ b/TaskManager.Dockerfile @@ -0,0 +1,60 @@ +# Copyright 2021 MONAI Consortium +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal as build + +ARG Version=0.0.0 +ARG FileVersion=0.0.0.0 + +# Install the tools +RUN dotnet tool install --tool-path /tools dotnet-trace +RUN dotnet tool install --tool-path /tools dotnet-dump +RUN dotnet tool install --tool-path /tools dotnet-counters +RUN dotnet tool install --tool-path /tools dotnet-stack +WORKDIR /app +COPY . ./ + +RUN echo "Building MONAI Workflow Manager $Version ($FileVersion)..." +RUN dotnet publish -c Release -o out --nologo /p:Version=$Version /p:FileVersion=$FileVersion src/TaskManager/TaskManager/Monai.Deploy.WorkflowManager.TaskManager.csproj + +RUN echo "Fetching mc executable for minio..." +RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc +RUN chmod +x mc + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get clean \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + libssl1.1 \ + openssl \ + sqlite3 \ + && rm -rf /var/lib/apt/lists + +WORKDIR /opt/monai/wm +COPY --from=build /app/out . +#COPY docs/compliance/open-source-licenses.md . + +COPY --from=build /tools /opt/dotnetcore-tools + +COPY --from=build /app/mc /usr/local/bin/mc +# RUN mv mc /usr/local/bin/mc + +EXPOSE 104 +EXPOSE 5000 + +RUN ls -lR /opt/monai/wm +ENV PATH="/opt/dotnetcore-tools:${PATH}" + +ENTRYPOINT ["/opt/monai/wm/Monai.Deploy.WorkflowManager"] diff --git a/Dockerfile b/WorkflowManager.Dockerfile similarity index 97% rename from Dockerfile rename to WorkflowManager.Dockerfile index 2187ffc4d..8bb8d87b2 100644 --- a/Dockerfile +++ b/WorkflowManager.Dockerfile @@ -1,60 +1,60 @@ -# Copyright 2021 MONAI Consortium -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM mcr.microsoft.com/dotnet/sdk:6.0-focal as build - -ARG Version=0.0.0 -ARG FileVersion=0.0.0.0 - -# Install the tools -RUN dotnet tool install --tool-path /tools dotnet-trace -RUN dotnet tool install --tool-path /tools dotnet-dump -RUN dotnet tool install --tool-path /tools dotnet-counters -RUN dotnet tool install --tool-path /tools dotnet-stack -WORKDIR /app -COPY . ./ - -RUN echo "Building MONAI Workflow Manager $Version ($FileVersion)..." -RUN dotnet publish -c Release -o out --nologo /p:Version=$Version /p:FileVersion=$FileVersion src/WorkflowManager/WorkflowManager/Monai.Deploy.WorkflowManager.csproj - -RUN echo "Fetching mc executable for minio..." -RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc -RUN chmod +x mc - -# Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - libssl1.1 \ - openssl \ - sqlite3 \ - && rm -rf /var/lib/apt/lists - -WORKDIR /opt/monai/wm -COPY --from=build /app/out . -#COPY docs/compliance/open-source-licenses.md . - -COPY --from=build /tools /opt/dotnetcore-tools - -COPY --from=build /app/mc /usr/local/bin/mc -# RUN mv mc /usr/local/bin/mc - -EXPOSE 104 -EXPOSE 5000 - -RUN ls -lR /opt/monai/wm -ENV PATH="/opt/dotnetcore-tools:${PATH}" - -ENTRYPOINT ["/opt/monai/wm/Monai.Deploy.WorkflowManager"] +# Copyright 2021 MONAI Consortium +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal as build + +ARG Version=0.0.0 +ARG FileVersion=0.0.0.0 + +# Install the tools +RUN dotnet tool install --tool-path /tools dotnet-trace +RUN dotnet tool install --tool-path /tools dotnet-dump +RUN dotnet tool install --tool-path /tools dotnet-counters +RUN dotnet tool install --tool-path /tools dotnet-stack +WORKDIR /app +COPY . ./ + +RUN echo "Building MONAI Workflow Manager $Version ($FileVersion)..." +RUN dotnet publish -c Release -o out --nologo /p:Version=$Version /p:FileVersion=$FileVersion src/WorkflowManager/WorkflowManager/Monai.Deploy.WorkflowManager.csproj + +RUN echo "Fetching mc executable for minio..." +RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc +RUN chmod +x mc + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get clean \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + libssl1.1 \ + openssl \ + sqlite3 \ + && rm -rf /var/lib/apt/lists + +WORKDIR /opt/monai/wm +COPY --from=build /app/out . +#COPY docs/compliance/open-source-licenses.md . + +COPY --from=build /tools /opt/dotnetcore-tools + +COPY --from=build /app/mc /usr/local/bin/mc +# RUN mv mc /usr/local/bin/mc + +EXPOSE 104 +EXPOSE 5000 + +RUN ls -lR /opt/monai/wm +ENV PATH="/opt/dotnetcore-tools:${PATH}" + +ENTRYPOINT ["/opt/monai/wm/Monai.Deploy.WorkflowManager"] diff --git a/build.sh b/build.sh index b8b390a54..e840f4dfc 100755 --- a/build.sh +++ b/build.sh @@ -22,5 +22,10 @@ fi echo "Building Workflow Manager Docker Image. VERSION=$VERSION, FILEVERSION=$FILEVERSION" pushd $SCRIPT_DIR -docker build --tag monai/workflow-manager:$VERSION --build-arg Version=$VERSION --build-arg FileVersion=$FILEVERSION . +docker build --tag monai/workflow-manager:$VERSION -f ./WorkflowManager.Dockerfile --build-arg Version=$VERSION --build-arg FileVersion=$FILEVERSION . +popd + +echo "Building Task Manager Docker Image. VERSION=$VERSION, FILEVERSION=$FILEVERSION" +pushd $SCRIPT_DIR +docker build --tag monai/task-manager:$VERSION -f ./TaskManager.Dockerfile --build-arg Version=$VERSION --build-arg FileVersion=$FILEVERSION . popd