# Image for Gitea Actions jobs. It contains every tool the pipeline needs so
# workflows do not download a JDK or install packages on every run.
#
# Build and push it with scripts/build-ci-image.sh.
FROM gradle:8.14.3-jdk21

ARG NODE_VERSION=22.14.0
ARG DOCKER_VERSION=27.3.1
ARG HELM_VERSION=3.16.4

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        git \
        ffmpeg \
        sqlite3 \
        xz-utils \
    && rm -rf /var/lib/apt/lists/*

# Node is required by actions/checkout and other JavaScript actions executed
# inside the job container.
RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
        -o /tmp/node.tar.xz \
    && tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 \
    && rm /tmp/node.tar.xz \
    && node --version \
    && npm --version

# Docker CLI only (the runner mounts its daemon socket into the job).
RUN curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" \
        -o /tmp/docker.tgz \
    && tar -xzf /tmp/docker.tgz -C /tmp \
    && install -m 0755 /tmp/docker/docker /usr/local/bin/docker \
    && rm -rf /tmp/docker /tmp/docker.tgz \
    && docker --version

RUN curl -fsSL "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" \
        -o /tmp/helm.tgz \
    && tar -xzf /tmp/helm.tgz -C /tmp \
    && install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm \
    && rm -rf /tmp/helm.tgz /tmp/linux-amd64 \
    && helm version --short

ENV GRADLE_USER_HOME=/root/.gradle \
    JAVA_HOME=/opt/java/openjdk

WORKDIR /workspace

CMD ["sleep", "infinity"]
