# =============================================================================
# KAMOS - Gaming OS - Containerfile
# "Play. Perform. Dominate."
# Base: Bazzite NVIDIA stable (proprietary NVIDIA driver, gaming-tuned bootc)
# =============================================================================
#
# Why this base:
#   ghcr.io/ublue-os/bazzite-nvidia:stable ships with the proprietary NVIDIA
#   driver baked in via akmods. If you want the open-kernel-module variant,
#   swap to ghcr.io/ublue-os/bazzite-nvidia-open:stable instead.
#
# Architecture: x86_64 only. This image will NOT boot natively on an Apple
# Silicon Mac. Test it inside VMware Fusion (with x86_64 emulation enabled)
# or install on a real NVIDIA PC.
# -----------------------------------------------------------------------------

ARG BASE_IMAGE="ghcr.io/ublue-os/bazzite-nvidia"
ARG BASE_TAG="stable"

FROM ${BASE_IMAGE}:${BASE_TAG}

# OCI labels - good practice and surface nicely on registries / artifacthub.
LABEL org.opencontainers.image.title="KAMOS"
LABEL org.opencontainers.image.description="KAMOS Gaming OS - Bazzite NVIDIA stable bootc image. Play. Perform. Dominate."
LABEL org.opencontainers.image.vendor="Khalaf"
LABEL org.opencontainers.image.source="https://cgi.medsys.cloud/mkm1971/kamos"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL io.artifacthub.package.readme-url="https://cgi.medsys.cloud/mkm1971/kamos/raw/branch/main/README.md"

# -----------------------------------------------------------------------------
# Stage 1: copy our customisations into the build context
# Note: build_files goes to /ctx (NOT /tmp) because the RUN below mounts a
# tmpfs over /tmp which would hide anything we put there.
# -----------------------------------------------------------------------------
COPY build_files/ /ctx/
COPY system_files/ /

# -----------------------------------------------------------------------------
# Stage 2: run the customisation script
#   - install / remove packages
#   - apply branding (wallpaper, plymouth theme, os-release, GRUB logo)
#   - any other system tweaks
# -----------------------------------------------------------------------------
RUN --mount=type=cache,dst=/var/cache \
    --mount=type=cache,dst=/var/log \
    --mount=type=tmpfs,dst=/tmp \
    chmod +x /ctx/build.sh && \
    bash /ctx/build.sh && \
    ostree container commit

# -----------------------------------------------------------------------------
# Sanity: make sure the image is bootc-compatible after our changes.
# `bootc container lint` is run by ostree container commit but we surface a
# friendly error via a final no-op so layer caching is clear.
# -----------------------------------------------------------------------------
