Skip to content

Commit

Permalink
docker: switch to Ubuntu 22.04 and clang-format-12
Browse files Browse the repository at this point in the history
This bases the PX4 v1.13 SITL build on top of Ubuntu 22.04. This is nice
because it allows us to switch to clang-format version 12.

clang-format-12 is a nice choice because it is available for both Ubuntu
20.04 as well as Ubuntu 22.04.
  • Loading branch information
julianoes committed Jul 14, 2022
1 parent a8583a2 commit 5951f41
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 9 deletions.
59 changes: 59 additions & 0 deletions docker/Dockerfile-Ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Development environment for MAVSDK based on Ubuntu 22.04.
#
# Author: Julian Oes <[email protected]>
#

FROM ubuntu:22.04
MAINTAINER Julian Oes <[email protected]>

ENV DEBIAN_FRONTEND noninteractive


RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
autoconf \
automake \
autotools-dev \
build-essential \
ca-certificates \
ccache \
clang-format-12 \
cmake \
colordiff \
doxygen \
git \
golang-go \
libcurl4-openssl-dev \
libltdl-dev \
libtinyxml2-dev \
libtool \
libz-dev \
ninja-build \
python3 \
python3-pip \
python3-future \
ruby-dev \
software-properties-common \
sudo \
wget \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

RUN gem install --no-document fpm;

RUN wget -qO- https://github.com/ncopa/su-exec/archive/dddd1567b7c76365e1e0aac561287975020a8fad.tar.gz | tar xvz && \
cd su-exec-* && make && mv su-exec /usr/local/bin && cd .. && rm -rf su-exec-*

# Create user with id 1001 (Jenkins docker workflow default)
RUN useradd --shell /bin/bash -u 1001 -c "" -m user

ADD /sudoers.txt /etc/sudoers
RUN chmod 440 /etc/sudoers

COPY entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

WORKDIR "/home/user/MAVSDK"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# PX4 v1.13 SITL testing environment for MAVSDK based on Ubuntu 20.04.
# PX4 v1.13 SITL testing environment for MAVSDK based on Ubuntu 22.04.
# Author: Julian Oes <[email protected]>
#
FROM mavsdk/mavsdk-ubuntu-20.04
FROM mavsdk/mavsdk-ubuntu-22.04
MAINTAINER Julian Oes <[email protected]>

ENV FIRMWARE_DIR ${WORKDIR}../Firmware
Expand All @@ -19,7 +19,9 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN git clone https://github.com/PX4/Firmware.git ${FIRMWARE_DIR}
RUN git -C ${FIRMWARE_DIR} switch release/1.13
RUN git -C ${FIRMWARE_DIR} checkout v1.13.0
# We need the updated ubuntu.sh script for Ubuntu 22.04
RUN git -C ${FIRMWARE_DIR} checkout 1a620b450d235d654751b5f28d882bd426aa6e39 -- Tools/setup/ubuntu.sh
RUN git -C ${FIRMWARE_DIR} submodule update --init --recursive
RUN wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
RUN cd ${FIRMWARE_DIR} && Tools/setup/ubuntu.sh --no-nuttx
Expand Down
6 changes: 4 additions & 2 deletions docker/build_and_push_docker_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ $DOCKER_CMD build -f Dockerfile-Fedora-34 -t mavsdk/mavsdk-fedora-34 .
$DOCKER_CMD build -f Dockerfile-Fedora-35 -t mavsdk/mavsdk-fedora-35 .
$DOCKER_CMD build -f Dockerfile-Fedora-36 -t mavsdk/mavsdk-fedora-36 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04 -t mavsdk/mavsdk-ubuntu-20.04 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-22.04 -t mavsdk/mavsdk-ubuntu-22.04 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04-PX4-SITL-v1.11 -t mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.11 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04-PX4-SITL-v1.12 -t mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.12 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04-PX4-SITL-v1.13 -t mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.13 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-22.04-PX4-SITL-v1.13 -t mavsdk/mavsdk-ubuntu-22.04-px4-sitl-v1.13 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04-APM-SITL-Copter-4.1.2 -t mavsdk/mavsdk-ubuntu-20.04-apm-sitl-copter-4.1.2 .
$DOCKER_CMD build -f Dockerfile-Ubuntu-20.04-APM-SITL-Rover-4.1.2 -t mavsdk/mavsdk-ubuntu-20.04-apm-sitl-rover-4.1.2 .
$DOCKER_CMD build -f Dockerfile.dockcross-linux-armv6-custom -t mavsdk/mavsdk-dockcross-linux-armv6-custom .
Expand All @@ -27,9 +28,10 @@ $DOCKER_CMD push mavsdk/mavsdk-fedora-34:latest
$DOCKER_CMD push mavsdk/mavsdk-fedora-35:latest
$DOCKER_CMD push mavsdk/mavsdk-fedora-36:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-22.04:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.11:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.12:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.13:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-22.04-px4-sitl-v1.13:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04-apm-sitl-copter-4.1.2:latest
$DOCKER_CMD push mavsdk/mavsdk-ubuntu-20.04-apm-sitl-rover-4.1.2:latest
$DOCKER_CMD push mavsdk/mavsdk-dockcross-linux-armv6-custom:latest
Expand Down
10 changes: 7 additions & 3 deletions tools/fix_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
# This script runs clang-format over all files ending in .h, .c, .cpp listed
# by git in the given directory.

version_required_major="10"
version_required_major="12"

# Try to find the latest version of clang
if command -v clang-format-10 >/dev/null; then
if command -v clang-format-12 >/dev/null; then
clang_format=clang-format-12
elif command -v clang-format-11 >/dev/null; then
clang_format=clang-format-11
elif command -v clang-format-10 >/dev/null; then
clang_format=clang-format-10
elif command -v clang-format-9 >/dev/null; then
clang_format=clang-format-9
Expand All @@ -29,7 +33,7 @@ if [[ $version =~ $semver_regex ]]; then
version_major=${BASH_REMATCH[1]}
if [ "$version_required_major" -gt "$version_major" ]; then
echo "Clang version $version_major too old (required: $version_required_major)"
echo "You can use clang-format-10 from docker:"
echo "You can use clang-format-12 from docker:"
echo ""
echo " 'tools/run-docker.sh tools/fix_style.sh .'"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion tools/run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

dockerimage=mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.11
dockerimage=mavsdk/mavsdk-ubuntu-22.04-px4-sitl-v1.13

if type podman > /dev/null 2> /dev/null
then
Expand Down

0 comments on commit 5951f41

Please sign in to comment.