@@ -94,63 +94,23 @@ DOCKERFILE_EOF
9494 " openspiel_env" )
9595 # OpenSpiel requires special C++ build process - replace entire Dockerfile
9696 cat > $CURRENT_STAGING_DIR /Dockerfile << DOCKERFILE_EOF
97- # OpenSpiel requires complex C++ build - using special multi-stage approach
98- # Stage 1: Build OpenSpiel C++ bindings
99- FROM python:3.11 AS openspiel-builder
100-
101- # Avoid interactive prompts during build
102- ENV DEBIAN_FRONTEND=noninteractive
103- ENV TZ=UTC
104-
105- # Install build dependencies
106- RUN apt-get update && apt-get install -y --no-install-recommends \
107- build-essential \
108- clang \
109- cmake \
110- curl \
111- git \
112- sudo \
113- && rm -rf /var/lib/apt/lists/*
114-
115- # Set up OpenSpiel build directory
116- RUN mkdir /repo
117- WORKDIR /repo
118-
119- # Clone OpenSpiel
120- RUN git clone https://github.com/google-deepmind/open_spiel.git .
121-
122- # Run OpenSpiel's installation script (downloads C++ dependencies)
123- RUN ./install.sh
124-
125- # Install Python dependencies
126- RUN pip3 install --no-cache-dir --upgrade setuptools testresources importlib_metadata
127- RUN pip3 install --no-cache-dir --upgrade -r requirements.txt cmake
128-
129- # Build OpenSpiel with Python 3.11
130- RUN mkdir -p build
131- WORKDIR /repo/build
132- RUN cmake -DPython3_EXECUTABLE=$( which python3) -DCMAKE_CXX_COMPILER=$( which clang++) ../open_spiel
133- RUN make -j$( nproc) pyspiel
134-
135- # Stage 2: Use the specified openenv-base image
136- FROM $BASE_IMAGE_REF
137-
138- # Copy OpenSpiel build artifacts from builder
139- RUN mkdir -p /repo
140- COPY --from=openspiel-builder /repo /repo
141-
142- # Install OpenSpiel Python requirements in runtime
143- WORKDIR /repo
144- RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
145-
146- # Set Python path for OpenSpiel
147- ENV PYTHONPATH=/repo:/repo/build/python:${PYTHONPATH}
148-
149- # Copy OpenEnv core
97+ # OpenSpiel environment using pre-built OpenSpiel base image
98+ # Use the pre-built OpenSpiel base image (contains compiled OpenSpiel)
99+ # Built from: docker build -t openspiel-base:latest -f src/envs/openspiel_env/server/Dockerfile.openspiel-base .
100+ # In GitHub Actions, this is overridden to use the GHCR base image
101+ ARG OPENSPIEL_BASE_IMAGE=openspiel-base:latest
102+ FROM \$ {OPENSPIEL_BASE_IMAGE}
103+
104+ # Copy OpenEnv core (base image already set WORKDIR=/app)
150105WORKDIR /app
151106COPY src/core/ /app/src/core/
107+
108+ # Copy OpenSpiel environment
152109COPY src/envs/openspiel_env/ /app/src/envs/openspiel_env/
153110
111+ # Copy README for web interface documentation
112+ COPY src/envs/openspiel_env/README.md /app/README.md
113+
154114# Extend Python path for OpenEnv (base image set PYTHONPATH=/app/src)
155115# We prepend OpenSpiel paths
156116ENV PYTHONPATH=/repo:/repo/build/python:/app/src
@@ -160,11 +120,13 @@ ENV OPENSPIEL_GAME=catch
160120ENV OPENSPIEL_AGENT_PLAYER=0
161121ENV OPENSPIEL_OPPONENT_POLICY=random
162122
163- # Health check
123+ # Health check (curl is provided by openenv-base)
164124HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
165125 CMD curl -f http://localhost:8000/health || exit 1
166126
167- # Run the FastAPI server
127+ # Note: EXPOSE 8000 already set by openenv-base
128+
129+ # Run the FastAPI server (uvicorn installed by openenv-base)
168130CMD ["uvicorn", "envs.openspiel_env.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
169131DOCKERFILE_EOF
170132 echo " Created special OpenSpiel Dockerfile with C++ build process"
@@ -205,12 +167,46 @@ create_readme() {
205167 # Capitalize first letter of environment name
206168 env_title=$( echo " $env_name " | awk ' {print toupper(substr($0,1,1)) substr($0,2)}' )
207169
170+ # Set environment-specific colors and emoji
171+ case $env_name in
172+ " atari_env" )
173+ EMOJI=" 🕹️"
174+ COLOR_FROM=" #FF6200"
175+ COLOR_TO=" #D4151B"
176+ ;;
177+ " coding_env" )
178+ EMOJI=" 💻"
179+ COLOR_FROM=" #007ACC"
180+ COLOR_TO=" #1E1E1E"
181+ ;;
182+ " openspiel_env" )
183+ EMOJI=" 🎮"
184+ COLOR_FROM=" #9146FF"
185+ COLOR_TO=" #00FFA3"
186+ ;;
187+ " echo_env" )
188+ EMOJI=" 🔊"
189+ COLOR_FROM=" #00C9FF"
190+ COLOR_TO=" #1B2845"
191+ ;;
192+ " chat_env" )
193+ EMOJI=" 💬"
194+ COLOR_FROM=" #0084FF"
195+ COLOR_TO=" #25D366"
196+ ;;
197+ * )
198+ EMOJI=" 🐳"
199+ COLOR_FROM=" blue"
200+ COLOR_TO=" green"
201+ ;;
202+ esac
203+
208204 cat > $CURRENT_STAGING_DIR /README.md << README_EOF
209205---
210206title: ${env_title} Environment Server
211- emoji: 🐳
212- colorFrom: blue
213- colorTo: green
207+ emoji: ${EMOJI}
208+ colorFrom: ${COLOR_FROM}
209+ colorTo: ${COLOR_TO}
214210sdk: docker
215211pinned: false
216212app_port: 8000
@@ -310,9 +306,10 @@ Provides access to OpenSpiel games for multi-agent reinforcement learning.
310306Send a POST request to `/step` with:
311307```json
312308{
313- "action": 0
309+ "action": {
310+ "action_id": 1
311+ }
314312}
315- ```
316313README_EOF
317314 ;;
318315 esac
0 commit comments