# The image the nightly `tracker-live` workflow runs in: the packaged Super Productivity
# desktop app, an X server to hold it, and what the suite itself needs (Gitea #156).
# Built by `.gitea/workflows/sp-live-image.yml`, never by hand.
FROM debian:trixie-slim

ARG SP_VERSION
ARG SP_SHA512

# `nodejs` is for act_runner, which executes JavaScript actions (checkout) inside the
# job container. `libasound2t64` and `libgbm1` are the two libraries the .deb does not
# pull in and the app will not start without.
RUN set -eu; \
    test -n "$SP_VERSION" && test -n "$SP_SHA512"; \
    apt-get update -qq; \
    apt-get install -y --no-install-recommends \
      ca-certificates curl git nodejs python3 python3-venv ripgrep \
      xvfb xauth libasound2t64 libgbm1; \
    curl -fsSL -o /tmp/sp.deb \
      "https://github.com/super-productivity/super-productivity/releases/download/v${SP_VERSION}/superProductivity-amd64.deb"; \
    expected="$(printf '%s' "$SP_SHA512" | base64 -d | od -An -v -tx1 | tr -d ' \n')"; \
    echo "${expected}  /tmp/sp.deb" | sha512sum -c -; \
    apt-get install -y --no-install-recommends /tmp/sp.deb; \
    rm -rf /tmp/sp.deb /var/lib/apt/lists/*

LABEL org.opencontainers.image.title="chemenu-sp-live" \
      org.opencontainers.image.description="Packaged Super Productivity for chemenu's live tracker suite" \
      chemenu.sp-version="${SP_VERSION}"

ENV CHEMENU_LIVE_SP_BINARY="/opt/Super Productivity/superproductivity" \
    CHEMENU_LIVE_SP_VERSION="${SP_VERSION}"
