Skip to content

Commit

Permalink
Set up Bazelisk in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jul 22, 2024
1 parent 89a860d commit 6a1f5ab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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
Empty file added .docker_cache/empty_file
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ __generated__
cache.sqlite
cache.sqlite-journal
out.png
.docker_cache/
22 changes: 11 additions & 11 deletions platform/linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
8 changes: 5 additions & 3 deletions platform/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6a1f5ab

Please sign in to comment.