entrypoint.sh 896 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. # check user is root
  3. if [ "$(id -u)" -ne 0 ]; then
  4. echo "The OpenDevin entrypoint.sh must run as root"
  5. exit 1
  6. fi
  7. if [ -z "$SANDBOX_USER_ID" ]; then
  8. echo "SANDBOX_USER_ID is not set"
  9. exit 1
  10. fi
  11. # change uid of opendevin user to match the host user
  12. # but the group id is not changed, so the user can still access everything under /app
  13. useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser
  14. usermod -aG app enduser
  15. mkdir -p /home/enduser/.cache/ms-playwright/
  16. mv /home/opendevin/.cache/ms-playwright/ /home/enduser/.cache/
  17. # get the user group of /var/run/docker.sock and set opendevin to that group
  18. DOCKER_SOCKET_GID=$(stat -c '%g' /var/run/docker.sock)
  19. echo "Docker socket group id: $DOCKER_SOCKET_GID"
  20. usermod -aG $DOCKER_SOCKET_GID enduser
  21. # switch to the user and start the server
  22. su enduser -c "cd /app && uvicorn opendevin.server.listen:app --host 0.0.0.0 --port 3000"