Skip to content

Commit

Permalink
Add dev docker and compose file that launches Qt Creator
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Oct 29, 2024
1 parent 0da3a34 commit da8b145
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ How to create:
* Create Video: `gource -1280x720 -seconds-per-day 0.2 --auto-skip-seconds 0.2 --disable-bloom -background d0d3d4 --hide filenames,mouse,progress -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4`
* Create Gif: `ffmpeg -i gource.mp4 -r 10 -vf "scale=800:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" tesseract_evolution.gif`

## Docker Development Container

It common to leverage docker to develop for different distributions of Ubuntu, so a docker compose file has been provided to simplify this process for Tesseract development.

Initial setup, you must create directories for the different distributions to save Qt Creator configs so they persist.

``` bash
mkdir ~/.config/QtProjectDocker
mkdir ~/.config/QtProjectDocker/focal
mkdir ~/.config/QtProjectDocker/noetic
mkdir ~/.config/QtProjectDocker/jammy
```

Now you can start the development docker. Replace focal with what ubuntu distro you want to develope with.

``` bash
cd <path to tesseract repo>/docker
USER_ID=$(id -u) GROUP_ID=$(id -g) UBUNTU_TAG=focal docker compose -f docker-compose-dev.yaml up --build --remove-orphans
```

## TODO's

Warning: These packages are under heavy development and are subject to change.
Expand Down
89 changes: 89 additions & 0 deletions docker/DockerfileDev
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
ARG UBUNTU_TAG
FROM ubuntu:${UBUNTU_TAG}

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

ENV DEBIAN_FRONTEND noninteractive

# Install
RUN apt update \
&& apt upgrade -y \
&& apt install -y sudo cmake curl git python3 wget gnupg2 g++ gcc software-properties-common locales \
&& locale-gen en_US.UTF-8

# Set environment variables to use UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

# Add ROS Independent Colcon
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# Add Gazebo
RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null

# Add Colcon
RUN curl -s https://packagecloud.io/install/repositories/dirk-thomas/colcon/script.deb.sh | bash

# Add Tesseract Robotics PPA
RUN add-apt-repository ppa:levi-armstrong/tesseract-robotics

# Install the dependency repositories
RUN apt update \
&& apt install -y \
python3-colcon-common-extensions \
libeigen3-dev \
libboost-all-dev \
coinor-libipopt-dev \
liborocos-kdl-dev \
libconsole-bridge-dev \
liboctomap-dev \
libfcl-dev \
libpcl-dev \
libompl-dev \
libyaml-cpp-dev \
libtinyxml2-dev \
libbullet-dev \
libbullet-extras-dev \
libgraphviz-dev \
libqwt-qt5-dev \
libqt5svg5-dev \
libqglviewer-dev-qt5 \
libxcb-cursor-dev \
libgz-rendering7-dev \
libgz-common5-av-dev \
libgz-common5-profiler-dev \
taskflow \
qt-advanced-docking-system

# Install the Qt Creator and Plugin
RUN wget https://download.qt.io/official_releases/qtcreator/14.0/14.0.2/cpack_experimental/qtcreator-opensource-linux-x86_64-14.0.2.deb \
&& dpkg -i qtcreator-opensource-linux-x86_64-14.0.2.deb \
&& echo 'export PATH=$PATH:/opt/qt-creator/bin' >> ~/.bashrc \
&& echo 'export PATH=$PATH:/opt/qt-creator/bin' >> ~/.profile \
&& echo 'export XDG_DATA_DIRS=$XDG_DATA_DIRS:/opt/qt-creator/share/' >> ~/.profile \
&& wget https://github.com/ros-industrial/ros_qtc_plugin/releases/download/14.2/ROSProjectManager-14.2-Linux-x86_64.deb \
&& dpkg -i ROSProjectManager-14.2-Linux-x86_64.deb

# Define build arguments for USERNAME, UID, and GID
ARG USERNAME
ARG USER_ID
ARG GROUP_ID

# Echo Args
RUN echo "USERNAME: ${USERNAME}" \
&& echo "USER_ID: ${USER_ID}" \
&& echo "GROUP_ID: ${GROUP_ID}" \
&& echo ""

# Create a group and user with the specified username, UID, and GID
RUN groupadd -g ${GROUP_ID} ${USERNAME} \
&& useradd -l -m -u ${USER_ID} -g ${GROUP_ID} -s /bin/bash ${USERNAME} -d /home/${USERNAME} \
&& chown ${USER_ID}:${GROUP_ID} /home/${USERNAME} \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set the default user
USER ${USERNAME}
WORKDIR /home/${USERNAME}
37 changes: 37 additions & 0 deletions docker/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Must create the following directories on the host machine
# - ~/.config/QtProjectDocker/focal
# - ~/.config/QtProjectDocker/noetic
# - ~/.config/QtProjectDocker/jammy
# Below is the example docker composer command
# - USER_ID=$(id -u) GROUP_ID=$(id -g) UBUNTU_TAG=focal docker compose -f docker-compose-dev.yaml up --build --remove-orphans
services:
qtcreator:
build:
context: .
dockerfile: DockerfileDev
args:
UBUNTU_TAG: "${UBUNTU_TAG}"
USERNAME: "${USER}" # Passes the host user's username
USER_ID: "${USER_ID}" # Passes the host user's UID
GROUP_ID: "${GROUP_ID}" # Passes the host user's GID
volumes:
- ~/catkin_ws/:/home/${USERNAME}/catkin_ws # Mount the project directory
- ~/.config/QtProjectDocker/${UBUNTU_TAG}:/home/${USERNAME}/.config/QtProject # Mount the QtCreator config location so changes persist
- /tmp/.X11-unix:/tmp/.X11-unix # Enable X11 forwarding
- /etc/hosts:/etc/hosts
- /dev/shm:/dev/shm
environment:
- DISPLAY=${DISPLAY} # Pass the DISPLAY variable from the host
- XAUTHORITY=${XAUTHORITY}
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
- USERNAME=${USER} # Passes the host user name
- USER_ID=${USER_ID} # Passes the host user's UID
- GROUP_ID=${GROUP_ID} # Passes the host user's GID
- SHELL=/bin/bash
user: "${USERNAME}"
ipc: host
network_mode: "host" # Allow access to host network for DISPLAY
privileged: true
stdin_open: true # Keeps STDIN open, useful for interactive mode
tty: true # Allocates a pseudo-TTY
command: /opt/qt-creator/bin/qtcreator

0 comments on commit da8b145

Please sign in to comment.