# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Pre-built OpenSpiel base image # This image contains OpenSpiel compiled and ready to use # Built from: docker build -t openspiel-base:latest -f envs/openspiel_env/server/Dockerfile.openspiel-base . # In GitHub Actions, this is overridden to use the GHCR base image ARG BASE_IMAGE=openenv-base:latest FROM ${BASE_IMAGE} # Avoid interactive prompts during build ENV DEBIAN_FRONTEND=noninteractive ENV TZ=UTC # Install build dependencies (curl already installed by openenv-base) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ clang \ cmake \ git \ sudo \ && rm -rf /var/lib/apt/lists/* # Set up OpenSpiel build directory RUN mkdir /repo WORKDIR /repo # Clone OpenSpiel RUN git clone https://github.com/google-deepmind/open_spiel.git . # Run OpenSpiel's installation script (downloads C++ dependencies) RUN ./install.sh # Install Python dependencies # First upgrade pip and setuptools, then install other packages RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel RUN pip3 install --no-cache-dir --upgrade pbr testresources importlib_metadata RUN pip3 install --no-cache-dir --upgrade -r requirements.txt cmake # Build OpenSpiel with Python 3.11 # Use the exact same Python executable as the base image # Disable gin_rummy to speed up build (complex game, not needed for basic usage) RUN mkdir -p build WORKDIR /repo/build RUN cmake -DPython3_EXECUTABLE=/usr/local/bin/python3 \ -DCMAKE_CXX_COMPILER=$(which clang++) \ -DOPEN_SPIEL_BUILD_WITH_GIN_RUMMY=OFF \ ../open_spiel RUN make -j$(nproc) pyspiel # Install OpenSpiel Python requirements WORKDIR /repo RUN pip3 install --no-cache-dir --upgrade -r requirements.txt # Set Python path for OpenSpiel ENV PYTHONPATH=/repo:/repo/build/python:${PYTHONPATH} # Test OpenSpiel import to verify ABI compatibility RUN python3 -c "import pyspiel; print('OpenSpiel import successful')" || echo "OpenSpiel import failed" # Clean up build dependencies to reduce image size RUN apt-get remove -y build-essential clang cmake git sudo || true && \ apt-get autoremove -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Set working directory back to /app (standard for openenv-base) WORKDIR /app