# The upstream vAccel agent, from the release artifacts of nubificus/vaccel
# v0.8.0 -- never rebuilt from source, never re-implemented. The noop plugin is
# what executes the operations, so the answers are the upstream runtime's.
FROM ubuntu:24.04@sha256:440dcf6a5640b2ae5c77724e68787a906afb8ddee98bf86db94eea8528c2c076

ARG TARGETARCH
ARG VACCEL_VERSION=0.8.0
ARG AGENT_VERSION=0.5.0+vaccel.0.8.0

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

ADD https://github.com/nubificus/vaccel/releases/download/v${VACCEL_VERSION}/vaccel_${VACCEL_VERSION}-1_${TARGETARCH}.deb /tmp/
ADD https://github.com/nubificus/vaccel/releases/download/v${VACCEL_VERSION}/vaccel-rpc-agent_${AGENT_VERSION}-1_${TARGETARCH}.deb /tmp/

COPY checksums.txt /tmp/checksums.txt
RUN cd /tmp && sha256sum -c --ignore-missing checksums.txt \
  && apt-get install -y --no-install-recommends /tmp/*.deb \
  && rm -f /tmp/*.deb

ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib
EXPOSE 65500

# The noop plugin executes the operations. The vAccel runtime bootstraps itself
# from the environment (src/config.h: VACCEL_PLUGINS), and it must: without it
# vaccel_session_init returns VACCEL_ESESS ("sessions not initialized"), and
# every operation that needs a session fails.
ENV VACCEL_PLUGINS=libvaccel-noop.so
CMD ["vaccel-rpc-agent", "-a", "tcp://0.0.0.0:65500"]
