diff --git a/arm/image_handle/Dockerfile b/arm/image_handle/Dockerfile new file mode 100644 index 0000000..3c60c3b --- /dev/null +++ b/arm/image_handle/Dockerfile @@ -0,0 +1,56 @@ +FROM ros:humble + +# 定义参数 +ARG USERNAME=Elaina +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +USER root + +RUN apt-get update && apt-get install -y \ + sudo \ + vim \ + nautilus \ + v4l-utils \ + git-lfs \ + python3-pip \ + libgl1-mesa-glx \ + ros-humble-rmw-zenoh-cpp \ + ros-humble-rmw-cyclonedds-cpp \ + ros-humble-cv-bridge \ + libzbar0 \ + && git lfs install --system \ + && rm -rf /var/lib/apt/lists/* + +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + +RUN pip3 install --no-cache-dir \ + imutils \ + qrcode \ + ultralytics \ + openvino \ + roslibpy \ + pyzmq \ + comet_ml \ + open3d \ + py-spy \ + pyzbar \ + "numpy<2.0" \ + pyserial \ + pyserial-asyncio + +ENV PYTHONPATH="/home/${USERNAME}/yolo:/home/${USERNAME}/yolo/cv_lib" + +RUN echo "source /opt/ros/humble/setup.bash" >> /home/${USERNAME}/.bashrc \ + && echo "export PATH=\$HOME/.local/bin:\$PATH" >> /home/${USERNAME}/.bashrc \ + && mkdir -p /home/${USERNAME}/.config/fish \ + && echo "set -gx PATH \$HOME/.local/bin \$PATH" >> /home/${USERNAME}/.config/fish/config.fish \ + && chown -R ${USERNAME}:${USERNAME} /home/${USERNAME} + +USER ${USERNAME} +WORKDIR /home/${USERNAME} \ No newline at end of file diff --git a/arm/image_handle/build.bash b/arm/image_handle/build.bash new file mode 100755 index 0000000..c27756c --- /dev/null +++ b/arm/image_handle/build.bash @@ -0,0 +1,41 @@ +#!/bin/bash + +# 获取脚本所在目录 +# 获取脚本所在目录的绝对路径 +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +PARENT_DIR=$(dirname "$SCRIPT_DIR") + +echo "脚本目录: $SCRIPT_DIR" +echo "父目录: $PARENT_DIR" + +# 设置默认 tag +TAG="yolo-ros-arm" + +# 从外部传入的 IMAGE_REPO(格式:ghcr.io/user/repo 或 docker.io/user/repo) +IMAGE_REPO="elainasuki/rc2026" + +# 组合完整镜像名 +IMAGE="$IMAGE_REPO:$TAG" + +# 获取工作流中的环境变量来决定是否支持 arm64 +PLATFORMS="linux/arm64" # 默认只支持 amd64 架构 + +if [[ "${BUILD_ARM64}" == "true" ]]; then + PLATFORMS="$PLATFORMS,linux/arm64" # 如果环境变量 BUILD_ARM64 为 true,则支持 arm64 架构 +fi +# 这里用的是docker build .. content是上一级而不是当前目录 +# 如果传入 --github-action 参数 +if [[ "$1" == "--github-action" ]]; then + echo "构建并推送镜像: $IMAGE" + docker buildx build \ + --platform $PLATFORMS \ + -t "$IMAGE" \ + -f "$SCRIPT_DIR/Dockerfile" \ + --cache-from "type=registry,ref=$IMAGE" \ + --cache-to type=inline \ + "$SCRIPT_DIR" \ + --push +else + echo "本地构建 $IMAGE" + docker build -t "$IMAGE" -f "$SCRIPT_DIR/Dockerfile" "$SCRIPT_DIR" +fi \ No newline at end of file