mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Fix user permissions in docker (#1565)
* permissions mostly working * fix browser
This commit is contained in:
@@ -33,7 +33,7 @@ FROM python:3.12-slim as runtime
|
||||
WORKDIR /app
|
||||
|
||||
ENV RUN_AS_DEVIN=true
|
||||
ENV SANDBOX_USER_ID=1000
|
||||
ENV OPENDEVIN_USER_ID=1000
|
||||
ENV USE_HOST_NETWORK=false
|
||||
ENV SSH_HOSTNAME=host.docker.internal
|
||||
ENV WORKSPACE_BASE=/opt/workspace_base
|
||||
@@ -43,29 +43,33 @@ RUN mkdir -p $WORKSPACE_BASE
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y curl ssh sudo
|
||||
|
||||
RUN useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash opendevin && \
|
||||
RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs # Default is 1000, but OSX is often 501
|
||||
|
||||
RUN groupadd app
|
||||
RUN useradd -l -m -u $OPENDEVIN_USER_ID -s /bin/bash opendevin && \
|
||||
usermod -aG app opendevin && \
|
||||
usermod -aG sudo opendevin && \
|
||||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
RUN chown -R opendevin:opendevin /app
|
||||
RUN chown -R opendevin:app /app && chmod -R 770 /app
|
||||
USER opendevin
|
||||
|
||||
ENV VIRTUAL_ENV=/app/.venv \
|
||||
PATH="/app/.venv/bin:$PATH" \
|
||||
PYTHONPATH='/app'
|
||||
|
||||
COPY --chown=opendevin --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
USER root
|
||||
RUN chown -R opendevin:opendevin ${VIRTUAL_ENV}
|
||||
USER opendevin
|
||||
|
||||
COPY --chown=opendevin ./opendevin ./opendevin
|
||||
COPY --chown=opendevin ./agenthub ./agenthub
|
||||
RUN python opendevin/core/download.py # No-op to download assets
|
||||
COPY --chown=opendevin:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
RUN playwright install --with-deps chromium
|
||||
|
||||
COPY --chown=opendevin --from=frontend-builder /app/dist ./frontend/dist
|
||||
COPY --chown=opendevin:app --chmod=770 ./opendevin ./opendevin
|
||||
COPY --chown=opendevin:app --chmod=777 ./opendevin/runtime/plugins ./opendevin/runtime/plugins
|
||||
COPY --chown=opendevin:app --chmod=770 ./agenthub ./agenthub
|
||||
|
||||
COPY --chown=opendevin ./containers/app/entrypoint.sh /app/entrypoint.sh
|
||||
RUN python opendevin/core/download.py # No-op to download assets
|
||||
RUN chown -R opendevin:app /app/logs && chmod -R 770 /app/logs # This gets created by the download.py script
|
||||
|
||||
|
||||
COPY --chown=opendevin:app --chmod=770 --from=frontend-builder /app/dist ./frontend/dist
|
||||
COPY --chown=opendevin:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
USER root
|
||||
CMD ["/app/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user