feat: containerize build environment with Docker
- docker/Dockerfile: multi-stage image (linux-builder + windows-builder)
- linux-builder: Ubuntu 22.04 + OpenCV/LibRaw/Qt6 + GTest
- windows-builder: MXE cross-compilation (x86_64-w64-mingw32.static)
with OpenCV4, LibRaw, Qt6 for Windows .exe output
- docker-compose.yml: services for linux, windows-build, shell
- scripts/docker-build.sh: convenience wrapper
- linux|windows|all targets
- --no-cache, --run flags
Usage:
./scripts/docker-build.sh linux --run
./scripts/docker-build.sh windows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
93
scripts/docker-build.sh
Executable file
93
scripts/docker-build.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
# docker-build.sh — Baut photo-converter in Docker
|
||||
#
|
||||
# Verwendung:
|
||||
# ./scripts/docker-build.sh [linux|windows|all] [--no-cache] [--run]
|
||||
#
|
||||
# Optionen:
|
||||
# linux Linux CLI-Build (Standard)
|
||||
# windows Windows Cross-Compilation via MXE
|
||||
# all Beide Targets bauen
|
||||
# --no-cache Docker-Cache ignorieren
|
||||
# --run Nach dem Build direkt ausführen (nur linux)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'; GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m'
|
||||
log_info() { echo -e "${BLUE}[docker]${NC} $*"; }
|
||||
log_ok() { echo -e "${GREEN}[ok]${NC} $*"; }
|
||||
log_error(){ echo -e "${RED}[error]${NC} $*"; exit 1; }
|
||||
|
||||
TARGET="linux"
|
||||
NO_CACHE=""
|
||||
RUN_AFTER=0
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
linux) TARGET="linux" ;;
|
||||
windows) TARGET="windows" ;;
|
||||
all) TARGET="all" ;;
|
||||
--no-cache) NO_CACHE="--no-cache" ;;
|
||||
--run) RUN_AFTER=1 ;;
|
||||
--help|-h) sed -n '2,9p' "$0" | sed 's/^# \?//'; exit 0 ;;
|
||||
*) log_error "Unbekannte Option: $arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
command -v docker &>/dev/null || log_error "Docker nicht gefunden. Installieren: https://docs.docker.com/get-docker/"
|
||||
|
||||
mkdir -p output dist-windows
|
||||
|
||||
build_linux() {
|
||||
log_info "Baue Linux-Image (photo-converter:linux) ..."
|
||||
docker build $NO_CACHE \
|
||||
--target linux-builder \
|
||||
-t photo-converter:linux \
|
||||
-f docker/Dockerfile \
|
||||
.
|
||||
log_ok "Linux-Image gebaut"
|
||||
|
||||
if [[ $RUN_AFTER -eq 1 ]]; then
|
||||
log_info "Starte Konvertierung ..."
|
||||
docker run --rm \
|
||||
-v "$PROJECT_ROOT/import:/project/import:ro" \
|
||||
-v "$PROJECT_ROOT/output:/project/output" \
|
||||
-v "$PROJECT_ROOT/config.ini:/project/config.ini:ro" \
|
||||
photo-converter:linux \
|
||||
--batch --config config.ini
|
||||
log_ok "Konvertierung abgeschlossen. Ergebnisse in: output/"
|
||||
fi
|
||||
}
|
||||
|
||||
build_windows() {
|
||||
log_info "Baue Windows-Cross-Compilation-Image (photo-converter:windows-builder) ..."
|
||||
log_info "Hinweis: Erster Build lädt ~3 GB MXE-Pakete herunter (~20-30 Min)"
|
||||
docker build $NO_CACHE \
|
||||
--target windows-builder \
|
||||
-t photo-converter:windows-builder \
|
||||
-f docker/Dockerfile \
|
||||
.
|
||||
log_ok "Windows-Builder-Image gebaut"
|
||||
|
||||
log_info "Extrahiere photo-converter.exe ..."
|
||||
mkdir -p dist-windows
|
||||
docker run --rm \
|
||||
-v "$PROJECT_ROOT/dist-windows:/project/dist-windows" \
|
||||
photo-converter:windows-builder \
|
||||
-c "cp -r /project/dist-windows/. /project/dist-windows/ && echo 'Fertig'"
|
||||
|
||||
log_ok "Windows-Build abgeschlossen: dist-windows/"
|
||||
ls -lh dist-windows/bin/ 2>/dev/null || true
|
||||
}
|
||||
|
||||
case "$TARGET" in
|
||||
linux) build_linux ;;
|
||||
windows) build_windows ;;
|
||||
all) build_linux; build_windows ;;
|
||||
esac
|
||||
|
||||
log_ok "Fertig."
|
||||
Reference in New Issue
Block a user