Zach Wentz commited on
Commit
0716bd5
·
1 Parent(s): fe49f51

🤖 Deploy openspiel_env environment - 2025-10-19 22:40:03

Browse files
Files changed (1) hide show
  1. Dockerfile +62 -10
Dockerfile CHANGED
@@ -1,11 +1,43 @@
1
- # Copyright (c) Meta Platforms, Inc. and affiliates.
2
- # All rights reserved.
3
- #
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
 
7
- # Multi-stage build: First stage builds the base image
8
- FROM python:3.11-slim as base-builder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -26,14 +58,34 @@ WORKDIR /app
26
  ENV PYTHONPATH=/app/src
27
  ENV PYTHONUNBUFFERED=1
28
 
29
- # Second stage: Use the built base image and add environment-specific dependencies
30
- FROM base-builder
 
 
 
 
 
 
 
 
31
 
 
 
32
 
33
- # Copy only what's needed for this environment
 
34
  COPY src/core/ /app/src/core/
35
  COPY src/envs/openspiel_env/ /app/src/envs/openspiel_env/
36
 
 
 
 
 
 
 
 
 
 
37
  # Health check
38
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
39
  CMD curl -f http://localhost:8000/health || exit 1
 
1
+ # OpenSpiel requires complex C++ build - using special multi-stage approach
2
+ # Stage 1: Build OpenSpiel C++ bindings
3
+ FROM python:3.11 AS openspiel-builder
 
 
4
 
5
+ # Avoid interactive prompts during build
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
+ ENV TZ=UTC
8
+
9
+ # Install build dependencies
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ build-essential \
12
+ clang \
13
+ cmake \
14
+ curl \
15
+ git \
16
+ sudo \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # Set up OpenSpiel build directory
20
+ RUN mkdir /repo
21
+ WORKDIR /repo
22
+
23
+ # Clone OpenSpiel
24
+ RUN git clone https://github.com/google-deepmind/open_spiel.git .
25
+
26
+ # Run OpenSpiel's installation script (downloads C++ dependencies)
27
+ RUN ./install.sh
28
+
29
+ # Install Python dependencies
30
+ RUN pip3 install --no-cache-dir --upgrade setuptools testresources importlib_metadata
31
+ RUN pip3 install --no-cache-dir --upgrade -r requirements.txt cmake
32
+
33
+ # Build OpenSpiel with Python 3.11
34
+ RUN mkdir -p build
35
+ WORKDIR /repo/build
36
+ RUN cmake -DPython3_EXECUTABLE=$(which python3) -DCMAKE_CXX_COMPILER=$(which clang++) ../open_spiel
37
+ RUN make -j$(nproc) pyspiel
38
+
39
+ # Stage 2: Build OpenEnv base image
40
+ FROM python:3.11-slim as openenv-base
41
 
42
  # Install system dependencies
43
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
58
  ENV PYTHONPATH=/app/src
59
  ENV PYTHONUNBUFFERED=1
60
 
61
+ # Stage 3: Final runtime image
62
+ FROM openenv-base
63
+
64
+ # Copy OpenSpiel build artifacts from builder
65
+ RUN mkdir -p /repo
66
+ COPY --from=openspiel-builder /repo /repo
67
+
68
+ # Install OpenSpiel Python requirements in runtime
69
+ WORKDIR /repo
70
+ RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
71
 
72
+ # Set Python path for OpenSpiel
73
+ ENV PYTHONPATH=/repo:/repo/build/python:${PYTHONPATH}
74
 
75
+ # Copy OpenEnv core
76
+ WORKDIR /app
77
  COPY src/core/ /app/src/core/
78
  COPY src/envs/openspiel_env/ /app/src/envs/openspiel_env/
79
 
80
+ # Extend Python path for OpenEnv (base image set PYTHONPATH=/app/src)
81
+ # We prepend OpenSpiel paths
82
+ ENV PYTHONPATH=/repo:/repo/build/python:/app/src
83
+
84
+ # OpenSpiel-specific environment variables (can be overridden at runtime)
85
+ ENV OPENSPIEL_GAME=catch
86
+ ENV OPENSPIEL_AGENT_PLAYER=0
87
+ ENV OPENSPIEL_OPPONENT_POLICY=random
88
+
89
  # Health check
90
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
91
  CMD curl -f http://localhost:8000/health || exit 1