From 3a98eb3f9c2666aa663612230c723be5a82279b0 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:17:07 +0100 Subject: [PATCH] fixed dockerfile and updaed docs --- Dockerfile | 12 ++++++++---- docs/development/Building in Docker.md | 13 +++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71077c8ed96..c7aa633f273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,19 @@ ARG USER_ID ARG GROUP_ID ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-pip gcc-arm-none-eabi ninja-build gdb +RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-pip gcc-arm-none-eabi ninja-build + +RUN if [ "$GDB" = "yes" ]; then apt-get install -y gdb; fi RUN pip install pyyaml # if either of these are already set the same as the user's machine, leave them be and ignore the error -RUN if [ -n "$USER_ID" ]; then RUN addgroup --gid $GROUP_ID inav; exit 0; fi -RUN if [ -n "$USER_ID" ]; then RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID inav; exit 0; fi +RUN addgroup --gid $GROUP_ID inav; exit 0; +RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID inav; exit 0; + +ARG INAV_IMAGE_USER=inav +USER $INAV_IMAGE_USER -RUN if [ -n "$USER_ID" ]; then USER inav; fi RUN git config --global --add safe.directory /src VOLUME /src diff --git a/docs/development/Building in Docker.md b/docs/development/Building in Docker.md index 39cd887003a..21db47a8587 100755 --- a/docs/development/Building in Docker.md +++ b/docs/development/Building in Docker.md @@ -33,23 +33,24 @@ If you are getting error "standard_init_linux.go:219: exec user process caused: You'll have to manually execute the same steps that the build script does: -1. `docker build -t inav-build .` +1. `docker build --build-arg INAV_IMAGE_USER=root -t inav-build .` + This step is only needed the first time. -2. `docker run --rm -it -u root -v :/src inav-build ` + + Note that on Windows/WSL 2 mounted /src folder is writeable for root user only. You have to run build under root user. This is achieved with `--build-arg INAV_IMAGE_USER=root` option in the command line above. + + If GDB should be installed in the image, add argument '--build-arg GDB=yes' +2. `docker run --rm -it -v :/src inav-build ` + Where `` must be replaced with the absolute path of where you cloned this repo (see above), and `` with the name of the target that you want to build. - + Note that on Windows/WSL 2 mounted /src folder is writeable for root user only. You have to run build under root user. You can achieve this by using `-u root` option in the command line above. 3. If you need to update `Settings.md`, run: -`docker run --entrypoint /src/cmake/docker_docs.sh --rm -it -u root -v :/src inav-build` +`docker run --entrypoint /src/cmake/docker_docs.sh --rm -it -v :/src inav-build` 4. Building SITL: -`docker run --rm --entrypoint /src/cmake/docker_build_sitl.sh -it -u root -v :/src inav-build` +`docker run --rm --entrypoint /src/cmake/docker_build_sitl.sh -it -v :/src inav-build` 5. Running SITL: -`docker run -p 5760:5760 -p 5761:5761 -p 5762:5762 -p 5763:5763 -p 5764:5764 -p 5765:5765 -p 5766:5766 -p 5767:5767 --entrypoint /src/cmake/docker_run_sitl.sh --rm -it -u root -v :/src inav-build`. +`docker run -p 5760:5760 -p 5761:5761 -p 5762:5762 -p 5763:5763 -p 5764:5764 -p 5765:5765 -p 5766:5766 -p 5767:5767 --entrypoint /src/cmake/docker_run_sitl.sh --rm -it -v :/src inav-build`. + SITL command line parameters can be adjusted in `cmake/docker_run_sitl.sh`. Refer to the [Linux](#Linux) instructions or the [build script](/build.sh) for more details.