Skip to content

Commit 55ddff2

Browse files
Add evaluation server and Railway deployment
- FastAPI server for student policy submissions - Evaluation runner for PufferLib environments - SQLite leaderboard - Docker setup with base image for fast deploys - GitHub Action to build base image on native x86_64
1 parent ab75a78 commit 55ddff2

15 files changed

Lines changed: 1064 additions & 1 deletion

File tree

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.git
2+
.venv
3+
.claude
4+
__pycache__
5+
*.pyc
6+
*.db
7+
examples/
8+
resources
9+
uv.lock
10+
*.md
11+
.gitignore
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Base Image
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
push:
6+
paths:
7+
- 'Dockerfile.base'
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository_owner }}/rl-eval-base
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build and push
32+
uses: docker/build-push-action@v5
33+
with:
34+
context: .
35+
file: ./Dockerfile.base
36+
push: true
37+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,5 @@ models/
217217
*.ckpt
218218
tensorboard/
219219
resources
220+
server/leaderboard.db
221+
*.db

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Use pre-built base image with all dependencies
2+
# Build base with: docker build --platform linux/amd64 -t USERNAME/rl-eval-base -f Dockerfile.base .
3+
# Push with: docker push USERNAME/rl-eval-base
4+
FROM ghcr.io/eugenevinitsky/rl-eval-base:latest
5+
6+
WORKDIR /app
7+
8+
# Copy application code (this is the only thing that changes between deploys)
9+
COPY server/ /app/server/
10+
11+
# Create data directory
12+
RUN mkdir -p /data
13+
14+
ENV DATA_DIR=/data
15+
ENV PORT=8000
16+
17+
EXPOSE 8000
18+
19+
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.base

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Install system dependencies
6+
RUN apt-get update && apt-get install -y \
7+
build-essential \
8+
git \
9+
curl \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Install uv for faster pip operations
13+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
14+
ENV PATH="/root/.local/bin:$PATH"
15+
16+
# Install PyTorch CPU-only
17+
RUN uv pip install --system --no-cache \
18+
torch --index-url https://download.pytorch.org/whl/cpu
19+
20+
# Install pufferlib and other heavy deps (this is the slow part)
21+
RUN uv pip install --system --no-cache \
22+
numpy gymnasium pufferlib
23+
24+
# Install web deps
25+
RUN uv pip install --system --no-cache \
26+
fastapi uvicorn python-multipart

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: uvicorn server.app:app --host 0.0.0.0 --port $PORT

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ description = "Reinforcement Learning course project using PufferLib"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
8+
"fastapi>=0.128.0",
89
"pufferlib>=3.0.0",
10+
"python-multipart>=0.0.21",
11+
"uvicorn>=0.40.0",
912
]

railway.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[build]
2+
builder = "dockerfile"
3+
dockerfilePath = "Dockerfile"
4+
5+
[deploy]
6+
healthcheckPath = "/health"
7+
healthcheckTimeout = 30
8+
restartPolicyType = "on_failure"
9+
restartPolicyMaxRetries = 3

0 commit comments

Comments
 (0)