From ba9b23c2d1b53b2cc7cd0012cf298fc5748b40cf Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Tue, 2 Aug 2022 09:52:55 -0700 Subject: [PATCH] docker: new build interface script The new build script can pass arguments directly to ubuntu.sh when building, this is good for when you want a special build for example when you don't need RTPS or Simulation ``` ./Tools/docker_build.sh --no-sim-tools ``` In the future it can be extended if needed to generate multiple docker images based on the same Dockerfile, if for example we only want to build arm targets --- Tools/docker_build.sh | 20 ++++++++++++++++++++ Tools/setup/Dockerfile | 8 ++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 Tools/docker_build.sh diff --git a/Tools/docker_build.sh b/Tools/docker_build.sh new file mode 100755 index 0000000000..7df48a072d --- /dev/null +++ b/Tools/docker_build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [[ -z "${DOCKER_TAG}" ]]; then + TAG_NAME="latest" +else + TAG_NAME="${DOCKER_TAG}" +fi + +PX4_DOCKER_REPO="px4io/px4-dev:$TAG_NAME" +BUILD_ARGS="${@}" +PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +SRC_DIR=$PWD/../ + +echo "[docker_build.sh]: Building [$PX4_DOCKER_REPO]" +echo "[docker_build.sh]: - with args: [$BUILD_ARGS]" + +docker build \ + -t ${PX4_DOCKER_REPO} \ + -f Tools/setup/Dockerfile "${SRC_DIR}" \ + --build-arg INSTALL_ARGS="${BUILD_ARGS}" diff --git a/Tools/setup/Dockerfile b/Tools/setup/Dockerfile index a82d0d12f2..d81564fade 100644 --- a/Tools/setup/Dockerfile +++ b/Tools/setup/Dockerfile @@ -27,13 +27,17 @@ COPY Tools/setup/ubuntu.sh /tmp/ubuntu.sh # We support pre-downloading the gcc arm none eabi compiler # to speed up build times, if the file is not present when # building, the ubuntu.sh script will download it from source -COPY *gcc-arm-none-eabi-9-2020-q2-update-linux.tar.bz2 /tmp/gcc-arm-none-eabi-9-2020-q2-update-linux.tar.bz2 +COPY gcc-arm-none-eabi-9-2020-q2-update-linux.tar.* /tmp/ # The PATH env is set within ubuntu.sh, but given how we # are running the image using `gosu` to avoid read-only problems # with the filesystem the env variable does not persist ENV PATH="/opt/gcc-arm-none-eabi-9-2020-q2-update/bin:$PATH" ENV PATH="/opt/jdk-14.0.2+12/bin:$PATH" -RUN bash /tmp/ubuntu.sh --from-docker --with-java --with-rtps --no-sim-tools + +# For a complete list of INSTALL_ARGS options run: +# ./Tools/setup/ubuntu.sh --help +ARG INSTALL_ARGS +RUN bash /tmp/ubuntu.sh --from-docker $INSTALL_ARGS ENV DISPLAY :99