diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c22c8d2..c473f89 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,7 +8,7 @@ ARG USER_GID=$USER_UID WORKDIR /workspace/$USERNAME -RUN groupadd --gid $USER_GID $USERNAME \ +RUN groupadd --gid $USER_GID $USERNAME || true \ && groupadd -g 107 input \ && useradd -s /bin/bash --uid $USER_UID -g $USER_GID -G 107 -m $USERNAME \ && apt-get update \ @@ -22,16 +22,17 @@ RUN apt update && apt upgrade -y # Install Git RUN apt install -y git -# Copy to preload the ros packages -COPY ./ /workspace/$USERNAME/ - # Change user USER $USERNAME -# Rosdep update +# Source the ROS setup file +RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \ + echo "source /gazebo/gazebo_ws/install/setup.bash" >> ~/.bashrc + +# Install ROS dependencies RUN rosdep update +# Copy to preload the ros packages +COPY ./ /workspace/$USERNAME/ + RUN rosdep install --from-paths src --ignore-src --rosdistro humble -y -# Source the ROS setup file -RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc -RUN echo "source /gazebo/gazebo_ws/install/setup.bash" >> ~/.bashrc diff --git a/.dockerignore b/.dockerignore index 80dd262..cf145f1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ +build/ log/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05d5ac8..a3080a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,16 +3,19 @@ run-name: ${{ github.actor }} is working on ROS2 rove build on: [push] jobs: Build_rove: - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, docker] permissions: packages: write contents: read steps: - name: Check out the repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build docker compose run: | - docker compose run --user root devcontainer bash -c "colcon build" + docker compose build --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g) + - name: Build rove + run: | + docker compose run devcontainer bash -c "colcon build" diff --git a/docker-compose.yml b/docker-compose.yml index 209497c..524be03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,9 @@ services: build: context: . dockerfile: ./.devcontainer/Dockerfile + args: + - USER_UID=${USER_UID:-1000} + - USER_GID=${USER_GID:-1000} volumes: - ./:/workspace/rove - /tmp/.X11-unix:/tmp/.X11-unix