Skip to content

Commit

Permalink
Docker cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Oct 4, 2023
1 parent 0906084 commit 439e3f2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 76 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build a Docker Image
on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-20.04
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
72 changes: 31 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -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"]
17 changes: 0 additions & 17 deletions compose.yaml

This file was deleted.

9 changes: 6 additions & 3 deletions demo/compose.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 439e3f2

Please sign in to comment.