-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor images for old Mbed CLI 1 and Mbed CLI 2 #6
Open
arekzaluski
wants to merge
2
commits into
master
Choose a base branch
from
image-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
# docker-hub | ||
This repository contains the Dockerfile for building docker hub images | ||
# mbed-os-docker-images | ||
This repository contains the Dockerfile for building docker hub images of Mbed OS and additional tools required for embedded development in Mbed. | ||
|
||
### Docker-hub address: https://hub.docker.com/u/mbedos | ||
## Prerequisites | ||
|
||
[Docker](https://www.docker.com/) | ||
|
||
## Docker Hub address: https://hub.docker.com/u/mbedos | ||
|
||
## mbed-os-env | ||
Docker image with old Mbed tools (mbed-cli). | ||
|
||
## mbed-os-env-cmake | ||
Docker image with new Mbed tools (mbed-tools). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# mbed-OS development environment docker image | ||
|
||
This docker image is the official Mbed OS development environment which includes latest Mbed CLI 2. | ||
* It is based on ubuntu 20.04 | ||
* Python 3 is installed | ||
* arm-none-eabi-gcc toolchain is installed | ||
* pyOCD is installed | ||
* Cmake is installed | ||
* Latest released version of mbed-tools and GreenTea are installed | ||
|
||
# How to use docker image: | ||
|
||
## Pull docker images | ||
```bash | ||
docker pull mbedos/mbed-os-env-cmake | ||
|
||
``` | ||
|
||
## Run Mbed OS environment without HW support (build mbed images only) | ||
launch docker by | ||
```bash | ||
docker run -it mbedos/mbed-os-env:<lable> | ||
``` | ||
Then you will have the container with mbed OS development environment. | ||
you should be able to compile mbed commands/examples as recommenced in mbed documentations | ||
e.g. | ||
```bash | ||
mbed-tools import --no-requirements mbed-os-example-blinky | ||
cd mbed-os-example-blinky | ||
mbed-tools compile -m <TARGET> -t GCC_ARM | ||
``` | ||
|
||
## Run Mbed OS environment with HW support (USB pass-through) | ||
If you want to use this docker container connect and flash your targets. you need some extra command line option to pass-through your USB devices. | ||
```bash | ||
sudo docker run -it --privileged -v /dev/disk/by-id:/dev/disk/by-id -v /dev/serial/by-id:/dev/serial/by-id mbed-os-env:<label> | ||
``` | ||
Then you will have the container with mbed OS development environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env sh | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Install tools via apt-get | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get -y update | ||
apt-get -y install git \ | ||
wget \ | ||
python3 \ | ||
python3-dev \ | ||
python3-setuptools \ | ||
python3-usb \ | ||
python3-pip \ | ||
software-properties-common \ | ||
build-essential \ | ||
astyle \ | ||
mercurial \ | ||
ninja-build \ | ||
libssl-dev \ | ||
srecord | ||
|
||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null | ||
add-apt-repository 'deb https://apt.kitware.com/ubuntu/ focal main' | ||
apt-get -y update | ||
apt-get -y install cmake | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Set up mbed environment | ||
cd /root | ||
wget https://github.com/ARMmbed/mbed-os/raw/latest/tools/cmake/requirements.txt | ||
pip3 install -r requirements.txt | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Install Python modules (which are not included in requirements.txt) | ||
pip3 install \ | ||
mbed-tools \ | ||
pyocd \ | ||
mbed-greentea \ | ||
mbed-host-tests | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Install arm-none-eabi-gcc | ||
TARBALL="" | ||
ARCH="$(uname -m)" | ||
if [ "$ARCH" = "aarch64" ] | ||
then | ||
TARBALL="gcc-arm-none-eabi-9-2019-q4-major-aarch64-linux.tar.bz2" | ||
else | ||
TARBALL="gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2" | ||
fi | ||
|
||
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/$TARBALL | ||
tar -xjf $TARBALL | ||
rm $TARBALL | ||
PATH="/root/gcc-arm-none-eabi-9-2019-q4-major/bin:${PATH}" | ||
echo 'PATH="/root/gcc-arm-none-eabi-9-2019-q4-major/bin:${PATH}"' >> ~/.bashrc | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Display and save environment settings | ||
python3 --version | tee env_settings | ||
arm-none-eabi-gcc --version | tee -a env_settings | ||
(echo -n 'mbed-tools ' && mbed-tools --version) | tee -a env_settings | ||
(echo -n 'mbed-greentea ' && mbedgt --version) | tee -a env_settings | ||
(echo -n 'mbed-host-tests ' && mbedhtrun --version) | tee -a env_settings | ||
(echo -n 'pyocd ' && pyocd --version) | tee -a env_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
docker build "$@" -t mbed/mbed-os-env-cmake . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
PORT="8080" | ||
WORKSPACE=${@:-$HOME} | ||
PROJECT_DIR="/work/$(basename $WORKSPACE)" | ||
|
||
PARAMS="$PARAMS -it --rm" | ||
PARAMS="$PARAMS -v $WORKSPACE:$PROJECT_DIR" | ||
PARAMS="$PARAMS -p $PORT:8080" | ||
PARAMS="$PARAMS -w $PROJECT_DIR" | ||
|
||
docker run $PARAMS mbed/mbed-os-env-cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike the change to a single command, a change to
bootstrap.sh
triggers a full rebuild and it is slow with multiarch. Whereas, with variousRUN
, actions made before the modification are cached.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am agree with @pan- here, change it to a single command makes the huge docker image (1.4GB I think) into a single layer, every change will triggers a full rebuilding of whole layer. And this impair the benefit of the layer caching, and make the upload/download a slower process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another point is if this bootstrap scripts calling other scripts make changes to the docker image contents, the it would be unclear what it is in the docker image.
One of major benefit of Dockerfile is : It is self-descriptive, by reading the Dockerfile, you know what it is inside image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial idea was to share one script for Docker and others (e.g. Vagrant), but I agree that performance (caching) should be prioritised.
It would be good to have this part reverted, while having other improvements (e.g. installing CMake via PPA) merged soon, so our CI (mainly Travis) can benefit from that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Travis scripts currently still fetch the raw Ubuntu image and install stuff manually at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(By "reverted" I mean a separate PR - no need to abandon any work we've done here)