Dockerfile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Derived from OpenMausBot server/container-computer.ts (Apache-2.0).
  2. # See third-party/openmausbot. Local changes: Yaoyao image metadata.
  3. FROM docker.io/trycua/xfce-cua@sha256:274eb636f5cf3fc58f705916ee72b7a701270b3877369d08533a385c5325be9b
  4. USER root
  5. RUN set -eux; \
  6. arch="$(uname -m)"; \
  7. case "$arch" in \
  8. x86_64) wheel_url='https://files.pythonhosted.org/packages/fa/d7/a43008a328a40c85e7bc706fc20235b9abedc75e28b413817655153157ff/cua_driver-0.20.0-py3-none-manylinux_2_31_x86_64.whl'; wheel_sha='f60c35696a37f37ac954935e478ae4754f220856d022036625c9400d72185961'; wheel_path='/tmp/cua_driver-0.20.0-py3-none-manylinux_2_31_x86_64.whl'; lib_triplet='x86_64-linux-gnu' ;; \
  9. aarch64|arm64) wheel_url='https://files.pythonhosted.org/packages/94/9d/1c1838b69067e83266c3d2aae02d74eef353a43dc8644884ccf03fe7f933/cua_driver-0.20.0-py3-none-manylinux_2_31_aarch64.whl'; wheel_sha='48833bc5e4c60e701fc9eefb57dbac36ec77ef3990f816fbbe85b4e954af2c77'; wheel_path='/tmp/cua_driver-0.20.0-py3-none-manylinux_2_31_aarch64.whl'; lib_triplet='aarch64-linux-gnu' ;; \
  10. *) echo "unsupported architecture: $arch" >&2; exit 1 ;; \
  11. esac; \
  12. for ssl_lib in "/lib/$lib_triplet/libssl.so.3" "/lib/$lib_triplet/libcrypto.so.3"; do \
  13. if [ -e "$ssl_lib" ] && [ ! -s "$ssl_lib" ]; then \
  14. echo "pinned base image is defective on $arch: $ssl_lib is zero bytes, so curl cannot start — re-pull or replace the base image instead of debugging the wheel download" >&2; \
  15. exit 1; \
  16. fi; \
  17. done; \
  18. curl -fsSL "$wheel_url" -o "$wheel_path"; \
  19. echo "$wheel_sha $wheel_path" | sha256sum -c -; \
  20. /opt/venv/bin/python -m pip install --no-cache-dir --force-reinstall --no-deps "$wheel_path"; \
  21. rm -f "$wheel_path"; \
  22. driver_bin="$(find /opt/venv/lib -path '*/cua_driver/bin/cua-driver' -type f -print -quit)"; \
  23. test -n "$driver_bin"; \
  24. install -D -m 0755 "$driver_bin" /usr/local/libexec/openmausbot/cua-driver; \
  25. install -d -o cua -g cua -m 0700 /home/cua/workspace; \
  26. test "$(/usr/local/libexec/openmausbot/cua-driver --version)" = "cua-driver 0.20.0"
  27. # Install before XFCE starts so the panel and window manager see the font too.
  28. # Noto Sans CJK JP is distributed under the SIL Open Font License 1.1.
  29. RUN set -eux; \
  30. install -d -m 0755 /usr/local/share/fonts; \
  31. curl -fsSL 'https://raw.githubusercontent.com/notofonts/noto-cjk/165c01b46ea533872e002e0785ff17e44f6d97d8/Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf' -o /usr/local/share/fonts/NotoSansCJKjp-Regular.otf; \
  32. echo '68a3fc98800b2a27b371f2fb79991daf3633bd89309d4ffaa6946fd587f375b5 /usr/local/share/fonts/NotoSansCJKjp-Regular.otf' | sha256sum -c -; \
  33. chmod 0644 /usr/local/share/fonts/NotoSansCJKjp-Regular.otf; \
  34. install -d -m 0755 /usr/local/share/licenses/noto-cjk; \
  35. curl -fsSL 'https://raw.githubusercontent.com/notofonts/noto-cjk/165c01b46ea533872e002e0785ff17e44f6d97d8/LICENSE' -o /usr/local/share/licenses/noto-cjk/OFL.txt; \
  36. echo '6a73f9541c2de74158c0e7cf6b0a58ef774f5a780bf191f2d7ec9cc53efe2bf2 /usr/local/share/licenses/noto-cjk/OFL.txt' | sha256sum -c -; \
  37. fc-cache -f
  38. RUN printf '%s\n' \
  39. '#!/bin/sh' \
  40. 'set -eu' \
  41. 'workspace=/home/cua/workspace' \
  42. 'profiles="$workspace/.browser-profiles"' \
  43. 'mkdir -p "$profiles/google-chrome" "$profiles/chromium" "$HOME/.config"' \
  44. 'if ! chmod 0700 "$workspace" "$profiles" "$profiles/google-chrome" "$profiles/chromium" 2>/dev/null; then' \
  45. ' for directory in "$workspace" "$profiles" "$profiles/google-chrome" "$profiles/chromium"; do' \
  46. ' test -r "$directory" && test -w "$directory" && test -x "$directory"' \
  47. ' done' \
  48. 'fi' \
  49. 'migrate_profile() {' \
  50. ' name="$1"' \
  51. ' source="$HOME/.config/$name"' \
  52. ' target="$profiles/$name"' \
  53. ' if [ -d "$source" ] && [ ! -L "$source" ] && [ -z "$(find "$target" -mindepth 1 -print -quit)" ]; then' \
  54. ' cp -a "$source"/. "$target"/' \
  55. ' fi' \
  56. ' rm -rf "$source"' \
  57. ' ln -s "$target" "$source"' \
  58. '}' \
  59. 'migrate_profile google-chrome' \
  60. 'migrate_profile chromium' \
  61. 'find "$profiles" \( -name SingletonLock -o -name SingletonSocket -o -name SingletonCookie -o -name .parentlock \) -delete' \
  62. > /usr/local/bin/prepare-openmausbot-workspace.sh \
  63. && chmod 0755 /usr/local/bin/prepare-openmausbot-workspace.sh
  64. RUN printf '%s\n' \
  65. '#!/bin/sh' \
  66. '/usr/local/bin/prepare-openmausbot-workspace.sh' \
  67. 'attempt=0' \
  68. 'until DISPLAY=:1 xset q >/dev/null 2>&1; do' \
  69. ' attempt=$((attempt + 1))' \
  70. ' if [ "$attempt" -ge 45 ]; then echo "X display :1 did not become ready within 45 seconds" >&2; exit 1; fi' \
  71. ' sleep 1' \
  72. 'done' \
  73. 'exec env CUA_DRIVER_INSTALL_CHANNEL=python_package CUA_DRIVER_RS_TELEMETRY_ENABLED=0 /usr/local/libexec/openmausbot/cua-driver serve --socket /run/user/1000/openmausbot-cua.sock --permission-mode standard' \
  74. > /usr/local/bin/start-openmausbot-cua-driver.sh \
  75. && chmod 0755 /usr/local/bin/start-openmausbot-cua-driver.sh
  76. RUN printf '%s\n' \
  77. '' \
  78. '[program:openmausbot-cua-driver]' \
  79. 'command=/usr/local/bin/start-openmausbot-cua-driver.sh' \
  80. 'user=cua' \
  81. 'environment=HOME="/home/cua",USER="cua",DISPLAY=":1"' \
  82. 'autorestart=true' \
  83. 'startsecs=2' \
  84. 'stdout_logfile=/var/log/supervisor/cua-driver.log' \
  85. 'stderr_logfile=/var/log/supervisor/cua-driver.error.log' \
  86. 'priority=30' \
  87. >> /etc/supervisor/supervisord.conf
  88. LABEL com.openmausbot.local-vm="1" \
  89. com.openmausbot.cua-driver="0.20.0" \
  90. com.openmausbot.cua-base="sha256:274eb636f5cf3fc58f705916ee72b7a701270b3877369d08533a385c5325be9b" \
  91. com.openmausbot.image-layer="5"
  92. LABEL cn.samien.yaoyao.computer-image="1"
  93. COPY prepare-firefox.sh /usr/local/bin/prepare-yaoyao-firefox.sh
  94. RUN chmod 0755 /usr/local/bin/prepare-yaoyao-firefox.sh \
  95. && sed -i '2i /usr/local/bin/prepare-yaoyao-firefox.sh || exit 1' /usr/local/bin/start-openmausbot-cua-driver.sh