WIP: in tree Dockerfile and github actions push to github registry

This commit is contained in:
Daniel Agar 2021-05-06 13:42:59 -04:00
parent e265ebabc5
commit d72d6ea28e
14 changed files with 155 additions and 73 deletions

View File

@ -130,7 +130,7 @@ pipeline {
// TODO: actually upload artifacts to S3
// stage('S3 Upload') {
// agent {
// docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
// docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
// }
// options {
// skipDefaultCheckout()

View File

@ -28,7 +28,7 @@ jobs:
"parameters_metadata",
]
container:
image: px4io/px4-dev-nuttx-focal:2021-04-29
image: ghcr.io/px4/px4-dev:2021-05-06
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v1

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- 'master'
- 'github-actions'
pull_request:
branches:
- '*'
@ -11,7 +12,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: px4io/px4-dev-nuttx-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
strategy:
matrix:
config: [

View File

@ -11,7 +11,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: px4io/px4-dev-nuttx-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
strategy:
matrix:
config: [

31
.github/workflows/container.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Build and publish Docker image
on:
push:
branches:
- 'master'
- 'github-actions'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
px4/px4-dev:latest
ghcr.io/px4/px4-dev:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@ -11,7 +11,7 @@ jobs:
airframe:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -26,7 +26,7 @@ jobs:
module:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -41,7 +41,7 @@ jobs:
parameter:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -65,7 +65,7 @@ jobs:
uorb_graph:
runs-on: ubuntu-latest
container: px4io/px4-dev-nuttx-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -80,7 +80,7 @@ jobs:
micrortps_agent:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -94,7 +94,7 @@ jobs:
ROS_msgs:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:
@ -107,7 +107,7 @@ jobs:
ROS2_bridge:
runs-on: ubuntu-latest
container: px4io/px4-dev-base-focal:2021-04-29
container: ghcr.io/px4/px4-dev:2021-05-06
steps:
- uses: actions/checkout@v1
with:

29
Dockerfile Normal file
View File

@ -0,0 +1,29 @@
#
# PX4 development environment
#
FROM ubuntu:20.04
LABEL maintainer="Daniel Agar <daniel@agar.ca>"
COPY Tools/setup/ubuntu.sh /tmp/ubuntu.sh
COPY Tools/setup/requirements.txt /tmp/requirements.txt
RUN DEBIAN_FRONTEND=noninteractive /tmp/ubuntu.sh --no-sim-tools \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
# create user with id 1001 (jenkins docker workflow default)
RUN useradd --shell /bin/bash -u 1001 -c "" -m user && usermod -a -G dialout user
ENV CCACHE_UMASK=000
ENV PATH="/usr/lib/ccache:$PATH"
# SITL UDP PORTS
EXPOSE 14556/udp
EXPOSE 14557/udp
# create and start as LOCAL_USER_ID
COPY Tools/setup/entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"]

18
Jenkinsfile vendored
View File

@ -85,7 +85,7 @@ pipeline {
stage('Airframe') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh 'make distclean'
@ -105,7 +105,7 @@ pipeline {
stage('Parameter') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh 'make distclean'
@ -125,7 +125,7 @@ pipeline {
stage('Module') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh 'make distclean'
@ -176,7 +176,7 @@ pipeline {
stage('Userguide') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')
@ -206,7 +206,7 @@ pipeline {
stage('QGroundControl') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')
@ -234,7 +234,7 @@ pipeline {
stage('microRTPS agent') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')
@ -264,7 +264,7 @@ pipeline {
stage('PX4 ROS msgs') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')
@ -293,7 +293,7 @@ pipeline {
stage('PX4 ROS2 bridge') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')
@ -336,7 +336,7 @@ pipeline {
stage('S3') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-04-29' }
docker { image 'ghcr.io/px4/px4-dev:2021-05-06' }
}
steps {
sh('export')

View File

@ -2,10 +2,7 @@
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:2021-04-29"
elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*beaglebone.* ]] || [[ $@ =~ .*pilotpi.default ]]; then
if [[ $@ =~ .*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:2021-02-04"
elif [[ $@ =~ .*pilotpi.arm64 ]]; then
@ -30,7 +27,7 @@ fi
# otherwise default to nuttx
if [ -z ${PX4_DOCKER_REPO+x} ]; then
PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2021-04-29"
PX4_DOCKER_REPO="ghcr.io/px4/px4-dev:2021-05-06"
fi
# docker hygiene
@ -67,4 +64,5 @@ docker run -it --rm -w "${SRC_DIR}" \
--publish 14556:14556/udp \
--volume=${CCACHE_DIR}:${CCACHE_DIR}:rw \
--volume=${SRC_DIR}:${SRC_DIR}:rw \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME
${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3"

11
Tools/setup/Makefile Normal file
View File

@ -0,0 +1,11 @@
.PHONY: docker_build docker_push all
DATE := $(shell date +%Y-%m-%d)
docker_build:
docker build -f Dockerfile -t px4-dev:${DATE} .
docker_push: build
docker push px4io/px4-dev:${DATE}
all: docker_build

0
Tools/setup/arch.sh Normal file → Executable file
View File

27
Tools/setup/entrypoint.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Start virtual X server in the background
# - DISPLAY default is :99, set in dockerfile
# - Users can override with `-e DISPLAY=` in `docker run` command to avoid
# running Xvfb and attach their screen
if [[ -x "$(command -v Xvfb)" && "$DISPLAY" == ":99" ]]; then
echo "Starting Xvfb"
Xvfb :99 -screen 0 1600x1200x24+32 &
fi
# Check if the ROS_DISTRO is passed and use it
# to source the ROS environment
if [ -n "${ROS_DISTRO}" ]; then
source "/opt/ros/$ROS_DISTRO/setup.bash"
fi
# Use the LOCAL_USER_ID if passed in at runtime
if [ -n "${LOCAL_USER_ID}" ]; then
echo "Starting with UID : $LOCAL_USER_ID"
# modify existing user's id
usermod -u $LOCAL_USER_ID user
# run as user
exec gosu user "$@"
else
exec "$@"
fi

View File

@ -1,24 +1,26 @@
argcomplete
argparse>=1.2
argparse
cerberus
coverage
empy>=3.3
jinja2>=2.8
jsonschema
kconfiglib
matplotlib>=3.0.*
numpy>=1.13
nunavut>=1.1.0
packaging
pandas>=0.21
pkgconfig
psutil
pygments
wheel>=0.31.1
pymavlink
pyros-genmsg
pyserial>=3.0
pyulog>=0.5.0
pyyaml
requests
serial
setuptools>=39.2.0
six>=1.12.0
toml>=0.9
wheel>=0.31.1

View File

@ -31,10 +31,9 @@ done
# detect if running in docker
if [ -f /.dockerenv ]; then
echo "Running within docker, installing initial dependencies";
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
ca-certificates \
gnupg \
lsb-core \
gosu \
sudo \
wget \
;
@ -53,7 +52,7 @@ fi
# check ubuntu version
# otherwise warn and point to docker?
UBUNTU_RELEASE="`lsb_release -rs`"
UBUNTU_RELEASE=$(cat /etc/os-release | grep VERSION_ID | cut -d "\"" -f 2)
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
echo "Ubuntu 14.04 is no longer supported"
@ -63,16 +62,18 @@ elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
exit 1
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
echo "Ubuntu 18.04"
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
echo "Ubuntu 20.04"
fi
echo
echo "Installing PX4 general dependencies"
sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
sudo apt-get -qq update
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
astyle \
build-essential \
ccache \
@ -93,20 +94,23 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
python3-wheel \
rsync \
shellcheck \
unzip \
zip \
;
if [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
echo "Installing Ubuntu 16.04 PX4-compatible ccache version"
wget -O /tmp/ccache_3.4.1-1_amd64.deb http://launchpadlibrarian.net/356662933/ccache_3.4.1-1_amd64.deb
wget -q -O /tmp/ccache_3.4.1-1_amd64.deb http://launchpadlibrarian.net/356662933/ccache_3.4.1-1_amd64.deb
sudo dpkg -i /tmp/ccache_3.4.1-1_amd64.deb
fi
# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
python3 -m pip install --user -r ${DIR}/requirements.txt
if [ -f /.dockerenv ]; then
# system wide for docker
python3 -m pip install -r ${DIR}/requirements.txt
else
python3 -m pip install --user --quiet -r ${DIR}/requirements.txt
fi
# NuttX toolchain (arm-none-eabi-gcc)
if [[ $INSTALL_NUTTX == "true" ]]; then
@ -114,33 +118,13 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Installing NuttX dependencies"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
automake \
binutils-dev \
bison \
build-essential \
flex \
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
g++-multilib \
gcc-multilib \
gdb-multiarch \
genromfs \
gettext \
gperf \
kconfig-frontends \
libelf-dev \
libexpat-dev \
libgmp-dev \
libisl-dev \
libmpc-dev \
libmpfr-dev \
libncurses5-dev \
libncursesw5-dev \
libtool \
pkg-config \
screen \
texinfo \
u-boot-tools \
util-linux \
vim-common \
;
@ -164,7 +148,7 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
else
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2 && \
wget -q -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2 && \
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;
# add arm-none-eabi-gcc to user's PATH
@ -185,37 +169,36 @@ if [[ $INSTALL_SIM == "true" ]]; then
echo "Installing PX4 simulation dependencies"
# General simulation dependencies
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
bc \
;
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
java_version=11
gazebo_version=9
MAVSDK_VERSION=0.39.0
wget -q "https://github.com/mavlink/MAVSDK/releases/download/v${MAVSDK_VERSION}/mavsdk_{MAVSDK_VERSION})_ubuntu18.04_amd64.deb" -O /tmp/mavsdk.deb && sudo dpkg -i /tmp/mavsdk.deb
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
java_version=14
gazebo_version=11
MAVSDK_VERSION=0.39.0
wget -q "https://github.com/mavlink/MAVSDK/releases/download/v{MAVSDK_VERSION}/mavsdk_{MAVSDK_VERSION}_ubuntu20.04_amd64.deb" -O /tmp/mavsdk.deb && sudo dpkg -i /tmp/mavsdk.deb
else
java_version=14
gazebo_version=11
fi
# Java (jmavsim or fastrtps)
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
ant \
openjdk-$java_version-jre \
openjdk-$java_version-jdk \
default-jre-headless \
default-jdk-headless \
libvecmath-java \
;
# Set Java 11 as default
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version")
# Gazebo
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
wget -q http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
# Update list, since new gazebo-stable.list has been added
sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
sudo apt-get update -qq
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install \
dmidecode \
gazebo$gazebo_version \
gstreamer1.0-plugins-bad \