Browse Source

fix: 添加 dbus-daemon 启动脚本

大侠咬超人 2 days ago
parent
commit
b37ed972d8
2 changed files with 17 additions and 0 deletions
  1. 5 0
      Dockerfile
  2. 12 0
      docker-entrypoint.sh

+ 5 - 0
Dockerfile

@@ -115,4 +115,9 @@ EXPOSE 8000
 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
     CMD php artisan --version || exit 1
     CMD php artisan --version || exit 1
 
 
+# 启动脚本:先启动 dbus,再运行主命令
+COPY docker-entrypoint.sh /usr/local/bin/
+RUN chmod +x /usr/local/bin/docker-entrypoint.sh
+
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
 CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
 CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]

+ 12 - 0
docker-entrypoint.sh

@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+# 启动 dbus 守护进程(Chrome 需要)
+if [ -x /usr/bin/dbus-daemon ]; then
+    mkdir -p /run/dbus
+    rm -f /run/dbus/pid
+    dbus-daemon --system --fork 2>/dev/null || true
+fi
+
+# 执行传入的命令
+exec "$@"