# This Dockerfile builds the SwiftPM package in a Linux container. Note: iOS/macOS
# UIKit code cannot be built on Linux; this container focuses on metadata/description
# and a best-effort build for Swift-based components.
FROM swift:6.3.2-jammy
# Non-interactive apt and essential tools
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
bash \
&& rm -rf /var/lib/apt/lists/*
# Some CI environments call /bin/sh; ensure it is bash for compatibility with pipefail
RUN ln -sf /bin/bash /bin/sh
# Working directory for the build
WORKDIR /workspace
# Copy manifest first to leverage Docker cache
COPY Package.swift ./
# Copy the rest of the repository
COPY . .
# Gather package description (metadata) for smoke tests
RUN swift package describe > package.describe.txt 2>&1 || true
# Resolve dependencies and attempt a lightweight build (best-effort; may fail on Linux for UIKit code)
RUN swift package resolve 2>&1 || true
RUN swift build -c release 2>&1 || true
# Default command: print Swift version and first lines of package description if available
CMD ["bash", "-lc", "echo 'Container ready. Swift version:' && swift --version && echo && echo 'Package describe output (first lines):' && (test -f package.describe.txt && head -n 20 package.describe.txt || true) || true"]