Skip to content

Commit

Permalink
Merge pull request #2 from husarion/add-panther
Browse files Browse the repository at this point in the history
Add panther
  • Loading branch information
DominikN committed Oct 4, 2023
2 parents 4c49b36 + db86eaf commit 0906084
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 770 deletions.
111 changes: 56 additions & 55 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
name: Build/Publish Docker Image
name: Build a Docker Image

on:
on:
push:
workflow_dispatch:
inputs:
build_type:
description: "Is it a \"development\" or a \"stable\" release?"
required: true
default: 'development'
type: choice
options:
- development
- stable
target_distro:
description: "In case of \"stable\" release specify the ROS distro of the existing docker image (eg. humble)"
type: string
default: "ardent"
target_release:
description: "In case of \"stable\" release specify the version of the existing docker image (eg. 1.0.12)"
type: string
default: "0.0.0"
target_date:
description: "In case of \"stable\" release specify the date of the existing docker image in format YYYYMMDD (eg. 20220124)"
type: string
default: "20131206"
repository_dispatch:
types: [rebuild]
pull_request:
types:
- closed
- opened


jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:

include:
- dockerfile: Dockerfile
platforms: "linux/amd64, linux/arm64"
ros_distro: "humble"
repo_name: foxglove

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set FOXGLOVE_VERSION env
run: echo "FOXGLOVE_VERSION=v1.72.0" >> $GITHUB_ENV
shell: bash

- name: Set SHORT_DATE env
run: echo "SHORT_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
shell: bash

- name: Checkout
uses: actions/checkout@v2
- 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:nightly
# cache-from: type=registry,ref=husarnet/dds-router
cache-to: type=inline

- name: Build Docker Image
uses: husarion-ci/[email protected]
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
dockerfile: ${{ matrix.dockerfile }}
repo_name: ${{ matrix.repo_name }}
build_type: ${{ inputs.build_type }}
ros_distro: ${{ matrix.ros_distro }}
platforms: ${{ matrix.platforms }}
# variables important only for stable release
target_distro: ${{ inputs.target_distro }}
target_release: ${{ inputs.target_release }}
target_date: ${{ inputs.target_date }}
- name: Build and push (feature branch)
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:${{ github.head_ref || github.ref_name }}-${{ env.FOXGLOVE_VERSION }}
husarion/foxglove:nightly
# cache-from: type=registry,ref=husarnet/dds-router-${{ github.head_ref || github.ref_name }}
cache-to: type=inline
33 changes: 11 additions & 22 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
# Listen on localhost on the specified port
:{$FOXGLOVE_PORT} {
root * /src
:{$UI_PORT} {
tls internal

root * /src

redir /ui /?ds={$DS_TYPE}&ds.url=ws%3A%2F%2F{http.request.host}%3A{$DS_PORT}

templates {
mime "application/json" "text/plain"
mime "application/json" "text/plain" "text/html"
}

file_server browse
file_server browse

@urdf path /*.urdf

header @urdf {
Content-Type "text/plain"
}

# respond /get-default-ws "{{.Host}}{{env 'FOXGLOVE_PORT'}}" 200 {
# close
# }

header {
# get rid of CORS error
Access-Control-Allow-Origin *
Access-Control-Allow-Credentials true
Access-Control-Allow-Methods *
Access-Control-Allow-Headers *
defer
# Disable caching
Cache-Control "no-cache, no-store, must-revalidate"
}
header @urdf {
Content-Type "text/plain"
}
}
57 changes: 33 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
ARG FOXGLOVE_VERSION=v1.39.1
ARG FOXGLOVE_VERSION=v1.72.0

# 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 && \
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

RUN apt-get update -y && apt-get install -y ros-$ROS_DISTRO-xacro && \
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 > /rosbot_xl.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/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

Expand All @@ -21,13 +39,6 @@ WORKDIR /src
RUN git clone --branch $FOXGLOVE_VERSION https://github.com/foxglove/studio
WORKDIR /src/studio

COPY studio-files/defaultLayout.ts ./packages/studio-base/src/providers/CurrentLayoutProvider/defaultLayout.ts
COPY studio-files/Start.tsx ./packages/studio-base/src/components/OpenDialog/Start.tsx
COPY studio-files/Root.tsx ./web/src/Root.tsx
COPY studio-files/RosbridgeDataSourceFactory.ts ./packages/studio-base/src/dataSources/RosbridgeDataSourceFactory.ts
RUN grep -rl 'showOpenDialogOnStartup = true' ./packages/studio-base/src/Workspace.tsx \
| xargs sed -i 's/showOpenDialogOnStartup = true/showOpenDialogOnStartup = false/g'

RUN corepack enable
RUN yarn install --immutable

Expand All @@ -39,37 +50,35 @@ FROM caddy:2.6.2-alpine

ARG FOXGLOVE_VERSION

RUN apk update && apk add bash
RUN apk update && apk add \
bash \
nss-tools

SHELL ["/bin/bash", "-c"]

WORKDIR /src

COPY --from=build /src/studio/web/.webpack .
COPY FoxgloveDefaultLayout.json .
COPY default-url.txt .
COPY FoxgloveDefaultLayout.json /foxglove/default-layout.json

COPY Caddyfile /etc/caddy/
COPY caddy_entrypoint.sh /
COPY entrypoint.sh /

# copy URDFs
COPY --from=urdf_builder /ros2_ws ./ros2_ws
COPY --from=urdf_builder /rosbot.urdf .
COPY --from=urdf_builder /rosbot_xl.urdf .

# replace file:///ros2_ws with http://{{.Host}}:FOXGLOVE_PORT/ros2_ws in /src/rosbot_xl.urdf and /src/rosbot.urdf files
RUN sed -i 's|file:///ros2_ws|http://{{.Host}}:{{env "FOXGLOVE_PORT"}}/ros2_ws|g' /src/rosbot_xl.urdf /src/rosbot.urdf

# replace localhost:8080 with {{.Host}}:FOXGLOVE_PORT in /src/FoxgloveDefaultLayout.json file
RUN sed -i 's|localhost:8080|{{.Host}}:{{env "FOXGLOVE_PORT"}}|g' /src/FoxgloveDefaultLayout.json
COPY --from=urdf_builder /panther.urdf .

EXPOSE 8080
# CMD ["caddy", "file-server", "--listen", ":8080"]

RUN echo $(echo $FOXGLOVE_VERSION | sed -r 's/v([0-9]+.[0-9]+.[0-9]+)/\1/g') > /version.txt
ENV DS_TYPE=rosbridge-websocket
# ENV DS_TYPE=foxglove-websocket
ENV DS_PORT=9090
ENV UI_PORT=8080

ENV FOXGLOVE_PORT=8080
ENV ROSBRIDGE_PORT=9090
# 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

# ENTRYPOINT [ "/bin/bash", "/caddy_entrypoint.sh" ]
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
Loading

0 comments on commit 0906084

Please sign in to comment.