Skip to content

Commit

Permalink
minimal px4-dev Dockerfile + CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Nov 15, 2024
1 parent 1519baf commit 879b38c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 97 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/dev_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 0 additions & 30 deletions Tools/container/docker_build.sh

This file was deleted.

49 changes: 0 additions & 49 deletions Tools/container/docker_run.sh

This file was deleted.

67 changes: 67 additions & 0 deletions Tools/docker_run.sh
Original file line number Diff line number Diff line change
@@ -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' (<none>) 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"
9 changes: 5 additions & 4 deletions Tools/container/Dockerfile → Tools/setup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
File renamed without changes.
5 changes: 0 additions & 5 deletions Tools/setup/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 879b38c

Please sign in to comment.