From 61323a76646cc4348c4685a8387ad25e68e338de Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Sun, 28 Dec 2025 19:11:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20Docker=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E5=B9=B6=E4=BF=AE=E5=A4=8D=20Ventoy?= =?UTF-8?q?=20=E8=B5=84=E6=BA=90=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: 合并 RUN 层减少镜像层数,使用 COPY --chmod 简化权限设置 - init.sh: 指定数据目录为 /etc/one-kvm 确保路径一致 - package-docker.sh: 从 libs/ventoy-img-rs/resources 复制资源并自动解压 xz 文件 - README.md: 修正 docker run 示例格式 --- README.md | 9 +++++---- build/Dockerfile.runtime | 34 +++++++--------------------------- build/init.sh | 2 +- build/package-docker.sh | 22 +++++++++++++++++----- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index ad223bb8..2ff2c63f 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,11 @@ One-KVM 是一个用 Rust 编写的开放轻量的 IP-KVM(基于 IP 的键盘 ```bash docker run -d --privileged \ - -v /dev:/dev \ - -v /sys/kernel/config:/sys/kernel/config \ - --net=host \ - siletwind0/one-kvm + --name one-kvm \ + -v /dev:/dev \ + -v /sys/kernel/config:/sys/kernel/config \ + --net=host \ + silentwind0/one-kvm ``` 访问 http://IP:8080 diff --git a/build/Dockerfile.runtime b/build/Dockerfile.runtime index f6465817..478993e9 100644 --- a/build/Dockerfile.runtime +++ b/build/Dockerfile.runtime @@ -8,7 +8,7 @@ FROM debian:12-slim ARG TARGETPLATFORM -# Install runtime dependencies only (matches build environment) +# Install runtime dependencies and create directories RUN apt-get update && apt-get install -y --no-install-recommends \ # Runtime libraries libasound2 \ @@ -38,39 +38,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libxcb1 \ # Utilities ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# Intel Media SDK runtime for x86_64 only -RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - apt-get update && \ - apt-get install -y --no-install-recommends libmfx1 && \ - rm -rf /var/lib/apt/lists/*; \ - fi - -# Create directories -RUN mkdir -p /etc/one-kvm/ventoy + # Intel Media SDK (x86_64 only, ignored on other archs) + $([ "$TARGETPLATFORM" = "linux/amd64" ] && echo "libmfx1") \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /etc/one-kvm/ventoy # Copy init script -COPY init.sh /init.sh +COPY --chmod=755 init.sh /init.sh # Copy binaries (these are placed by the build script) -COPY one-kvm /usr/bin/one-kvm -COPY ttyd /usr/bin/ttyd -COPY gostc /usr/bin/gostc -COPY easytier-core /usr/bin/easytier-core +COPY --chmod=755 one-kvm ttyd gostc easytier-core /usr/bin/ # Copy ventoy resources if they exist COPY ventoy/ /etc/one-kvm/ventoy/ -# Set permissions and verify -RUN chmod +x /init.sh /usr/bin/one-kvm /usr/bin/ttyd /usr/bin/gostc /usr/bin/easytier-core && \ - /usr/bin/one-kvm --help - -# Expose ports -EXPOSE 8080 8443 - -# Data volume -VOLUME ["/etc/one-kvm"] - # Entrypoint CMD ["/init.sh"] diff --git a/build/init.sh b/build/init.sh index 3652c51b..6929f8ae 100644 --- a/build/init.sh +++ b/build/init.sh @@ -6,7 +6,7 @@ set -e # Start one-kvm with default options # Additional options can be passed via environment variables -EXTRA_ARGS="" +EXTRA_ARGS="-d /etc/one-kvm" # Enable HTTPS if requested if [ "${ENABLE_HTTPS:-false}" = "true" ]; then diff --git a/build/package-docker.sh b/build/package-docker.sh index e73f56a4..813bbc59 100755 --- a/build/package-docker.sh +++ b/build/package-docker.sh @@ -232,12 +232,24 @@ build_for_platform() { # Copy init script cp "$PROJECT_ROOT/build/init.sh" "$staging/init.sh" - # Copy ventoy resources if they exist - if [ -d "$PROJECT_ROOT/res/ventoy" ]; then - cp -r "$PROJECT_ROOT/res/ventoy/"* "$staging/ventoy/" 2>/dev/null || true + # Copy ventoy resources (decompress xz files if needed) + local ventoy_src="$PROJECT_ROOT/libs/ventoy-img-rs/resources" + if [ -d "$ventoy_src" ]; then + echo_info "Copying Ventoy resources..." + # Copy boot.img directly + if [ -f "$ventoy_src/boot.img" ]; then + cp "$ventoy_src/boot.img" "$staging/ventoy/" + fi + # Decompress xz files + if [ -f "$ventoy_src/core.img.xz" ]; then + xz -dk "$ventoy_src/core.img.xz" -c > "$staging/ventoy/core.img" + fi + if [ -f "$ventoy_src/ventoy.disk.img.xz" ]; then + xz -dk "$ventoy_src/ventoy.disk.img.xz" -c > "$staging/ventoy/ventoy.disk.img" + fi + else + echo_warn "Ventoy resources not found at $ventoy_src" fi - # Ensure ventoy dir exists (even if empty) for COPY command - touch "$staging/ventoy/.keep" # Copy Dockerfile cp "$PROJECT_ROOT/build/Dockerfile.runtime" "$staging/Dockerfile"