52 lines
2.4 KiB
Docker
52 lines
2.4 KiB
Docker
FROM node:22-bookworm-slim AS frontend-build
|
|
WORKDIR /build/frontend
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
RUN npm ci
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
FROM node:22-bookworm-slim AS runtime-base
|
|
ARG CODEX_VERSION=latest
|
|
ARG CLAUDE_CODE_VERSION=latest
|
|
ARG OPENCODE_VERSION=latest
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONPATH=/app:/app/backend \
|
|
HOME=/home/codex
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends python3 python3-pip python3-dev gcc git gh openssh-client sshpass tmux docker.io ca-certificates \
|
|
&& python3 -m pip install --break-system-packages --no-cache-dir --upgrade pip setuptools==84.2.1 \
|
|
&& npm install --global "@openai/codex@${CODEX_VERSION}" "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" "opencode-ai@${OPENCODE_VERSION}" \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /app
|
|
COPY backend/requirements.txt /app/backend/requirements.txt
|
|
RUN python3 -m pip install --break-system-packages --no-cache-dir -r /app/backend/requirements.txt
|
|
COPY backend/ /app/backend/
|
|
COPY django_ui/ /app/django_ui/
|
|
COPY docs/ /app/docs/
|
|
COPY scripts/ /app/scripts/
|
|
COPY manage.py /app/manage.py
|
|
COPY --from=frontend-build /build/frontend/dist/ /app/frontend/dist/
|
|
RUN chmod +x /app/scripts/codexpi-browser /app/scripts/codexpi-remote /app/scripts/codexpi_bridge.py /app/scripts/codexpi-gitea-askpass \
|
|
&& ln -s /app/scripts/codexpi-browser /usr/local/bin/codexpi-browser \
|
|
&& ln -s /app/scripts/codexpi-remote /usr/local/bin/codexpi-remote \
|
|
&& mkdir -p /app/data /home/codex/.codex /home/codex/.claude /home/codex/.config/opencode /home/codex/.config/gh /home/codex/.local/share/opencode \
|
|
&& chown -R node:node /app /home/codex
|
|
USER node
|
|
|
|
FROM runtime-base AS test
|
|
USER root
|
|
COPY backend/requirements-dev.txt /app/backend/requirements-dev.txt
|
|
COPY tests/ /app/tests/
|
|
COPY Dockerfile docker-compose.yml pytest.ini /app/
|
|
COPY repair-rpi-with-codex.sh /app/repair-rpi-with-codex.sh
|
|
COPY deploy/ /app/deploy/
|
|
COPY frontend/index.html /app/frontend/index.html
|
|
COPY frontend/public/ /app/frontend/public/
|
|
RUN python3 -m pip install --break-system-packages --no-cache-dir -r /app/backend/requirements-dev.txt
|
|
USER node
|
|
CMD ["python3", "-m", "pytest", "-q"]
|
|
|
|
FROM runtime-base AS production
|
|
CMD ["python3", "-m", "uvicorn", "codexpi.main:app", "--app-dir", "/app/backend", "--host", "0.0.0.0", "--port", "8000"]
|