|
| 1 | +# Dockerfile — open-source-alignment-faking |
| 2 | +# |
| 3 | +# Produces a reproducible environment with all system and Python dependencies |
| 4 | +# pre-installed. Fixes FP-1 (SSH submodule), FP-2 (uv PATH), FP-8 (ffmpeg). |
| 5 | +# |
| 6 | +# PREREQUISITES before building: |
| 7 | +# The safety-tooling submodule must be initialised in your local checkout. |
| 8 | +# If you cloned with --recurse-submodules and it failed (SSH key issue), run: |
| 9 | +# |
| 10 | +# git -c submodule.safety-tooling.url=https://github.com/safety-research/safety-tooling.git \ |
| 11 | +# submodule update --init --recursive |
| 12 | +# |
| 13 | +# Or just run: bash setup.sh |
| 14 | +# Then build: docker build -t alignment-faking . |
| 15 | +# |
| 16 | +# USAGE: |
| 17 | +# # Interactive shell (fill in your real keys): |
| 18 | +# docker run --rm -it \ |
| 19 | +# -e ANTHROPIC_API_KEY=sk-ant-... \ |
| 20 | +# -e OPENAI_API_KEY=sk-... \ |
| 21 | +# -e OPENAI_API_KEY1=sk-... \ |
| 22 | +# -v "$(pwd)/outputs:/workspace/outputs" \ |
| 23 | +# alignment-faking |
| 24 | +# |
| 25 | +# # Inside the container, run the pipeline: |
| 26 | +# bash experiments/examples/1_run_pipeline.sh claude-3-5-sonnet-20240620 |
| 27 | +# |
| 28 | +# # Or mount a .env file instead of passing -e flags: |
| 29 | +# docker run --rm -it \ |
| 30 | +# --env-file .env \ |
| 31 | +# -v "$(pwd)/outputs:/workspace/outputs" \ |
| 32 | +# alignment-faking |
| 33 | + |
| 34 | +FROM python:3.11-slim-bookworm |
| 35 | + |
| 36 | +# ── System dependencies ───────────────────────────────────────────────────── |
| 37 | +# ffmpeg : audio processing via pydub (FP-8) |
| 38 | +# git : submodule operations and huggingface-hub downloads |
| 39 | +# curl : uv installer |
| 40 | +# libgl1 : OpenCV (opencv-python) runtime dependency |
| 41 | +# libglib2.0-0: OpenCV runtime dependency |
| 42 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 43 | + ffmpeg \ |
| 44 | + git \ |
| 45 | + curl \ |
| 46 | + libgl1 \ |
| 47 | + libglib2.0-0 \ |
| 48 | + && rm -rf /var/lib/apt/lists/* |
| 49 | + |
| 50 | +# ── uv ───────────────────────────────────────────────────────────────────── |
| 51 | +# Install uv and add to PATH directly (FP-2: the 'source ~/.local/bin/env' |
| 52 | +# trick in the README does not work; we use export PATH instead). |
| 53 | +RUN curl -LsSf https://astral.sh/uv/install.sh | sh |
| 54 | +ENV PATH="/root/.local/bin:$PATH" |
| 55 | + |
| 56 | +# ── Application code ──────────────────────────────────────────────────────── |
| 57 | +WORKDIR /workspace |
| 58 | + |
| 59 | +# Copy repository (the safety-tooling submodule must already be present |
| 60 | +# in your local checkout — see prerequisites above). |
| 61 | +COPY . . |
| 62 | + |
| 63 | +# ── Python environment ────────────────────────────────────────────────────── |
| 64 | +# Create a venv at /workspace/.venv (FP-7: venv lives at repo root). |
| 65 | +RUN uv venv --python 3.11 .venv |
| 66 | + |
| 67 | +# Activate venv for subsequent RUN commands. |
| 68 | +ENV VIRTUAL_ENV="/workspace/.venv" |
| 69 | +ENV PATH="/workspace/.venv/bin:$PATH" |
| 70 | + |
| 71 | +# Install safety-tooling (editable) then repo requirements. |
| 72 | +RUN uv pip install -e safety-tooling |
| 73 | +RUN uv pip install -r requirements.txt |
| 74 | + |
| 75 | +# ── Runtime environment ───────────────────────────────────────────────────── |
| 76 | +# Make src/ importable as a package. |
| 77 | +ENV PYTHONPATH="/workspace" |
| 78 | + |
| 79 | +# API keys should be passed at runtime via --env-file or -e flags, never baked in. |
| 80 | +# The pipeline crashes if OPENAI_API_KEY is unset (FP-3); see .env.example for details. |
| 81 | + |
| 82 | +# Default: drop into an interactive bash shell so the researcher can run |
| 83 | +# whichever experiment they need. |
| 84 | +CMD ["/bin/bash"] |
0 commit comments