# Multi-stage Dockerfile to build tinyraycaster from source on Ubuntu 22.04
# Stage 1: build
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake libsdl2-dev
WORKDIR /tinyraycaster
COPY . .
# Build the project
RUN mkdir -p build && cd build && cmake .. && make -j"$(nproc)"
# Stage 2: runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl2-2.0-0
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /tinyraycaster
# Copy the built application and sources for runtime if needed
COPY --from=builder /tinyraycaster /tinyraycaster
# Run the application with SDL dummy driver to support headless environments
CMD ["bash","-lc","SDL_VIDEODRIVER=dummy /tinyraycaster/build/tinyraycaster"]