ignatius-nobel/meta_hackathon
1
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 the5# LICENSE file in the root directory of this source tree.6 7# =============================================================================8# OpenSpiel Environment Dockerfile9# =============================================================================10#11# Uses a pre-built OpenSpiel base image to avoid long build times (~30-60 min).12# The base image contains compiled OpenSpiel (C++ and Python bindings).13#14# DEFAULT (recommended for HuggingFace Spaces):15# Uses pre-built image from GHCR - no C++ compilation needed16#17# BUILD YOUR OWN BASE IMAGE (if you need custom OpenSpiel configuration):18# 1. Build the base image first (takes ~30-60 min):19# docker build -t openspiel-base:latest -f server/Dockerfile.openspiel-base .20# 2. Then build with your local base image:21# docker build --build-arg OPENSPIEL_BASE_IMAGE=openspiel-base:latest -t openspiel-env .22#23# =============================================================================24 25# Default: use pre-built image from GHCR (skips C++ compilation)26ARG OPENSPIEL_BASE_IMAGE=ghcr.io/meta-pytorch/openenv-openspiel-base:sha-e622c7e27FROM ${OPENSPIEL_BASE_IMAGE}28 29WORKDIR /app30 31# Install git (needed for pip install from git repos in pyproject.toml)32RUN apt-get update && apt-get install -y --no-install-recommends git \33 && rm -rf /var/lib/apt/lists/*34 35# Copy environment code (context is the environment directory)36COPY . /app/env37 38# Install Python dependencies from pyproject.toml39WORKDIR /app/env40RUN pip3 install --no-cache-dir .41 42WORKDIR /app43 44# Copy README for web interface documentation45COPY README.md /app/README.md46 47# Python path configuration48# - /repo and /repo/build/python: OpenSpiel paths from base image49# - /app/env: Environment code50ENV PYTHONPATH=/repo:/repo/build/python:/app/env51 52# OpenSpiel-specific environment variables (can be overridden at runtime)53ENV OPENSPIEL_GAME=catch54ENV OPENSPIEL_AGENT_PLAYER=055ENV OPENSPIEL_OPPONENT_POLICY=random56 57# Uvicorn configuration58ENV WORKERS=159 60# Health check61HEALTHCHECK --interval=30s --timeout=3s --start-period=120s --retries=3 \62 CMD curl -f http://localhost:8000/health || exit 163 64EXPOSE 800065 66# Run the FastAPI server67ENV ENABLE_WEB_INTERFACE=true68CMD uvicorn server.app:app --host 0.0.0.0 --port 8000 --timeout-keep-alive 120 --workers ${WORKERS}69 