diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml index 3a835d9..4d25d35 100644 --- a/.github/workflows/build-docker-image.yaml +++ b/.github/workflows/build-docker-image.yaml @@ -3,7 +3,7 @@ name: Build a Docker Image on: push: workflow_dispatch: - + jobs: build: runs-on: ubuntu-20.04 @@ -12,8 +12,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set FOXGLOVE_VERSION env - run: echo "FOXGLOVE_VERSION=v1.72.0" >> $GITHUB_ENV + - name: "Set VERSION env" + run: echo "VERSION=$(docker run --rm --entrypoint /bin/bash husarion/${{ env.IMAGE_NAME }}:${{ inputs.ros_distro }}-nightly -c "cat /version.txt")" >> $GITHUB_ENV shell: bash - name: Set SHORT_DATE env @@ -22,32 +22,29 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: version: latest - + - name: Login to Docker Registry uses: docker/login-action@v2 with: registry: docker.io username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Build and push (production) if: github.ref_name == 'main' uses: docker/build-push-action@v3 with: platforms: linux/amd64, linux/arm64 push: true - build-args: | - FOXGLOVE_VERSION=${{ env.FOXGLOVE_VERSION }} tags: | - husarion/foxglove:${{ env.FOXGLOVE_VERSION }}-${{ env.SHORT_DATE }} - husarion/foxglove:${{ env.FOXGLOVE_VERSION }} + husarion/foxglove:${{ env.VERSION }}-${{ env.SHORT_DATE }} + husarion/foxglove:${{ env.VERSION }} husarion/foxglove:nightly - # cache-from: type=registry,ref=husarnet/dds-router cache-to: type=inline - name: Build and push (feature branch) @@ -56,10 +53,7 @@ jobs: with: platforms: linux/amd64, linux/arm64 push: true - build-args: | - FOXGLOVE_VERSION=${{ env.FOXGLOVE_VERSION }} tags: | - husarion/foxglove:${{ github.head_ref || github.ref_name }}-${{ env.FOXGLOVE_VERSION }} + husarion/foxglove:${{ github.head_ref || github.ref_name }}-${{ env.VERSION }} husarion/foxglove:nightly - # cache-from: type=registry,ref=husarnet/dds-router-${{ github.head_ref || github.ref_name }} cache-to: type=inline \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8fc7195..764bf84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,52 @@ -ARG FOXGLOVE_VERSION=v1.72.0 +ARG ROS_DISTRO=humble # URDF stage -FROM husarion/rviz2:humble-nightly as urdf_builder - -RUN apt-get update && apt-get install -y \ - python3-pip \ - python3-colcon-common-extensions \ - python3-rosdep \ - python3-vcstool \ - git && \ - git clone -b ros2-control https://github.com/husarion/panther_ros.git /ros2_ws/src/panther_ros && \ +FROM ros:$ROS_DISTRO-ros-base as urdf_builder + +SHELL ["/bin/bash", "-c"] + +WORKDIR /ros2_ws + +RUN apt update && \ + apt-get install -y \ + subversion \ + ros-$ROS_DISTRO-xacro && \ + mkdir src && \ + cd ./src && \ + svn checkout https://github.com/husarion/rosbot_ros/trunk/rosbot_description && \ + svn checkout https://github.com/husarion/rosbot_xl_ros/trunk/rosbot_xl_description && \ + git clone https://github.com/husarion/ros_components_description.git && \ + svn checkout https://github.com/husarion/open_manipulator_x/trunk/open_manipulator_x_description && \ + git clone -b ros2-control https://github.com/husarion/panther_ros.git && \ rm -rf /ros2_ws/src/panther_ros/panther && \ rm -rf /ros2_ws/src/panther_ros/panther_battery && \ rm -rf /ros2_ws/src/panther_ros/panther_controller && \ rm -rf /ros2_ws/src/panther_ros/panther_hardware_interfaces && \ - rm -rf /ros2_ws/src/panther_ros/panther_utils && \ - cd /ros2_ws && \ - source install/setup.bash && \ - colcon build + rm -rf /ros2_ws/src/panther_ros/panther_utils -RUN apt-get update -y && apt-get install -y ros-$ROS_DISTRO-xacro && \ +RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ + colcon build && \ source install/setup.bash && \ - xacro /ros2_ws/src/rosbot_ros/rosbot_description/urdf/rosbot.urdf.xacro > /rosbot.urdf && \ - xacro /ros2_ws/src/rosbot_xl_ros/rosbot_xl_description/urdf/rosbot_xl.urdf.xacro use_sim:=false simulation_controllers_config_file:=None > /rosbot_xl.urdf && \ + xacro /ros2_ws/src/rosbot_description/urdf/rosbot.urdf.xacro > /rosbot.urdf && \ + xacro /ros2_ws/src/rosbot_xl_description/urdf/rosbot_xl.urdf.xacro use_sim:=false simulation_controllers_config_file:=None > /rosbot_xl.urdf && \ xacro /ros2_ws/src/panther_ros/panther_description/urdf/panther.urdf.xacro > /panther.urdf && \ # Changing rotation is cause by .stl files in rosbot_ros/rosbot_description. We will change it to the .dae files. sed -i 's/rpy=\"1.5707963267948966 0.0 1.5707963267948966\"/rpy=\"0.0 0.0 1.5707963267948966\"/g' /rosbot.urdf -# Build stage -FROM node:16 as build - -ARG FOXGLOVE_VERSION - -RUN apt update && apt install -y \ - git-lfs - -WORKDIR /src -RUN git clone --branch $FOXGLOVE_VERSION https://github.com/foxglove/studio -WORKDIR /src/studio - -RUN corepack enable -RUN yarn install --immutable - -ENV FOXGLOVE_DISABLE_SIGN_IN=true -RUN yarn run web:build:prod - -# Release stage -FROM caddy:2.6.2-alpine - -ARG FOXGLOVE_VERSION +# Latest version: https://github.com/foxglove/studio/pkgs/container/studio +FROM ghcr.io/foxglove/studio:latest RUN apk update && apk add \ bash \ - nss-tools + nss-tools \ + curl \ + jq \ + sed SHELL ["/bin/bash", "-c"] WORKDIR /src -COPY --from=build /src/studio/web/.webpack . COPY FoxgloveDefaultLayout.json /foxglove/default-layout.json COPY Caddyfile /etc/caddy/ @@ -80,5 +68,7 @@ ENV UI_PORT=8080 # replace file:///ros2_ws with http://{{.Host}}:UI_PORT/ros2_ws in /src/rosbot_xl.urdf and /src/rosbot.urdf files RUN sed -i 's|file:///ros2_ws|http://{{.Host}}:{{env "UI_PORT"}}/ros2_ws|g' /src/rosbot_xl.urdf /src/rosbot.urdf /src/panther.urdf +RUN echo $(curl -s https://raw.githubusercontent.com/foxglove/studio/main/package.json | jq -r '.version' | sed -nE 's/.*\b([0-9]+\.[0-9]+\.[0-9]+)\b.*/\1/p') > /version.txt + ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 1a45ec4..0000000 --- a/compose.yaml +++ /dev/null @@ -1,17 +0,0 @@ -services: - foxglove: - build: . - network_mode: host - # ports: - # - 8080:8080 - environment: - - DS_TYPE=rosbridge-websocket - - DS_PORT=9090 - - UI_PORT=8080 - - rosbridge: - image: husarion/rosbridge-server:humble - network_mode: host - # ports: - # - 9090:9090 - command: ros2 launch rosbridge_server rosbridge_websocket_launch.xml diff --git a/demo/compose.yaml b/demo/compose.yaml index 04d985d..b5c2902 100644 --- a/demo/compose.yaml +++ b/demo/compose.yaml @@ -1,10 +1,13 @@ services: foxglove: - image: husarion/foxglove:v1.72.0 + # image: husarion/foxglove:v1.72.0 + build: + context: .. + dockerfile: Dockerfile ports: - 8080:8080 volumes: - - ./RosbotTeleop.json:/foxglove/default-layout.json + - ./foxglove-layout.json:/foxglove/default-layout.json environment: - DS_TYPE=rosbridge-websocket - DS_PORT=9090 @@ -14,4 +17,4 @@ services: image: husarion/rosbridge-server:humble ports: - 9090:9090 - command: ros2 launch rosbridge_server rosbridge_websocket_launch.xml + command: ros2 launch rosbridge_server rosbridge_websocket_launch.xml