Skip to content
Open
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
90 changes: 90 additions & 0 deletions Docker/DOCKERFILE_MERGE.md
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
114 changes: 114 additions & 0 deletions Docker/Dockerfile.unified
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 []
17 changes: 17 additions & 0 deletions Docker/build-kaapana.sh
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"
16 changes: 16 additions & 0 deletions Docker/build-standalone.sh
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"