# Base Containerfile for Debcraft
FROM debian:sid

ENV DEBIAN_FRONTEND=noninteractive

# Debian build essentials and Debcraft essentials
# Unfortunately this is almost 500 MB but here is no way around it. Luckily due
# to caching all rebuilds and all later containers will build much faster.
RUN apt-get update -q && \
    apt-get install -q --yes --no-install-recommends \
    blhc \
    ccache \
    curl \
    devscripts \
    eatmydata \
    equivs \
    fakeroot \
    git \
    git-buildpackage \
    lintian \
    pristine-tar

# Validator dependencies
# @TODO: dh-debputy and python3-pygls only available in latest Debian Sid 2024,
# this needs some rethinking to be compatible with building containers of older
# Debian and Ubuntu releases
RUN apt-get install -q --yes --no-install-recommends \
  dh-debputy \
  diffoscope-minimal \
  hunspell-en-us \
  python3-debian \
  python3-hunspell \
  python3-levenshtein \
  python3-lsprotocol \
  shellcheck \
  xxd

COPY control /
RUN apt-get update -q && \
    DEBIAN_FRONTEND=noninteractive mk-build-deps -r -i /control \
    -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends'

# Should be automatic and not needed at all, but run one more time just to be sure
RUN update-ccache-symlinks

# Older ccache does not support '--verbose' but will print stats anyway, just
# followed by help section. Newer ccache 4.0+ (Ubuntu 22.04 "Focal", Debian 12
# "Bullseye") however require '--verbose' to show any cache hit stats at all.
RUN ccache --show-stats  --verbose || true

# Enable source repositories so debcraft-downloader can work
COPY enable-source-repositories.sh /enable-source-repositories
RUN /enable-source-repositories

RUN apt-get install -q --yes command-not-found && \
    apt-get update -q

COPY *.sh /
