diff --git a/.docker_cache/empty_file b/.docker_cache/empty_file new file mode 100644 index 00000000000..e69de29bb2d diff --git a/.gitignore b/.gitignore index 4133ad85fbe..665dd29ad05 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ __generated__ cache.sqlite cache.sqlite-journal out.png +.docker_cache/ diff --git a/platform/linux/Dockerfile b/platform/linux/Dockerfile index b55061954f5..ae2321eb921 100644 --- a/platform/linux/Dockerfile +++ b/platform/linux/Dockerfile @@ -1,20 +1,13 @@ FROM ubuntu:22.04 -# When running docker with -u flag, the user should exist in the container to avoid various warnings -RUN groupadd -f user && useradd -m -g user user - # Install build tools and dependencies RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y \ apt-transport-https \ curl \ gnupg \ - && curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg \ - && mv bazel-archive-keyring.gpg /usr/share/keyrings \ - && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ - && apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - bazel \ + build-essential \ + libsqlite3-dev \ libcurl4-openssl-dev \ libglfw3-dev \ libuv1-dev \ @@ -28,6 +21,15 @@ RUN apt-get update \ cmake \ ccache \ ninja-build \ - pkg-config + pkg-config \ + && : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check + +# This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it +RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 -o /usr/local/bin/bazel \ + && chmod +x /usr/local/bin/bazel \ + && : + +# When running docker with -u flag, the user should exist in the container to avoid various warnings +RUN groupadd -f user && useradd -m -g user user -WORKDIR /code +WORKDIR /app diff --git a/platform/linux/README.md b/platform/linux/README.md index 79688d84ab3..fc9151cb84d 100644 --- a/platform/linux/README.md +++ b/platform/linux/README.md @@ -30,14 +30,16 @@ You can use a Docker container to build MapLibre Native. A `Dockerfile` that ins ```bash # Build docker image from the repo root -docker build -t maplibre-native-image -f platform/linux/Dockerfile . +docker build \ + -t maplibre-native-image \ + -f platform/linux/Dockerfile . # Run docker image as the current user. # This ensures that the files created in the container are owned by the current user. -docker run --rm -it -v "$PWD:/code/" -u $(id -u):$(id -g) maplibre-native-image ___any_build_command___ +docker run --rm -it -v "$PWD:/app/" -v "$PWD/.docker_cache:/home/user/.cache" -u $(id -u):$(id -g) maplibre-native-image ___any_build_command___ # You can also execute build commands from inside the docker container by starting it without parameters: -docker run --rm -it -v "$PWD:/code/" -u $(id -u):$(id -g) maplibre-native-image +docker run --rm -it -v "$PWD:/app/" -v "$PWD/.docker_cache:/home/user/.cache" -u $(id -u):$(id -g) maplibre-native-image ``` You can safely ignore this type of message and a missing username. It happens if your linux user was not the first one created on the system.