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
This commit is contained in:
Ramon Roche 2022-08-02 09:52:55 -07:00
parent 38fc86cf3b
commit ba9b23c2d1
No known key found for this signature in database
GPG Key ID: 275988FAE5821713
2 changed files with 26 additions and 2 deletions

20
Tools/docker_build.sh Executable file
View File

@ -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}"

View File

@ -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