Skip to content

Commit 879b38c

Browse files
committed
minimal px4-dev Dockerfile + CI
1 parent 1519baf commit 879b38c

File tree

7 files changed

+79
-97
lines changed

7 files changed

+79
-97
lines changed

.github/workflows/dev_container.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ jobs:
2323
- name: Build and load container image
2424
uses: docker/build-push-action@v6
2525
with:
26+
context: Tools/setup
2627
push: false
2728
load: true
28-
tags: ghcr.io/px4/px4-dev:latest
29-
file: ./Tools/container/Dockerfile
29+
tags: px4-dev:latest
3030
platforms: |
3131
linux/amd64
3232
33-
- name: Test container image
34-
run: |
35-
DOCKER_TAG=latest ./Tools/container/docker_run.sh "make px4_fmu-v6x"
36-
37-
- name: Setup tmate session
38-
if: ${{ failure() }}
39-
uses: mxschmitt/action-tmate@v3
33+
- name: make quick_check
34+
uses: addnab/docker-run-action@v3
35+
with:
36+
image: px4-dev:latest
37+
run: make quick_check

Tools/container/docker_build.sh

-30
This file was deleted.

Tools/container/docker_run.sh

-49
This file was deleted.

Tools/docker_run.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#! /bin/bash
2+
3+
if [ -z ${PX4_DOCKER_REPO+x} ]; then
4+
echo "guessing PX4_DOCKER_REPO based on input";
5+
if [[ $@ =~ .*px4_fmu.* ]]; then
6+
# nuttx-px4fmu-v{1,2,3,4,5}
7+
PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2022-08-12"
8+
elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*beaglebone.* ]] || [[ $@ =~ .*pilotpi.default ]]; then
9+
# beaglebone_blue_default, emlid_navio2_default, px4_raspberrypi_default, scumaker_pilotpi_default
10+
PX4_DOCKER_REPO="px4io/px4-dev-armhf:2023-06-26"
11+
elif [[ $@ =~ .*pilotpi.arm64 ]]; then
12+
# scumaker_pilotpi_arm64
13+
PX4_DOCKER_REPO="px4io/px4-dev-aarch64:2022-08-12"
14+
elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*bebop.* ]]; then
15+
# posix_rpi_cross, posix_bebop_default
16+
PX4_DOCKER_REPO="px4io/px4-dev-armhf:2023-06-26"
17+
elif [[ $@ =~ .*clang.* ]] || [[ $@ =~ .*scan-build.* ]]; then
18+
# clang tools
19+
PX4_DOCKER_REPO="px4io/px4-dev-clang:2021-02-04"
20+
elif [[ $@ =~ .*tests* ]]; then
21+
# run all tests with simulation
22+
PX4_DOCKER_REPO="px4io/px4-dev-simulation-bionic:2021-12-11"
23+
fi
24+
else
25+
echo "PX4_DOCKER_REPO is set to '$PX4_DOCKER_REPO'";
26+
fi
27+
28+
# otherwise default to nuttx
29+
if [ -z ${PX4_DOCKER_REPO+x} ]; then
30+
PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2022-08-12"
31+
fi
32+
33+
# docker hygiene
34+
35+
#Delete all stopped containers (including data-only containers)
36+
#docker rm $(docker ps -a -q)
37+
38+
#Delete all 'untagged/dangling' (<none>) images
39+
#docker rmi $(docker images -q -f dangling=true)
40+
41+
echo "PX4_DOCKER_REPO: $PX4_DOCKER_REPO";
42+
43+
PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
44+
SRC_DIR=$PWD/../
45+
46+
CCACHE_DIR=${HOME}/.ccache
47+
mkdir -p "${CCACHE_DIR}"
48+
49+
docker run -it --rm -w "${SRC_DIR}" \
50+
--env=AWS_ACCESS_KEY_ID \
51+
--env=AWS_SECRET_ACCESS_KEY \
52+
--env=BRANCH_NAME \
53+
--env=CCACHE_DIR="${CCACHE_DIR}" \
54+
--env=CI \
55+
--env=CODECOV_TOKEN \
56+
--env=COVERALLS_REPO_TOKEN \
57+
--env=LOCAL_USER_ID="$(id -u)" \
58+
--env=PX4_ASAN \
59+
--env=PX4_MSAN \
60+
--env=PX4_TSAN \
61+
--env=PX4_UBSAN \
62+
--env=TRAVIS_BRANCH \
63+
--env=TRAVIS_BUILD_ID \
64+
--publish 14556:14556/udp \
65+
--volume=${CCACHE_DIR}:${CCACHE_DIR}:rw \
66+
--volume=${SRC_DIR}:${SRC_DIR}:rw \
67+
${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3"

Tools/container/Dockerfile renamed to Tools/setup/Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ ENV TZ=UTC
1313
EXPOSE 14556/udp
1414
EXPOSE 14557/udp
1515

16-
COPY Tools/container/entrypoint.sh /usr/local/bin/entrypoint.sh
17-
COPY Tools/setup/requirements.txt /tmp/requirements.txt
18-
COPY Tools/setup/ubuntu.sh /tmp/ubuntu.sh
16+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
1917

2018
# Install PX4 Requirements
19+
COPY requirements.txt /tmp/requirements.txt
20+
COPY ubuntu.sh /tmp/ubuntu.sh
2121
RUN touch /.dockerenv
2222
RUN bash /tmp/ubuntu.sh
23+
2324
# create user with id 1001 (jenkins docker workflow default)
2425
RUN useradd --shell /bin/bash -u 1001 -c "" -m user && usermod -a -G dialout user
2526

26-
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
27+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
2728

2829
CMD ["/bin/bash"]
File renamed without changes.

Tools/setup/ubuntu.sh

-5
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,3 @@ if [[ $INSTALL_SIM == "true" ]]; then
229229
fi
230230

231231
fi
232-
233-
if [[ $INSTALL_NUTTX == "true" ]]; then
234-
echo
235-
echo "Relogin or reboot computer before attempting to build NuttX targets"
236-
fi

0 commit comments

Comments
 (0)