-
Notifications
You must be signed in to change notification settings - Fork 46
feat: consolidate Dockerfiles with build arguments (Issue #115 Task #4) #127
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
Open
rohitx01
wants to merge
2
commits into
OSIPI:main
Choose a base branch
from
rohitx01:merge-dockerfiles-issue115
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Dockerfile Consolidation - Issue #115 Task #4 | ||
|
|
||
| ## Overview | ||
| This document describes the consolidation of two separate Dockerfiles into a single unified Dockerfile that supports both standalone and Kaapana deployment. | ||
|
|
||
| ## Problem | ||
| Previously maintained two separate Dockerfiles: | ||
| 1. `Docker/Dockerfile` - Standalone IVIM fitting | ||
| 2. `kaapana_ivim_osipi/.../Dockerfile` - Kaapana deployment | ||
|
|
||
| This created: | ||
| - Code duplication | ||
| - Maintenance overhead | ||
| - Inconsistent updates | ||
|
|
||
| ## Solution | ||
| Created `Docker/Dockerfile.unified` that uses Docker build arguments to support both scenarios. | ||
|
|
||
| ## Build Arguments | ||
|
|
||
| | Argument | Default | Options | Purpose | | ||
| |----------|---------|---------|---------| | ||
| | `BASE_IMAGE` | `python:3.11-slim` | Any valid Docker image | Choose base image | | ||
| | `ENV_TYPE` | `standalone` | `standalone` or `kaapana` | Select environment | | ||
|
|
||
| ## Building | ||
|
|
||
| ### Standalone Build | ||
|
|
||
| Method 1: Using build script | ||
| ./Docker/build-standalone.sh | ||
|
|
||
| Method 2: Direct docker command | ||
| docker build | ||
| --build-arg ENV_TYPE=standalone | ||
| -t ivim-fitting:standalone | ||
| -f Docker/Dockerfile.unified . | ||
| ### Kaapana Build | ||
| Method 1: Using build script | ||
| ./Docker/build-kaapana.sh | ||
|
|
||
| Method 2: Direct docker command | ||
| docker build | ||
| --build-arg BASE_IMAGE=local-only/base-python-cpu:latest | ||
| --build-arg ENV_TYPE=kaapana | ||
| -t ivim-fitting:kaapana | ||
| -f Docker/Dockerfile.unified . | ||
|
|
||
| ## Testing Completed | ||
|
|
||
| ### Local Testing (Docker Desktop - Windows) | ||
| - [x] Standalone build succeeds (13.2GB, ID: 75a626d42f0b) | ||
| - [x] Kaapana build succeeds (14GB, ID: f662fb55bfee) | ||
| - [x] Both conditional logic statements work correctly | ||
| - [x] File copying and dependencies install without errors | ||
| - [x] Build scripts execute correctly | ||
|
|
||
| ### Integration Testing (Requires Kaapana Platform) | ||
| - [ ] Runtime with actual `local-only/base-python-cpu:latest` base image | ||
| - [ ] Volume mounts work (`OPERATOR_IN_DIR`, `OPERATOR_OUT_DIR`) | ||
| - [ ] MinIO data integration | ||
| - [ ] Airflow DAG execution in Kaapana UI | ||
| - [ ] Workflow submission through web interface | ||
|
|
||
| ## Files Modified/Added | ||
|
|
||
| | File | Change | Type | | ||
| |------|--------|------| | ||
| | `Docker/Dockerfile.unified` | New unified Dockerfile | New | | ||
| | `Docker/build-standalone.sh` | Build script for standalone | New | | ||
| | `Docker/build-kaapana.sh` | Build script for Kaapana | New | | ||
| | `Docker/DOCKERFILE_MERGE.md` | This documentation | New | | ||
|
|
||
| ## Notes for Reviewers | ||
|
|
||
| ### What I Could Test | ||
| Docker build process for both environments | ||
| Image creation and basic structure | ||
| Build argument passing | ||
| Entry point configuration | ||
|
|
||
| ### What Needs Your Testing | ||
| Runtime behavior in actual Kaapana deployment | ||
| Compatibility with Kaapana base image | ||
| Workflow execution through Kaapana UI | ||
| Data pipeline with MinIO | ||
|
|
||
| ## Related Issues | ||
| - Addresses #115 (Task #4) | ||
| - Related to PR #112 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
|
|
||
| # Unified Dockerfile for IVIM Fitting Method | ||
| # | ||
| # Supports both standalone and Kaapana deployment using build arguments. | ||
| # | ||
| # BUILD COMMANDS: | ||
| # =============== | ||
| # | ||
| # For standalone (default): | ||
| # $ docker build --build-arg ENV_TYPE=standalone \ | ||
| # -t ivim-fitting:standalone \ | ||
| # -f Dockerfile.unified . | ||
| # | ||
| # For Kaapana deployment: | ||
| # $ docker build --build-arg BASE_IMAGE=local-only/base-python-cpu:latest \ | ||
| # --build-arg ENV_TYPE=kaapana \ | ||
| # -t ivim-fitting:kaapana \ | ||
| # -f Dockerfile.unified . | ||
| # | ||
|
|
||
|
|
||
| # Step 1: Set base image (before FROM) | ||
| ARG BASE_IMAGE=python:3.11-slim | ||
|
|
||
| FROM ${BASE_IMAGE} | ||
|
|
||
| # Step 2: Define build-time configuration | ||
| ARG ENV_TYPE=standalone | ||
| ARG WORKDIR_PATH=/usr/src/app | ||
|
|
||
| # Metadata labels | ||
| LABEL IMAGE="ivim-fitting-method" | ||
| LABEL VERSION="0.2.4" | ||
| LABEL BUILD_IGNORE="False" | ||
|
|
||
|
|
||
| # COMMON SETUP (applies to both standalone and Kaapana) | ||
| # Install common system dependencies | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| libssl-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
|
|
||
| # ENVIRONMENT-SPECIFIC SETUP | ||
| # Kaapana setup | ||
| RUN if [ "$ENV_TYPE" = "kaapana" ]; then \ | ||
| echo "=== Configuring for KAAPANA ==="; \ | ||
| apt-get update && apt-get install -y --no-install-recommends \ | ||
| texlive-xetex \ | ||
| texlive-fonts-recommended \ | ||
| texlive-plain-generic \ | ||
| git && \ | ||
| apt-get clean && rm -rf /var/lib/apt/lists/*; \ | ||
| fi | ||
|
|
||
| # Standalone setup | ||
| RUN if [ "$ENV_TYPE" = "standalone" ]; then \ | ||
| echo "=== Configuring for STANDALONE ==="; \ | ||
| fi | ||
|
|
||
| # CODE ACQUISITION | ||
| # For Kaapana: Clone from GitHub and install dependencies | ||
| RUN if [ "$ENV_TYPE" = "kaapana" ]; then \ | ||
| mkdir -p /kaapana/app && \ | ||
| cd /kaapana/app && \ | ||
| git clone https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection.git && \ | ||
| cd TF2.4_IVIM-MRI_CodeCollection && \ | ||
| pip install --no-cache-dir -r requirements.txt; \ | ||
| fi | ||
|
|
||
| # For Standalone: Copy requirements and install | ||
| RUN if [ "$ENV_TYPE" = "standalone" ]; then \ | ||
| mkdir -p /usr/src/app; \ | ||
| fi | ||
|
|
||
| # Set working directory | ||
| WORKDIR ${WORKDIR_PATH} | ||
|
|
||
|
|
||
| # COPY FILES AND INSTALL DEPENDENCIES | ||
| # Copy requirements.txt from project root to current working directory | ||
| COPY requirements.txt ./ | ||
|
|
||
| # Copy source code (WrapImage and other files) | ||
| COPY WrapImage ./WrapImage/ | ||
|
|
||
| # Install Python dependencies for standalone | ||
| RUN if [ "$ENV_TYPE" = "standalone" ]; then \ | ||
| pip install --no-cache-dir -r requirements.txt; \ | ||
| fi | ||
|
|
||
|
|
||
| # SET ENTRYPOINT | ||
| # Kaapana entrypoint with verbose output | ||
| RUN if [ "$ENV_TYPE" = "kaapana" ]; then \ | ||
| echo "Kaapana wrapper selected"; \ | ||
| else \ | ||
| echo "Standalone wrapper selected"; \ | ||
| fi | ||
|
|
||
| # Use entrypoint script approach for flexibility | ||
| RUN echo '#!/bin/bash' > /entrypoint.sh && \ | ||
| if [ "$ENV_TYPE" = "kaapana" ]; then \ | ||
| echo 'cd /kaapana/app/TF2.4_IVIM-MRI_CodeCollection' >> /entrypoint.sh && \ | ||
| echo 'exec python3 -u -m WrapImage.nifti_wrapper_kaapana "$@"' >> /entrypoint.sh; \ | ||
| else \ | ||
| echo 'cd /usr/src/app' >> /entrypoint.sh && \ | ||
| echo 'exec python3 -m WrapImage.nifti_wrapper "$@"' >> /entrypoint.sh; \ | ||
| fi && \ | ||
| chmod +x /entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| CMD [] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| echo " Building IVIM Fitting for KAAPANA..." | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
|
|
||
| docker build \ | ||
| --build-arg BASE_IMAGE=local-only/base-python-cpu:latest \ | ||
| --build-arg ENV_TYPE=kaapana \ | ||
| -t ivim-fitting:kaapana \ | ||
| -f Docker/Dockerfile.unified \ | ||
| . | ||
|
|
||
| echo "" | ||
| echo " Build successful!" | ||
| echo " Image: ivim-fitting:kaapana" | ||
| docker images | grep "ivim-fitting.*kaapana" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| echo " Building IVIM Fitting for STANDALONE..." | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
|
|
||
| docker build \ | ||
| --build-arg ENV_TYPE=standalone \ | ||
| -t ivim-fitting:standalone \ | ||
| -f Docker/Dockerfile.unified \ | ||
| . | ||
|
|
||
| echo "" | ||
| echo " Build successful!" | ||
| echo " Image: ivim-fitting:standalone" | ||
| docker images | grep "ivim-fitting.*standalone" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.