tldev-posturr
SUCCESS
10m 49s
History Source
SummaryIterations1Transcript12Dockerfile
Dockerfile37 lines · 1469 chars
# Dockerfile for Dorso (Swift package)
# Stage 1: Build the Swift package (optional Dorso executable) in a Swift toolchain environment.
# Note: Building macOS GUI apps with AppKit in Linux containers is not fully supported; this container
# provides a reproducible build environment and a runtime stub that indicates whether a built binary exists.

# Stage 1: Swift builder
FROM swift:5.9 AS builder
ARG BUILD_APP=0
WORKDIR /workspace

# Copy repository into the builder
COPY . .

# Resolve dependencies
RUN swift package resolve

# Optionally build the Dorso executable (requires macOS frameworks). When BUILD_APP=1, attempt to build.
RUN if [ "$BUILD_APP" = "1" ]; then \
      echo "Attempting to build Dorso executable..."; \
      swift build -c release --product Dorso; \
    else \
      echo "Skipping Dorso build (BUILD_APP=$BUILD_APP)."; \
    fi

# Stage 2: Runtime image
FROM debian:bookworm-slim
WORKDIR /workspace

# Copy the workspace (source and any built artifacts if present) from the builder
COPY --from=builder /workspace /workspace

# Basic runtime setup
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

# Default command: try to run the built Dorso binary if it exists; otherwise print a helpful message
CMD ["/bin/sh", "-lc", "if [ -x /workspace/.build/release/Dorso ]; then /workspace/.build/release/Dorso; else echo 'Dorso binary not built in this container. Build with BUILD_APP=1 on macOS host.'; fi"]