Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions arm/image_handle/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}
41 changes: 41 additions & 0 deletions arm/image_handle/build.bash
Original file line number Diff line number Diff line change
@@ -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
Loading