From 6a1f5ab4318ccf0b07c01fd4a7909f60c029aa14 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 22 Jul 2024 15:51:30 -0400 Subject: [PATCH] Set up Bazelisk in Dockerfile --- .../npm_translate_lock_LTE4Nzc1MDcwNjU= | 6 ++--- .docker_cache/empty_file | 0 .gitignore | 1 + platform/linux/Dockerfile | 22 +++++++++---------- platform/linux/README.md | 8 ++++--- 5 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 .docker_cache/empty_file diff --git a/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= b/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= index 99b2490ac37..d330048e844 100755 --- a/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= +++ b/.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU= @@ -1,7 +1,5 @@ # @generated # Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "//:pnpm-lock.yaml"). # This file should be checked into version control along with the pnpm-lock.yaml file. -.npmrc=-592547263 -pnpm-lock.yaml=104874376 -package-lock.json=-1109603374 -package.json=752745807 +pnpm-lock.yaml=322447152 +package.json=1512585561 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..4d9d7cecc6a 100644 --- a/platform/linux/Dockerfile +++ b/platform/linux/Dockerfile @@ -1,20 +1,11 @@ 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 \ libcurl4-openssl-dev \ libglfw3-dev \ libuv1-dev \ @@ -28,6 +19,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.