Dockerfile 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ARG OPEN_DEVIN_BUILD_VERSION=dev
  2. FROM node:21.7.2-bookworm-slim AS frontend-builder
  3. WORKDIR /app
  4. COPY ./frontend/package.json frontend/package-lock.json ./
  5. RUN npm install -g npm@10.5.1
  6. RUN npm ci
  7. COPY ./frontend ./
  8. RUN npm run make-i18n && npm run build
  9. FROM python:3.12.3-slim AS backend-builder
  10. WORKDIR /app
  11. ENV PYTHONPATH='/app'
  12. ENV POETRY_NO_INTERACTION=1 \
  13. POETRY_VIRTUALENVS_IN_PROJECT=1 \
  14. POETRY_VIRTUALENVS_CREATE=1 \
  15. POETRY_CACHE_DIR=/tmp/poetry_cache
  16. RUN apt-get update -y \
  17. && apt-get install -y curl make git build-essential \
  18. && python3 -m pip install poetry==1.8.2 --break-system-packages
  19. COPY ./pyproject.toml ./poetry.lock ./
  20. RUN touch README.md
  21. RUN export POETRY_CACHE_DIR && poetry install --without evaluation,llama-index --no-root && rm -rf $POETRY_CACHE_DIR
  22. FROM python:3.12.3-slim AS runtime
  23. WORKDIR /app
  24. ARG OPEN_DEVIN_BUILD_VERSION #re-declare for this section
  25. ENV RUN_AS_DEVIN=true
  26. # A random number--we need this to be different from the user's UID on the host machine
  27. ENV OPENDEVIN_USER_ID=42420
  28. ENV SANDBOX_API_HOSTNAME=host.docker.internal
  29. ENV USE_HOST_NETWORK=false
  30. ENV WORKSPACE_BASE=/opt/workspace_base
  31. ENV OPEN_DEVIN_BUILD_VERSION=$OPEN_DEVIN_BUILD_VERSION
  32. RUN mkdir -p $WORKSPACE_BASE
  33. RUN apt-get update -y \
  34. && apt-get install -y curl ssh sudo
  35. # Default is 1000, but OSX is often 501
  36. RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs
  37. # Default is 60000, but we've seen up to 200000
  38. RUN sed -i 's/^UID_MAX.*/UID_MAX 1000000/' /etc/login.defs
  39. RUN groupadd app
  40. RUN useradd -l -m -u $OPENDEVIN_USER_ID -s /bin/bash opendevin && \
  41. usermod -aG app opendevin && \
  42. usermod -aG sudo opendevin && \
  43. echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  44. RUN chown -R opendevin:app /app && chmod -R 770 /app
  45. RUN sudo chown -R opendevin:app $WORKSPACE_BASE && sudo chmod -R 770 $WORKSPACE_BASE
  46. USER opendevin
  47. ENV VIRTUAL_ENV=/app/.venv \
  48. PATH="/app/.venv/bin:$PATH" \
  49. PYTHONPATH='/app'
  50. COPY --chown=opendevin:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  51. RUN playwright install --with-deps chromium
  52. COPY --chown=opendevin:app --chmod=770 ./opendevin ./opendevin
  53. COPY --chown=opendevin:app --chmod=777 ./opendevin/runtime/plugins ./opendevin/runtime/plugins
  54. COPY --chown=opendevin:app --chmod=770 ./agenthub ./agenthub
  55. COPY --chown=opendevin:app --chmod=770 ./pyproject.toml ./pyproject.toml
  56. COPY --chown=opendevin:app --chmod=770 ./poetry.lock ./poetry.lock
  57. COPY --chown=opendevin:app --chmod=770 ./README.md ./README.md
  58. COPY --chown=opendevin:app --chmod=770 ./MANIFEST.in ./MANIFEST.in
  59. # This is run as "opendevin" user, and will create __pycache__ with opendevin:opendevin ownership
  60. RUN python opendevin/core/download.py # No-op to download assets
  61. # Add this line to set group ownership of all files/directories not already in "app" group
  62. # opendevin:opendevin -> opendevin:app
  63. RUN find /app \! -group app -exec chgrp app {} +
  64. RUN chown -R opendevin:app /app/logs && chmod -R 770 /app/logs # This gets created by the download.py script
  65. COPY --chown=opendevin:app --chmod=770 --from=frontend-builder /app/dist ./frontend/dist
  66. COPY --chown=opendevin:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
  67. USER root
  68. WORKDIR /app
  69. ENTRYPOINT ["/app/entrypoint.sh"]
  70. CMD ["uvicorn", "opendevin.server.listen:app", "--host", "0.0.0.0", "--port", "3000"]