# Multi-stage build for GPUImage Swift package on Linux
FROM swift:4.2 AS builder
# Install system dependencies needed for OpenGL, GLUT, and Video4Linux
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-dev \
freeglut3-dev \
libxrandr-dev \
libxinerama-dev \
libxi-dev \
libxcursor-dev \
libv4l-dev \
libgd-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Copy the source into the container and build
WORKDIR /workspace
COPY . .
# Build the Swift package in release mode
RUN swift build -c release
# Runtime image
FROM debian:bullseye-slim AS runtime
# Install runtime OpenGL and Video4Linux related libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-dri \
libgl1-mesa-glx \
freeglut3 \
libv4l-0 \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Copy the built artifacts from the builder
COPY --from=builder /workspace/.build /workspace/.build
WORKDIR /workspace
# Default to an interactive shell so the container remains usable
CMD ["/bin/bash"]