FROM swift:5.9-jammy AS builder
LABEL maintainer="BuildAgent"
# Build stage: attempt to compile any Swift Package if present
WORKDIR /app
COPY . /app
# Install lightweight build dependencies that Swift may require
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libsqlite3-dev libxml2-dev libcurl4-openssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN swift --version
# If the repository contains a Swift Package Manifest, build it in release mode.
RUN if [ -f Package.swift ]; then swift build -c release; fi
# Show any produced release artifacts (best-effort)
RUN if [ -d ".build/release" ]; then ls -la .build/release; fi
FROM ubuntu:jammy-20260217 AS runtime
WORKDIR /app
COPY --from=builder /app /app
# Try to run a built binary if one exists; this container is Linux-based and may not be able to execute macOS apps.
CMD ["bash","-lc","for b in NetNewsWire NetNewsWire7 NNW; do if [ -x \".build/release/$b\" ]; then exec \".build/release/$b\"; fi; done; echo 'No suitable executable found in .build/release. This project targets macOS (AppKit/UIKit) and cannot be fully run in Linux containers.'"]