diff --git a/.github/workflows/dev_container.yml b/.github/workflows/dev_container.yml index 14a751a16290..a7c2cf84d231 100644 --- a/.github/workflows/dev_container.yml +++ b/.github/workflows/dev_container.yml @@ -23,17 +23,15 @@ jobs: - name: Build and load container image uses: docker/build-push-action@v6 with: + context: Tools/setup push: false load: true - tags: ghcr.io/px4/px4-dev:latest - file: ./Tools/container/Dockerfile + tags: px4-dev:latest platforms: | linux/amd64 - - name: Test container image - run: | - DOCKER_TAG=latest ./Tools/container/docker_run.sh "make px4_fmu-v6x" - - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 + - name: make quick_check + uses: addnab/docker-run-action@v3 + with: + image: px4-dev:latest + run: make quick_check diff --git a/Tools/container/docker_build.sh b/Tools/container/docker_build.sh deleted file mode 100755 index 2d985f9ebfc2..000000000000 --- a/Tools/container/docker_build.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -if [[ -z "${DOCKER_TAG}" ]]; then - # the default tag for docker images - # follows the pattern below, and we recommend - # that any images pushed to the registry continue - # to use the pattern for consistency - TAG_NAME="`date +"%Y-%m-%d"`" -else - TAG_NAME="${DOCKER_TAG}" -fi - -# container name and tag -PX4_DOCKER_REPO="ghcr.io/px4/px4-dev:$TAG_NAME" -# get project root directory -SRC_DIR=$(dirname $(realpath $0)) -SRC_DIR=${SRC_DIR%/*/*} - -echo "[docker_build.sh] Source: [$SRC_DIR]" -echo "[docker_build.sh] ⭐️ Building: [$PX4_DOCKER_REPO]" - -docker build \ - --platform=linux/amd64 \ - -t ${PX4_DOCKER_REPO} \ - -f Tools/container/Dockerfile "${SRC_DIR}" - -# push to the container registry -if [[ "${PUSH_TO_REGISTRY}" ]]; then - docker push ${PX4_DOCKER_REPO} -fi diff --git a/Tools/container/docker_run.sh b/Tools/container/docker_run.sh deleted file mode 100755 index 04a1894c398d..000000000000 --- a/Tools/container/docker_run.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -if [[ -z "${DOCKER_TAG}" ]]; then - # The default tag name should be hardcoded - # to whatever we are currently using in CI on this branch - TAG_NAME="2024-10-11" -else - TAG_NAME="${DOCKER_TAG}" -fi - -if [[ -z "${REPO_NAME}" ]]; then - REPO_NAME="ghcr.io/px4/px4-dev" - # REPO_NAME="px4/px4-dev" -else - REPO_NAME="${REPO_NAME}" - TAG_NAME="" -fi - -# set the image name and tag -PX4_DOCKER_REPO="$REPO_NAME:$TAG_NAME" -# get the project root path -# assumes docker_run.sh lives in ./Tools/container -SRC_DIR=$(dirname $(realpath $0)) -SRC_DIR=${SRC_DIR%/*/*} - -echo "[docker_run.sh] Project Root: $SRC_DIR" -echo "[docker_run.sh] ⭐️ Running: '$PX4_DOCKER_REPO'" - -docker run -it --rm -w "${SRC_DIR}" \ - --platform linux/amd64 \ - --env=AWS_ACCESS_KEY_ID \ - --env=AWS_SECRET_ACCESS_KEY \ - --env=BRANCH_NAME \ - --env=CCACHE_DIR="${CCACHE_DIR}" \ - --env=CI \ - --env=CODECOV_TOKEN \ - --env=COVERALLS_REPO_TOKEN \ - --env=LOCAL_USER_ID="$(id -u)" \ - --env=PX4_ASAN \ - --env=PX4_MSAN \ - --env=PX4_TSAN \ - --env=PX4_UBSAN \ - --env=TRAVIS_BRANCH \ - --env=TRAVIS_BUILD_ID \ - --publish 14556:14556/udp \ - --volume=/tmp/.X11-unix:/tmp/.X11-unix \ - --volume=/tmp:/tmp:rw \ - --volume=${SRC_DIR}:${SRC_DIR}:rw \ - ${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3" diff --git a/Tools/docker_run.sh b/Tools/docker_run.sh new file mode 100755 index 000000000000..c78b9cc7e1ea --- /dev/null +++ b/Tools/docker_run.sh @@ -0,0 +1,67 @@ +#! /bin/bash + +if [ -z ${PX4_DOCKER_REPO+x} ]; then + echo "guessing PX4_DOCKER_REPO based on input"; + if [[ $@ =~ .*px4_fmu.* ]]; then + # nuttx-px4fmu-v{1,2,3,4,5} + PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2022-08-12" + elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*beaglebone.* ]] || [[ $@ =~ .*pilotpi.default ]]; then + # beaglebone_blue_default, emlid_navio2_default, px4_raspberrypi_default, scumaker_pilotpi_default + PX4_DOCKER_REPO="px4io/px4-dev-armhf:2023-06-26" + elif [[ $@ =~ .*pilotpi.arm64 ]]; then + # scumaker_pilotpi_arm64 + PX4_DOCKER_REPO="px4io/px4-dev-aarch64:2022-08-12" + elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*bebop.* ]]; then + # posix_rpi_cross, posix_bebop_default + PX4_DOCKER_REPO="px4io/px4-dev-armhf:2023-06-26" + elif [[ $@ =~ .*clang.* ]] || [[ $@ =~ .*scan-build.* ]]; then + # clang tools + PX4_DOCKER_REPO="px4io/px4-dev-clang:2021-02-04" + elif [[ $@ =~ .*tests* ]]; then + # run all tests with simulation + PX4_DOCKER_REPO="px4io/px4-dev-simulation-bionic:2021-12-11" + fi +else + echo "PX4_DOCKER_REPO is set to '$PX4_DOCKER_REPO'"; +fi + +# otherwise default to nuttx +if [ -z ${PX4_DOCKER_REPO+x} ]; then + PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2022-08-12" +fi + +# docker hygiene + +#Delete all stopped containers (including data-only containers) +#docker rm $(docker ps -a -q) + +#Delete all 'untagged/dangling' () images +#docker rmi $(docker images -q -f dangling=true) + +echo "PX4_DOCKER_REPO: $PX4_DOCKER_REPO"; + +PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +SRC_DIR=$PWD/../ + +CCACHE_DIR=${HOME}/.ccache +mkdir -p "${CCACHE_DIR}" + +docker run -it --rm -w "${SRC_DIR}" \ + --env=AWS_ACCESS_KEY_ID \ + --env=AWS_SECRET_ACCESS_KEY \ + --env=BRANCH_NAME \ + --env=CCACHE_DIR="${CCACHE_DIR}" \ + --env=CI \ + --env=CODECOV_TOKEN \ + --env=COVERALLS_REPO_TOKEN \ + --env=LOCAL_USER_ID="$(id -u)" \ + --env=PX4_ASAN \ + --env=PX4_MSAN \ + --env=PX4_TSAN \ + --env=PX4_UBSAN \ + --env=TRAVIS_BRANCH \ + --env=TRAVIS_BUILD_ID \ + --publish 14556:14556/udp \ + --volume=${CCACHE_DIR}:${CCACHE_DIR}:rw \ + --volume=${SRC_DIR}:${SRC_DIR}:rw \ + ${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3" diff --git a/Tools/container/Dockerfile b/Tools/setup/Dockerfile similarity index 72% rename from Tools/container/Dockerfile rename to Tools/setup/Dockerfile index 30f4e44ae65d..66b15f33f883 100644 --- a/Tools/container/Dockerfile +++ b/Tools/setup/Dockerfile @@ -13,16 +13,17 @@ ENV TZ=UTC EXPOSE 14556/udp EXPOSE 14557/udp -COPY Tools/container/entrypoint.sh /usr/local/bin/entrypoint.sh -COPY Tools/setup/requirements.txt /tmp/requirements.txt -COPY Tools/setup/ubuntu.sh /tmp/ubuntu.sh +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh # Install PX4 Requirements +COPY requirements.txt /tmp/requirements.txt +COPY ubuntu.sh /tmp/ubuntu.sh RUN touch /.dockerenv RUN bash /tmp/ubuntu.sh + # create user with id 1001 (jenkins docker workflow default) RUN useradd --shell /bin/bash -u 1001 -c "" -m user && usermod -a -G dialout user -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] CMD ["/bin/bash"] diff --git a/Tools/container/entrypoint.sh b/Tools/setup/docker-entrypoint.sh similarity index 100% rename from Tools/container/entrypoint.sh rename to Tools/setup/docker-entrypoint.sh diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh index 2beaddb297bf..2d2fa00c1e4c 100755 --- a/Tools/setup/ubuntu.sh +++ b/Tools/setup/ubuntu.sh @@ -229,8 +229,3 @@ if [[ $INSTALL_SIM == "true" ]]; then fi fi - -if [[ $INSTALL_NUTTX == "true" ]]; then - echo - echo "Relogin or reboot computer before attempting to build NuttX targets" -fi