Dockerfile.j2 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {% if skip_init %}
  2. FROM {{ base_image }}
  3. {% else %}
  4. # ================================================================
  5. # START: Build Runtime Image from Scratch
  6. # ================================================================
  7. FROM {{ base_image }}
  8. {% if 'ubuntu' in base_image and (base_image.endswith(':latest') or base_image.endswith(':24.04')) %}
  9. {% set LIBGL_MESA = 'libgl1' %}
  10. {% else %}
  11. {% set LIBGL_MESA = 'libgl1-mesa-glx' %}
  12. {% endif %}
  13. # Install necessary packages and clean up in one layer
  14. RUN apt-get update && \
  15. apt-get install -y wget sudo apt-utils {{ LIBGL_MESA }} libasound2-plugins && \
  16. apt-get clean \
  17. && rm -rf /var/lib/apt/lists/*
  18. # Create necessary directories
  19. RUN mkdir -p /opendevin && \
  20. mkdir -p /opendevin/logs && \
  21. chmod 777 /opendevin/logs && \
  22. echo "" > /opendevin/bash.bashrc
  23. RUN if [ ! -d /opendevin/miniforge3 ]; then \
  24. wget --progress=bar:force -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \
  25. bash Miniforge3.sh -b -p /opendevin/miniforge3 && \
  26. rm Miniforge3.sh && \
  27. chmod -R g+w /opendevin/miniforge3 && \
  28. bash -c ". /opendevin/miniforge3/etc/profile.d/conda.sh && conda config --set changeps1 False && conda config --append channels conda-forge"; \
  29. fi
  30. # Install Python and Poetry
  31. RUN /opendevin/miniforge3/bin/mamba install python=3.11 -y
  32. RUN /opendevin/miniforge3/bin/mamba install conda-forge::poetry -y
  33. # ================================================================
  34. # END: Build Runtime Image from Scratch
  35. # ================================================================
  36. {% endif %}
  37. # ================================================================
  38. # START: Copy Project and Install/Update Dependencies
  39. # ================================================================
  40. COPY project.tar.gz /opendevin
  41. RUN if [ -d /opendevin/code ]; then rm -rf /opendevin/code; fi
  42. RUN cd /opendevin && tar -xzvf project.tar.gz && rm project.tar.gz
  43. RUN mv /opendevin/{{ source_code_dirname }} /opendevin/code
  44. # Install/Update Dependencies
  45. # 1. Install pyproject.toml via poetry
  46. # 2. Install playwright and chromium
  47. # 3. Clear poetry, apt, mamba caches
  48. RUN cd /opendevin/code && \
  49. /opendevin/miniforge3/bin/mamba run -n base poetry env use python3.11 && \
  50. /opendevin/miniforge3/bin/mamba run -n base poetry install --no-interaction --no-root && \
  51. apt-get update && \
  52. /opendevin/miniforge3/bin/mamba run -n base poetry run pip install playwright && \
  53. /opendevin/miniforge3/bin/mamba run -n base poetry run playwright install --with-deps chromium && \
  54. /opendevin/miniforge3/bin/mamba run -n base poetry cache clear --all . && \
  55. apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  56. /opendevin/miniforge3/bin/mamba clean --all
  57. # ================================================================
  58. # END: Copy Project and Install/Update Dependencies
  59. # ================================================================