uc_salary_aggregator/Dockerfile

119 lines
3.6 KiB
Docker

# =============================================================================
# UC Salary Analysis — Dev Container
# =============================================================================
# This container lets you run Claude Code in a Docker container so it can't
# access your file system. It also helps set things up for a web tool later,
# and has the proper dependencies. Tested on Linux, should work on macOS too.
#
# Multi-stage build with two named targets:
#
# claude-code — Claude Code + Python data pipeline tools
# for UCOP scraper refactor and classifier work
#
# webdev — All of the above + Node.js/Vite/React toolchain
# for the interactive UC salary visualisation site
#
# BUILD
# docker build --target claude-code -t uc-claude-code .
# docker build --target webdev -t uc-webdev .
#
# RUN (Claude Code)
# docker run -it --rm \
# -v $(pwd):/workspace \
# -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
# uc-claude-code
#
# RUN (web dev, with hot-reload on host port 5173)
# docker run -it --rm \
# -v $(pwd):/workspace \
# -p 5173:5173 \
# uc-webdev
#
# The workspace is mounted at /workspace in all cases.
# =============================================================================
ARG DEBIAN_FRONTEND=noninteractive
ARG NODE_MAJOR=22
# -----------------------------------------------------------------------------
# Stage 0 — base: Debian trixie + common system deps
# -----------------------------------------------------------------------------
FROM debian:trixie-slim AS base
ARG DEBIAN_FRONTEND
ARG NODE_MAJOR
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
curl \
wget \
ca-certificates \
gnupg \
git \
git-lfs \
unzip \
jq \
ripgrep \
python3 \
python3-pip \
python3-venv \
python3-dev \
build-essential \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --no-cache-dir \
requests \
pandas \
matplotlib \
openpyxl
# -----------------------------------------------------------------------------
# Stage 1 — claude-code: add Claude Code CLI
# -----------------------------------------------------------------------------
FROM base AS claude-code
ARG NODE_MAJOR
# Install Node.js via nodesource signed apt repo
# (the setup_*.x | bash method returns 404 as of 2025)
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /usr/share/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] \
https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g @anthropic-ai/claude-code
WORKDIR /workspace
CMD ["bash"]
# -----------------------------------------------------------------------------
# Stage 2 — webdev: add full frontend toolchain on top of claude-code
# Exposes Vite at 5173 and FastAPI/uvicorn at 8000 to serve
# JSON to the frontend for a future tool or smth..
# -----------------------------------------------------------------------------
FROM claude-code AS webdev
RUN apt-get update && apt-get install -y --no-install-recommends \
libvips-dev \
procps \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir \
fastapi \
"uvicorn[standard]" \
pydantic
EXPOSE 5173
EXPOSE 8000
WORKDIR /workspace
CMD ["bash"]