perf: eliminate slow chown operations in Docker builds (~41min → seconds) (#12256)

Co-authored-by: Pranjal Gupta <19pran@gmail.com>
This commit is contained in:
Pranjal Gupta
2026-01-09 02:29:43 +11:00
committed by GitHub
parent 6475aa3487
commit 39f0e6ed94

View File

@@ -223,12 +223,12 @@ RUN \
# Set environment variables (requires root)
/openhands/micromamba/bin/micromamba run -n openhands poetry run python -c "import sys; print('OH_INTERPRETER_PATH=' + sys.executable)" >> /etc/environment && \
# Set permissions for shared read-only access
# Note: chown -R operations removed - files are now created with correct ownership
# by running micromamba/poetry as openhands user (see install_dependencies_user)
chmod -R 755 /openhands/poetry && \
chmod -R 755 /openhands/micromamba && \
chown -R openhands:openhands /openhands/poetry && \
mkdir -p /openhands/workspace && chmod -R g+rws,o+rw /openhands/workspace && \
chown -R openhands:openhands /openhands/workspace && \
chown -R openhands:openhands /openhands/micromamba && \
# Ensure PATH includes system binaries early in startup
echo 'export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"' >> /etc/environment && \
echo 'export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"' >> /etc/bash.bashrc && \
@@ -290,8 +290,11 @@ RUN mkdir -p /openhands/micromamba/bin && \
echo 'export PATH="/openhands/micromamba/bin:$PATH"' >> /etc/environment
# Create the openhands virtual environment and install poetry and python
# Run as openhands user to avoid expensive chown -R operations later
USER openhands
RUN /openhands/micromamba/bin/micromamba create -n openhands -y && \
/openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry python=3.12 -y
USER root
# Create a clean openhands directory including only the pyproject.toml, poetry.lock and openhands/__init__.py
RUN \