Skip to content

Commit 4dbf42c

Browse files
committed
feat: consolidate Dockerfiles with build arguments (Issue #115 Task #4)
- Create unified Dockerfile.unified supporting both standalone and Kaapana - Add build-standalone.sh and build-kaapana.sh convenience scripts - Document consolidation approach and testing performed - Uses ARG for BASE_IMAGE and ENV_TYPE configuration Testing completed: - Standalone build: Successfully created (13.2GB) Image ID: 75a626d42f0b - Kaapana build: Successfully created (14GB) Image ID: f662fb55bfee - Both images build without errors - Conditional logic (if statements) work correctly - Entry points properly configured for each environment Integration testing requires: - Actual Kaapana base image (local-only/base-python-cpu:latest) - Kaapana platform deployment - Workflow execution in Kaapana UI
1 parent d12644d commit 4dbf42c

File tree

4 files changed

+237
-0
lines changed

4 files changed

+237
-0
lines changed

Docker/DOCKERFILE_MERGE.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Dockerfile Consolidation - Issue #115 Task #4
2+
3+
## Overview
4+
This document describes the consolidation of two separate Dockerfiles into a single unified Dockerfile that supports both standalone and Kaapana deployment.
5+
6+
## Problem
7+
Previously maintained two separate Dockerfiles:
8+
1. `Docker/Dockerfile` - Standalone IVIM fitting
9+
2. `kaapana_ivim_osipi/.../Dockerfile` - Kaapana deployment
10+
11+
This created:
12+
- Code duplication
13+
- Maintenance overhead
14+
- Inconsistent updates
15+
16+
## Solution
17+
Created `Docker/Dockerfile.unified` that uses Docker build arguments to support both scenarios.
18+
19+
## Build Arguments
20+
21+
| Argument | Default | Options | Purpose |
22+
|----------|---------|---------|---------|
23+
| `BASE_IMAGE` | `python:3.11-slim` | Any valid Docker image | Choose base image |
24+
| `ENV_TYPE` | `standalone` | `standalone` or `kaapana` | Select environment |
25+
26+
## Building
27+
28+
### Standalone Build
29+
30+
Method 1: Using build script
31+
./Docker/build-standalone.sh
32+
33+
Method 2: Direct docker command
34+
docker build
35+
--build-arg ENV_TYPE=standalone
36+
-t ivim-fitting:standalone
37+
-f Docker/Dockerfile.unified .
38+
### Kaapana Build
39+
Method 1: Using build script
40+
./Docker/build-kaapana.sh
41+
42+
Method 2: Direct docker command
43+
docker build
44+
--build-arg BASE_IMAGE=local-only/base-python-cpu:latest
45+
--build-arg ENV_TYPE=kaapana
46+
-t ivim-fitting:kaapana
47+
-f Docker/Dockerfile.unified .
48+
49+
## Testing Completed
50+
51+
### Local Testing (Docker Desktop - Windows)
52+
- [x] Standalone build succeeds (13.2GB, ID: 75a626d42f0b)
53+
- [x] Kaapana build succeeds (14GB, ID: f662fb55bfee)
54+
- [x] Both conditional logic statements work correctly
55+
- [x] File copying and dependencies install without errors
56+
- [x] Build scripts execute correctly
57+
58+
### Integration Testing (Requires Kaapana Platform)
59+
- [ ] Runtime with actual `local-only/base-python-cpu:latest` base image
60+
- [ ] Volume mounts work (`OPERATOR_IN_DIR`, `OPERATOR_OUT_DIR`)
61+
- [ ] MinIO data integration
62+
- [ ] Airflow DAG execution in Kaapana UI
63+
- [ ] Workflow submission through web interface
64+
65+
## Files Modified/Added
66+
67+
| File | Change | Type |
68+
|------|--------|------|
69+
| `Docker/Dockerfile.unified` | New unified Dockerfile | New |
70+
| `Docker/build-standalone.sh` | Build script for standalone | New |
71+
| `Docker/build-kaapana.sh` | Build script for Kaapana | New |
72+
| `Docker/DOCKERFILE_MERGE.md` | This documentation | New |
73+
74+
## Notes for Reviewers
75+
76+
### What I Could Test
77+
Docker build process for both environments
78+
Image creation and basic structure
79+
Build argument passing
80+
Entry point configuration
81+
82+
### What Needs Your Testing
83+
Runtime behavior in actual Kaapana deployment
84+
Compatibility with Kaapana base image
85+
Workflow execution through Kaapana UI
86+
Data pipeline with MinIO
87+
88+
## Related Issues
89+
- Addresses #115 (Task #4)
90+
- Related to PR #112

Docker/Dockerfile.unified

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
# Unified Dockerfile for IVIM Fitting Method
3+
#
4+
# Supports both standalone and Kaapana deployment using build arguments.
5+
#
6+
# BUILD COMMANDS:
7+
# ===============
8+
#
9+
# For standalone (default):
10+
# $ docker build --build-arg ENV_TYPE=standalone \
11+
# -t ivim-fitting:standalone \
12+
# -f Dockerfile.unified .
13+
#
14+
# For Kaapana deployment:
15+
# $ docker build --build-arg BASE_IMAGE=local-only/base-python-cpu:latest \
16+
# --build-arg ENV_TYPE=kaapana \
17+
# -t ivim-fitting:kaapana \
18+
# -f Dockerfile.unified .
19+
#
20+
21+
22+
# Step 1: Set base image (before FROM)
23+
ARG BASE_IMAGE=python:3.11-slim
24+
25+
FROM ${BASE_IMAGE}
26+
27+
# Step 2: Define build-time configuration
28+
ARG ENV_TYPE=standalone
29+
ARG WORKDIR_PATH=/usr/src/app
30+
31+
# Metadata labels
32+
LABEL IMAGE="ivim-fitting-method"
33+
LABEL VERSION="0.2.4"
34+
LABEL BUILD_IGNORE="False"
35+
36+
37+
# COMMON SETUP (applies to both standalone and Kaapana)
38+
# Install common system dependencies
39+
RUN apt-get update && apt-get install -y --no-install-recommends \
40+
build-essential \
41+
libssl-dev \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
45+
# ENVIRONMENT-SPECIFIC SETUP
46+
# Kaapana setup
47+
RUN if [ "$ENV_TYPE" = "kaapana" ]; then \
48+
echo "=== Configuring for KAAPANA ==="; \
49+
apt-get update && apt-get install -y --no-install-recommends \
50+
texlive-xetex \
51+
texlive-fonts-recommended \
52+
texlive-plain-generic \
53+
git && \
54+
apt-get clean && rm -rf /var/lib/apt/lists/*; \
55+
fi
56+
57+
# Standalone setup
58+
RUN if [ "$ENV_TYPE" = "standalone" ]; then \
59+
echo "=== Configuring for STANDALONE ==="; \
60+
fi
61+
62+
# CODE ACQUISITION
63+
# For Kaapana: Clone from GitHub and install dependencies
64+
RUN if [ "$ENV_TYPE" = "kaapana" ]; then \
65+
mkdir -p /kaapana/app && \
66+
cd /kaapana/app && \
67+
git clone https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection.git && \
68+
cd TF2.4_IVIM-MRI_CodeCollection && \
69+
pip install --no-cache-dir -r requirements.txt; \
70+
fi
71+
72+
# For Standalone: Copy requirements and install
73+
RUN if [ "$ENV_TYPE" = "standalone" ]; then \
74+
mkdir -p /usr/src/app; \
75+
fi
76+
77+
# Set working directory
78+
WORKDIR ${WORKDIR_PATH}
79+
80+
81+
# COPY FILES AND INSTALL DEPENDENCIES
82+
# Copy requirements.txt from project root to current working directory
83+
COPY requirements.txt ./
84+
85+
# Copy source code (WrapImage and other files)
86+
COPY WrapImage ./WrapImage/
87+
88+
# Install Python dependencies for standalone
89+
RUN if [ "$ENV_TYPE" = "standalone" ]; then \
90+
pip install --no-cache-dir -r requirements.txt; \
91+
fi
92+
93+
94+
# SET ENTRYPOINT
95+
# Kaapana entrypoint with verbose output
96+
RUN if [ "$ENV_TYPE" = "kaapana" ]; then \
97+
echo "Kaapana wrapper selected"; \
98+
else \
99+
echo "Standalone wrapper selected"; \
100+
fi
101+
102+
# Use entrypoint script approach for flexibility
103+
RUN echo '#!/bin/bash' > /entrypoint.sh && \
104+
if [ "$ENV_TYPE" = "kaapana" ]; then \
105+
echo 'cd /kaapana/app/TF2.4_IVIM-MRI_CodeCollection' >> /entrypoint.sh && \
106+
echo 'exec python3 -u -m WrapImage.nifti_wrapper_kaapana "$@"' >> /entrypoint.sh; \
107+
else \
108+
echo 'cd /usr/src/app' >> /entrypoint.sh && \
109+
echo 'exec python3 -m WrapImage.nifti_wrapper "$@"' >> /entrypoint.sh; \
110+
fi && \
111+
chmod +x /entrypoint.sh
112+
113+
ENTRYPOINT ["/entrypoint.sh"]
114+
CMD []

Docker/build-kaapana.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo " Building IVIM Fitting for KAAPANA..."
5+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
6+
7+
docker build \
8+
--build-arg BASE_IMAGE=local-only/base-python-cpu:latest \
9+
--build-arg ENV_TYPE=kaapana \
10+
-t ivim-fitting:kaapana \
11+
-f Docker/Dockerfile.unified \
12+
.
13+
14+
echo ""
15+
echo " Build successful!"
16+
echo " Image: ivim-fitting:kaapana"
17+
docker images | grep "ivim-fitting.*kaapana"

Docker/build-standalone.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo " Building IVIM Fitting for STANDALONE..."
5+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
6+
7+
docker build \
8+
--build-arg ENV_TYPE=standalone \
9+
-t ivim-fitting:standalone \
10+
-f Docker/Dockerfile.unified \
11+
.
12+
13+
echo ""
14+
echo " Build successful!"
15+
echo " Image: ivim-fitting:standalone"
16+
docker images | grep "ivim-fitting.*standalone"

0 commit comments

Comments
 (0)