Skip to content

Commit 4c0f8ce

Browse files
committed
moving docker builds to central repo
1 parent d6178f7 commit 4c0f8ce

9 files changed

Lines changed: 394 additions & 25 deletions

File tree

.gitignore

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
1-
# Prerequisites
2-
*.d
1+
# Dumb OS crap
2+
.DS_Store
33

4-
# Compiled Object files
5-
*.slo
6-
*.lo
4+
# Build outputs
75
*.o
8-
*.obj
6+
*.d
7+
lib*.so
8+
lib*.so.*
9+
.dep
10+
__pycache__
11+
*.pyc
12+
.mypy*
13+
.pyenv
14+
.dockerup
15+
16+
# Eclipse
17+
.metadata
18+
.settings
19+
.project
20+
.cproject
21+
.pydevproject
22+
.gdbinit
923

10-
# Precompiled Headers
11-
*.gch
12-
*.pch
24+
# Log files
25+
*.log
1326

14-
# Compiled Dynamic libraries
15-
*.so
16-
*.dylib
17-
*.dll
27+
# Build folders
28+
build*
1829

19-
# Fortran module files
20-
*.mod
21-
*.smod
30+
# Python
31+
*.egg-info
32+
*.pyc
33+
.mypy_cache
2234

23-
# Compiled Static libraries
24-
*.lai
25-
*.la
26-
*.a
27-
*.lib
35+
# We don't maintain a Vagrantfile as
36+
# part of our toolchain so don't check
37+
# it in if you are using one.
38+
.vagrant
39+
Vagrantfile
2840

29-
# Executables
30-
*.exe
31-
*.out
32-
*.app
41+
# Sonarqube
42+
_tmp
43+
cache

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
![UAVCAN](uavcan_logo.svg) UAVCAN Containerized Toolchains
2+
===================
3+
4+
This repository contains the Dockerfiles, instructions, and some utilities for building containers to be used as common toolchains for the UAVCAN project. These containers are published to the [uavcan organization on Docker Hub](https://cloud.docker.com/u/uavcan).

c_cpp/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Builds the c_cpp/ubuntu-18.04 toolchain container.
3+
#
4+
FROM ubuntu:18.04
5+
6+
VOLUME /repo
7+
8+
WORKDIR /repo
9+
10+
11+
ENV SONAR_SCANNER_VERSION 4.2.0.1873
12+
ENV LANG=en_US.UTF-8
13+
ENV LANGUAGE=en_US:en
14+
ENV LC_ALL=en_US.UTF-8
15+
ENV SONAR_SCANNER_HOME=/sonar-scanner-${SONAR_SCANNER_VERSION}-linux
16+
ENV SONAR_SCANNER_OPTS="-server"
17+
18+
ENV PATH="${SONAR_SCANNER_HOME}/build-wrapper-linux-x86:${PATH}"
19+
ENV PATH="${SONAR_SCANNER_HOME}/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:${PATH}"
20+
21+
COPY provision.sh /
22+
23+
RUN /provision.sh

c_cpp/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# C/C++ Toolchain Docker
2+
3+
The `uavcan/c_cpp` docker image provides a consistent build and test environment
4+
for development, continuous-integration, and test automation of C and C++ based projects.
5+
6+
## Manual Build and Push
7+
8+
These instructions are for maintainers with permissions to push to the [uavcan organization on Docker Hub](https://cloud.docker.com/u/uavcan).
9+
10+
```bash
11+
docker build .
12+
```
13+
14+
```bash
15+
docker images
16+
17+
REPOSITORY TAG IMAGE ID CREATED SIZE
18+
<none> <none> 736647481ad3 About a minute ago 1GB
19+
```
20+
21+
```bash
22+
docker tag 736647481ad3 uavcan/c_cpp:ubuntu-18.04
23+
docker login --username=yourhubusername
24+
docker push uavcan/c_cpp:ubuntu-18.04
25+
```
26+
27+
Use this pattern for tags:
28+
29+
```bash
30+
uavcan/[toolchain]:[build environment]
31+
```
32+
33+
## Testing out the container
34+
35+
To login to an interactive session do:
36+
37+
```bash
38+
docker run --rm -it -v ${PWD}:/repo uavcan/c_cpp:ubuntu-18.04
39+
```
40+
41+
## Toolchain Documentation
42+
43+
### Sonarqube
44+
45+
Wrap yer build:
46+
47+
```bash
48+
build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory cmake --build build/
49+
```
50+
51+
Upload the results:
52+
53+
```bash
54+
sonar-scanner \
55+
-Dsonar.organization=uavcan \
56+
-Dsonar.projectKey=UAVCAN_myproject \
57+
-Dsonar.sources=. \
58+
-Dsonar.host.url=https://sonarcloud.io \
59+
-Dsonar.cfamily.build-wrapper-output=bw-output \
60+
-Dsonar.login=TOKEN
61+
```
62+
63+
A [CMake example on github](https://github.com/SonarSource/sonarcloud_example_cpp-cmake-linux-otherci)
64+
65+
## Travis CI
66+
67+
You can use this in your .travis.yml like this:
68+
69+
```none
70+
services:
71+
- docker
72+
73+
before_install:
74+
- docker pull uavcan/c_cpp:ubuntu-18.04
75+
76+
script:
77+
- docker run --rm -v $TRAVIS_BUILD_DIR:/repo uavcan/c_cpp:ubuntu-18.04 /bin/sh -c mybuild_command
78+
79+
```
80+
81+
## BuildKite
82+
83+
Example pipeline.yml:
84+
85+
```yaml
86+
- label: ":github: my containerized build"
87+
command: "my_build_command"
88+
plugins:
89+
- docker#v3.5.0:
90+
workdir: /repo
91+
image: "uavcan/c_cpp:ubuntu-18.04"
92+
propagate-environment: true
93+
mount-ssh-agent: true
94+
```

c_cpp/provision.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# +----------------------------------------------------------+
4+
# | BASH : Modifying Shell Behaviour
5+
# | (https://www.gnu.org/software/bash/manual)
6+
# +----------------------------------------------------------+
7+
# Treat unset variables and parameters other than the special
8+
# parameters ‘@’ or ‘*’ as an error when performing parameter
9+
# expansion. An error message will be written to the standard
10+
# error, and a non-interactive shell will exit.
11+
set -o nounset
12+
13+
# Exit immediately if a pipeline returns a non-zero status.
14+
set -o errexit
15+
16+
# If set, the return value of a pipeline is the value of the
17+
# last (rightmost) command to exit with a non-zero status, or
18+
# zero if all commands in the pipeline exit successfully.
19+
set -o pipefail
20+
21+
# +----------------------------------------------------------+
22+
export DEBIAN_FRONTEND=noninteractive
23+
24+
apt-get update
25+
26+
# setup locales in the container so Python can default to utf-8.
27+
apt-get -y install locales
28+
# from http://jaredmarkell.com/docker-and-locales/
29+
locale-gen en_US.UTF-8
30+
export ENV LANG=en_US.UTF-8
31+
export ENV LANGUAGE=en_US:en
32+
export ENV LC_ALL=en_US.UTF-8
33+
34+
apt-get -y install software-properties-common
35+
add-apt-repository ppa:team-gcc-arm-embedded/ppa -y
36+
apt-get update
37+
apt-get -y install apt-utils
38+
apt-get -y install python3
39+
apt-get -y install python3-pip
40+
apt-get -y install python3-venv
41+
apt-get -y install cmake
42+
apt-get -y install git
43+
apt-get -y install gcc-arm-embedded
44+
apt-get -y install clang
45+
apt-get -y install clang-format
46+
apt-get -y install doxygen
47+
apt-get -y install lcov
48+
apt-get -y install valgrind
49+
apt-get -y install clang-tidy
50+
apt-get -y install npm
51+
apt-get -y install graphviz
52+
apt-get -y install curl
53+
apt-get -y install unzip
54+
55+
pip3 install virtualenv
56+
pip3 install tox
57+
58+
# a well-known workaround for npm install on docker
59+
# what. a. fail.
60+
mv /usr/local/lib/node_modules /usr/local/lib/node_modules.tmp && \
61+
mv /usr/local/lib/node_modules.tmp /usr/local/lib/node_modules && \
62+
npm install -g gh-pages
63+
64+
# Sonarqube
65+
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
66+
unzip -o $HOME/.sonar/sonar-scanner.zip -d $SONAR_SCANNER_HOME
67+
68+
curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
69+
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $SONAR_SCANNER_HOME
70+
71+
rm -rf $HOME/.sonar
72+
73+
echo "export PATH=$PATH" >> ~/.bashrc
74+
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
75+
echo "export LANGUAGE=en_US:en" >> ~/.bashrc
76+
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc

toxic/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Builds a docker image to use for tox runs.
3+
#
4+
FROM ubuntu:18.04
5+
6+
VOLUME /repo
7+
8+
WORKDIR /repo
9+
10+
11+
ENV SONAR_SCANNER_VERSION 4.2.0.1873
12+
ENV LANG=en_US.UTF-8
13+
ENV LANGUAGE=en_US:en
14+
ENV LC_ALL=en_US.UTF-8
15+
ENV SONAR_SCANNER_HOME=/sonar-scanner-${SONAR_SCANNER_VERSION}-linux
16+
ENV SONAR_SCANNER_OPTS="-server"
17+
18+
ENV PATH="${SONAR_SCANNER_HOME}/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:${PATH}"
19+
20+
COPY provision.sh /
21+
22+
RUN /provision.sh

toxic/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Toxic Docker
2+
3+
Builds and pushes a docker environment for use with tox testing. This environment contains a series of python versions allowing multi-version tox testing locally and in CI services.
4+
5+
The "sq" suffix indicates that the ["sonarqube"](https://www.sonarqube.org) scanner has been included in the image. This scanner allows tox builds to upload coverage and other reports to a sonarqube instance.
6+
7+
## Build and Push
8+
9+
These instructions are for maintainers with permissions to push to the "uavcan" organization on Docker Hub.
10+
11+
```
12+
docker build .
13+
```
14+
```
15+
docker images
16+
17+
REPOSITORY TAG IMAGE ID
18+
toxic latest d7ab132649d6
19+
```
20+
```
21+
# We use the range of python environments supported as the version tag.
22+
docker tag d7ab132649d6 uavcan/toxic:py35-py38-sq
23+
docker login --username=yourhubusername
24+
docker push uavcan/toxic:py35-py38-sq
25+
```
26+
27+
## Testing out the container
28+
29+
Start an interactive session:
30+
31+
```bash
32+
docker run --rm -it -v ${PWD}:/repo uavcan/toxic:py35-py38-sq
33+
```
34+
35+
On macintosh you'll probably want to optimize osxfs with something like cached or delegated:
36+
37+
```bash
38+
docker run --rm -it -v ${PWD}:/repo:delegated uavcan/toxic:py35-py38-sq
39+
```
40+
41+
See ["Performance tuning for volume mounts"](https://docs.docker.com/docker-for-mac/osxfs-caching/) for details.
42+
43+
## Travis CI
44+
45+
You can use this in your .travis.yml like this:
46+
47+
```none
48+
services:
49+
- docker
50+
51+
before_install:
52+
- docker pull uavcan/uavcan/toxic:py35-py38-sq
53+
54+
script:
55+
- docker run --rm -v $TRAVIS_BUILD_DIR:/repo uavcan/uavcan/toxic:py35-py38-sq /bin/sh -c tox
56+
57+
```
58+
59+
## BuildKite
60+
61+
Example pipeline.yml:
62+
63+
```yaml
64+
- label: ":github: my containerized build"
65+
command: "tox"
66+
plugins:
67+
- docker#v3.5.0:
68+
workdir: /repo
69+
image: "uavcan/toxic:py35-py38-sq"
70+
propagate-environment: true
71+
mount-ssh-agent: true
72+
```

0 commit comments

Comments
 (0)