Dockerfile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-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 poetry install --without evaluation --no-root && rm -rf $POETRY_CACHE_DIR
  22. FROM python:3.12-slim as runtime
  23. WORKDIR /app
  24. ENV RUN_AS_DEVIN=true
  25. # A random number--we need this to be different from the user's UID on the host machine
  26. ENV OPENDEVIN_USER_ID=42420
  27. ENV USE_HOST_NETWORK=false
  28. ENV SSH_HOSTNAME=host.docker.internal
  29. ENV WORKSPACE_BASE=/opt/workspace_base
  30. ENV OPEN_DEVIN_BUILD_VERSION=$OPEN_DEVIN_BUILD_VERSION
  31. RUN mkdir -p $WORKSPACE_BASE
  32. RUN apt-get update -y \
  33. && apt-get install -y curl ssh sudo
  34. RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs # Default is 1000, but OSX is often 501
  35. RUN groupadd app
  36. RUN useradd -l -m -u $OPENDEVIN_USER_ID -s /bin/bash opendevin && \
  37. usermod -aG app opendevin && \
  38. usermod -aG sudo opendevin && \
  39. echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  40. RUN chown -R opendevin:app /app && chmod -R 770 /app
  41. USER opendevin
  42. ENV VIRTUAL_ENV=/app/.venv \
  43. PATH="/app/.venv/bin:$PATH" \
  44. PYTHONPATH='/app'
  45. COPY --chown=opendevin:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  46. RUN playwright install --with-deps chromium
  47. COPY --chown=opendevin:app --chmod=770 ./opendevin ./opendevin
  48. COPY --chown=opendevin:app --chmod=777 ./opendevin/runtime/plugins ./opendevin/runtime/plugins
  49. COPY --chown=opendevin:app --chmod=770 ./agenthub ./agenthub
  50. RUN python opendevin/core/download.py # No-op to download assets
  51. RUN chown -R opendevin:app /app/logs && chmod -R 770 /app/logs # This gets created by the download.py script
  52. COPY --chown=opendevin:app --chmod=770 --from=frontend-builder /app/dist ./frontend/dist
  53. COPY --chown=opendevin:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
  54. USER root
  55. CMD ["/app/entrypoint.sh"]