File size: 2,452 Bytes
c65b2a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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