diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e4e3fb5..6c91a5f7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout files @@ -46,10 +46,10 @@ jobs: run: | export PATH=$PATH:${{ runner.temp }}/arm-none-eabi/bin make -j `nproc` submodules - + - name: Download softdevice id: download-softdevice - run: | + run: | export PATH=$PATH:${{ runner.temp }}/arm-none-eabi/bin make -j `nproc` softdevice diff --git a/.github/workflows/sim.yml b/.github/workflows/sim.yml index c832547a..571ed0b2 100644 --- a/.github/workflows/sim.yml +++ b/.github/workflows/sim.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout files @@ -29,7 +29,7 @@ jobs: id: install-packages run: | sudo apt-get update - sudo apt-get install libsdl2-2.0.0 + sudo apt-get install libsdl2-2.0.0 meson - name: Install python modules id: install-modules diff --git a/Makefile b/Makefile index 9e663f13..a80cb6bb 100644 --- a/Makefile +++ b/Makefile @@ -170,3 +170,31 @@ dist: docs find $(DIST) -name __pycache__ | xargs $(RM) -r tar -C .. -zcf $(DIST).tar.gz $(notdir $(DIST)) (cd ..; zip -9r $(DIST).zip $(notdir $(DIST))) + +build-docker-image: + docker compose \ + --file ./tools/docker/docker-compose-build.yml \ + build \ + --pull + +push-docker-image: + docker compose \ + --file ./tools/docker/docker-compose-build.yml \ + push + +run-docker-image: + docker run \ + --rm \ + --volume=$$(pwd):/project/ \ + --volume=/run/dbus:/run/dbus:ro \ + --user=$$(id -u):$$(id -g) \ + --userns=host \ + --net=host \ + --hostname="wasp-os-dev" \ + --name="wasp-os-dev" \ + --init \ + --interactive \ + --tty \ + --entrypoint="" \ + wasp-os/wasp-os-dev:0.1.0 \ + bash diff --git a/docs/install.rst b/docs/install.rst index e1dfe448..775b82ec 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -16,16 +16,15 @@ Building wasp-os and launching the wasp-os simulator requires Python 3.6 (or later) and the following python modules: click, numpy, pexpect, PIL (or Pillow), pydbus, pygobject, pyserial, pysdl2. -On Debian Buster the required python modules can be obtained using the -following commands: +On Debian Bookworm / Ubuntu 22.04 or later the required python modules can be +obtained using the following commands: .. code-block:: sh sudo apt install \ - wget git build-essential libsdl2-2.0-0 python3-click python3-gi \ - python3-numpy python3-pexpect python3-pil python3-pip python3-pydbus \ - python3-serial unzip - pip3 install --user cbor pysdl2 tomli + wget git build-essential libsdl2-2.0-0 python3-cbor python3-click \ + python3-gi python3-numpy python3-pexpect python3-pil python3-pip \ + python3-pydbus python3-sdl2 python3-serial python3-tomli unzip Additionally if you wish to regenerate the documentation you will require a complete sphinx toolchain: @@ -53,29 +52,31 @@ tested using the `GNU-RM toolchain link time optimization is enabled during the MicroPython build (LTO is enabled by default). -Install prerequisites via docker +Install prerequisites via Docker ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .. note:: - If you want to use the Docker-based setup, it is assumed that you're using - and x86 machine on Linux, running Xorg. Other setups may require some - patching for now. + For the Docker-based setup, an x86 host machine running Linux with Xorg is + assumed. Other setups may require some patching for now. -To build wasp-os with docker, ensure it is installed and running, then open a terminal and run the following commands in your home directory: +To build or flash wasp-os with Docker, ensure `Docker is installed and set up +`_. +Then, run the following commands from within the project's root path: .. code-block:: sh - git clone https://github.com/wasp-os/wasp-os - cd wasp-os - ~/wasp-os/tools/docker/shell - -This will create a new user with restricted privileges, and drop you into a bash shell. + make build-docker-image + make run-docker-image -Some important things to note: +This will build the wasp-os Docker image locally and launch an interactive +container from it. The Docker container runs BASH from the project's root path +and all ``make`` commands should be usable from this shell, including ``make +sim`` and ``make check``. -All ``make`` commands should be usable from this shell, -including ``make sim`` and ``make check``. Some commands that interact with -Bluetooth, such as ``wasptool``, may not work, for now. +Some commands that interact with Bluetooth, such as ``wasptool``, require that +Bluetooth is enabled in the host OS. Bluetooth devices will then be accessible +from within the Docker container. Install prerequisites via Nix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/docker/.dockerignore b/tools/docker/.dockerignore new file mode 100644 index 00000000..dbf546a7 --- /dev/null +++ b/tools/docker/.dockerignore @@ -0,0 +1,4 @@ +* + +!/Dockerfile +!/.dockerignore diff --git a/tools/docker/.env b/tools/docker/.env new file mode 100644 index 00000000..39bde944 --- /dev/null +++ b/tools/docker/.env @@ -0,0 +1 @@ +DOCKER_IMG_VER="0.1.0" diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 49294fee..67c00661 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -1,24 +1,78 @@ -FROM ubuntu:focal - -ARG uid -ARG gid - -RUN set -xe; \ - export DEBIAN_FRONTEND=noninteractive; \ - apt-get update; \ - apt-get install -y \ - wget git build-essential pkg-config libsdl2-2.0.0 python3-click \ - python3-numpy python3-pexpect python3-pil python3-pip python3-pydbus \ - libcairo2-dev python3-serial unzip python3-sphinx graphviz \ - python3-recommonmark python3-pytest \ - ; \ - pip3 install cbor pysdl2 pygobject cryptography tomli; - -RUN set -xe; \ - wget --progress=dot:mega -O - https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 | tar xjf - -C /opt - -RUN set -xe; \ - addgroup --gid $gid user; \ - adduser --gecos "" --disabled-password --uid $uid --gid $gid user; - -COPY setup-env.sh /etc/profile.d/setup-env.sh +# Software version pinning +FROM ubuntu:24.04 +# Workaround: Newly introduced `ubuntu` user in ubuntu:24.04 causes UID/GID +# mapping issues when adding custom user +RUN touch /var/mail/ubuntu && \ + chown ubuntu /var/mail/ubuntu && \ + userdel --remove ubuntu + +# Version info. +# `ARG DOCKER_IMG_VER=...` passed in via Docker Compose + +# Main ("payload") software +ARG PAYLOAD=wasp-os-dev + +# Docker image labels +LABEL maintainer="Wasp OS" +LABEL name="${PAYLOAD}" +LABEL description="Wasp OS developer environment" +LABEL version=${DOCKER_IMG_VER} + +# Version info. (visible at run time from within Docker container) +ENV DOCKER_IMG_VER=${DOCKER_IMG_VER} + +# Install base/support software +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install --assume-yes --no-install-recommends \ + binutils-arm-none-eabi \ + bluez \ + build-essential \ + dbus \ + # TODO: Do version pinning? + gcc \ + gcc-arm-none-eabi \ + gir1.2-gtk-4.0 \ + git \ + graphviz \ + libcairo2-dev \ + libgirepository-2.0-dev \ + libnewlib-arm-none-eabi \ + libsdl2-2.0.0 \ + make \ + pkg-config \ + python-is-python3 \ + python3 \ + python3-dev \ + python3-pil \ + python3-pip \ + python3-recommonmark \ + python3-sphinx \ + python3-venv \ + sphinx \ + unzip \ + wget \ + && \ + rm --recursive --force /var/lib/apt/lists/* +ENV PYTHONUNBUFFERED=1 +ENV VIRTUAL_ENV=/opt/python/venv +RUN python3 -m venv ${VIRTUAL_ENV} +ENV PATH="${VIRTUAL_ENV}/bin:$PATH" +COPY ./wasp/requirements.txt /tmp/requirements.txt +RUN pip install --no-cache-dir \ + --requirement /tmp/requirements.txt + +# Install main ("payload") software +# None; Python scripts are provided through volumes at run time. + +# Switch to non-root user +RUN groupadd ${PAYLOAD} && \ + useradd --no-log-init --gid ${PAYLOAD} ${PAYLOAD} +USER ${PAYLOAD} + +# Set up working dir. and add to `$PATH` to ease project script exec. +WORKDIR /project/ +ENV PATH="/project:$PATH" + +# Execute main ("payload") software by default +ENTRYPOINT ["make"] +CMD ["--help"] diff --git a/tools/docker/docker-compose-build.yml b/tools/docker/docker-compose-build.yml new file mode 100644 index 00000000..d2d1bbf2 --- /dev/null +++ b/tools/docker/docker-compose-build.yml @@ -0,0 +1,15 @@ +x-build-template: + &build-default + build: + context: ../../ + dockerfile: ./tools/docker/Dockerfile + args: + - DOCKER_IMG_VER=${DOCKER_IMG_VER} + image: wasp-os/wasp-os-dev:${DOCKER_IMG_VER} + +services: + build-ver: + *build-default + build-latest: + << : *build-default + image: wasp-os/wasp-os-dev:latest diff --git a/tools/docker/setup-env.sh b/tools/docker/setup-env.sh deleted file mode 100644 index 245fb036..00000000 --- a/tools/docker/setup-env.sh +++ /dev/null @@ -1,4 +0,0 @@ -export PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH - - -cd ~/wasp-os diff --git a/tools/docker/shell b/tools/docker/shell deleted file mode 100755 index 01561b13..00000000 --- a/tools/docker/shell +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -docker build --build-arg uid=$UID --build-arg gid=$(id -g) -t wasp-os-dev ./tools/docker - -docker run \ - -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ - -v $(pwd):/home/user/wasp-os \ - -u user \ - -e DISPLAY \ - --init \ - --device /dev/dri \ - -it \ - --rm \ - wasp-os-dev \ - bash -l diff --git a/tools/ota-dfu b/tools/ota-dfu index 3d6fd30d..92858150 160000 --- a/tools/ota-dfu +++ b/tools/ota-dfu @@ -1 +1 @@ -Subproject commit 3d6fd30d33c2b20bc86ff6b9269fddf4a1d4c7c6 +Subproject commit 928581501dfbca71319559731247a3a9b7295c00 diff --git a/wasp/requirements.txt b/wasp/requirements.txt index 10fad09a..cee0e33f 100644 --- a/wasp/requirements.txt +++ b/wasp/requirements.txt @@ -1,6 +1,7 @@ cbor click cryptography +meson-python numpy pexpect Pillow