From c7a841a9c179d16ac6fe7c4c6b386ea479b34950 Mon Sep 17 00:00:00 2001 From: kon-foo <25391223+kon-foo@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:29:12 +0100 Subject: [PATCH 1/3] docker build instructions --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index b8008b9..c1d4b9c 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,30 @@ The following configuration settings can be added to the first `cmake -S . -B bu Ex: `-DENABLE_USERAPPS="Apps::Timer, Apps::Alarm"`. The default list of user applications will be selected if this variable is not set. +### Build with Docker + +You can also build the simulator using Docker. This is useful if you don't want to install all the dependencies on your system. +First build the Docker image: +```sh +docker build -t infinisim-build . +``` + +Afterwards you can build the simulator with: +```sh +docker run --rm -it -v ${PWD}:/sources infinisim-build +``` + +By default this builds the InfiniTime from the submodule in your ${PWD}. If you want to use a different repository, you got to mount it and pass the path to the `INFITIME_DIR` variable: +```sh +docker run --rm -it -v ${PWD}:/sources -v ${PWD}/../InfiniTime:/infinitime -e INFITIME_DIR=/infinitime infinisim-build +``` + +Other build configurations can be passed to the BUILD_FLAGS variable: +```sh +docker run --rm -it -v ${PWD}:/sources -e BUILD_FLAGS=-DENABLE_USERAPPS="Apps::MyApp,Apps::Alarm" infinisim-build +``` + + ## Run Simulator When the build was successful the simulator binary can be started with From 65db2362c639651325f622f14a00a9c850f37317 Mon Sep 17 00:00:00 2001 From: kon-foo <25391223+kon-foo@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:30:02 +0100 Subject: [PATCH 2/3] docker builder image --- Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2419d3c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:22.04 + +# Install dependencies +RUN apt-get update && \ + apt-get install -y \ + curl \ + cmake \ + libsdl2-dev \ + g++ \ + python3-pip \ + python3-venv \ + libpng-dev \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh \ + && bash nodesource_setup.sh \ + && apt-get install -y nodejs \ + && npm install -g lv_font_conv@1.5.2 \ + && pip install wheel Pillow + + +WORKDIR /sources + +# Define build configuration environment variables with default values +ENV INFITIME_DIR="/sources/InfiniTime" +ENV BUILD_FLAGS="" + +CMD ["bash", "-c", "cmake -S . -B build -DInfiniTime_DIR=${INFITIME_DIR} ${BUILD_FLAGS} && cmake --build build -j4"] From 20ba7265707457f448e7a7f755e3ac86b86cd236 Mon Sep 17 00:00:00 2001 From: kon-foo <25391223+kon-foo@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:53:00 +0100 Subject: [PATCH 3/3] quiet flag; build env vars; remove apt-cache --- Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2419d3c..0dd9a96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,26 @@ FROM ubuntu:22.04 # Install dependencies -RUN apt-get update && \ +ARG DEBIAN_FRONTEND=noninteractive +ARG NODE_MAJOR=20 +RUN apt-get update -qq && \ apt-get install -y \ curl \ cmake \ libsdl2-dev \ g++ \ + libpng-dev \ python3-pip \ python3-venv \ - libpng-dev \ - git \ - && rm -rf /var/lib/apt/lists/* \ - && curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ + && curl -sL https://deb.nodesource.com/setup_${NODE_MAJOR}.x -o nodesource_setup.sh \ && bash nodesource_setup.sh \ && apt-get install -y nodejs \ && npm install -g lv_font_conv@1.5.2 \ && pip install wheel Pillow - WORKDIR /sources - -# Define build configuration environment variables with default values +# Build configuration environment variables ENV INFITIME_DIR="/sources/InfiniTime" ENV BUILD_FLAGS=""