FROM debian:bookworm-slim

# List of all dependencies specified in root level Dockerfile
RUN apt-get update && apt-get install --yes --no-install-recommends \
    attr \
    bubblewrap \
    build-essential \
    clang-format \
    clang-tools \
    ca-certificates \
    cmake \
    fuse3 \
    g++ \
    git \
    libbenchmark-dev \
    libc6-dev \
    libfuse3-dev \
    libgmock-dev \
    libgoogle-glog-dev \
    libgoogle-glog0v6 \
    libgrpc++-dev \
    libgrpc++1.51 \
    libgtest-dev \
    libprotobuf-dev \
    libssl3 \
    libssl-dev \
    libtomlplusplus-dev \
    libcurl4-openssl-dev \
    net-tools \
    ninja-build \
    nlohmann-json3-dev \
    pkg-config \
    protobuf-compiler \
    protobuf-compiler-grpc \
    socat \
    sudo \
    uuid-dev

# Add non-root user for devcontainer use
RUN groupadd -r builder && useradd --shell /bin/bash -m -r -g builder builder
# Grant access to apt for non-root user to install packages
RUN echo "builder ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/builder \
    && chmod 0440 /etc/sudoers.d/builder

# Bootstrap container with recc/buildbox-casd from the release image
# to speed up builds
COPY --from=registry.gitlab.com/buildgrid/buildbox/buildbox:latest /usr/local/bin/recc /usr/local/bin/buildbox-casd /usr/local/bin
RUN mkdir /home/builder/.recc /tmp/casd && chmod 777 /tmp/casd && ln -s /workspaces/buildbox/.devcontainer/recc.conf /home/builder/.recc/recc.conf
