Skip to content

Commit

Permalink
Bump docker base to Ubuntu 22.04 -> 24.04
Browse files Browse the repository at this point in the history
Several updates to allow docker to work with the new cmake
  • Loading branch information
nyurik committed Jan 17, 2025
1 parent 42490d5 commit c307171
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

# Install build tools and dependencies
RUN apt-get update \
Expand Down Expand Up @@ -40,23 +40,24 @@ RUN echo "Download and install Bazel" \
&& chmod +x /usr/local/bin/bazel \
&& :


ARG USERNAME=user
# This username is hardcoded in several places, and should simply match whatever base image uses
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create docker user wuth sudo rights as passed in by the build command
# This was modeled on https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
# On a Mac, USER_GID might already exist, so ignore it if it fails (--force)
RUN groupadd --force --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
RUN groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chown -R $USER_UID:$USER_GID /home/$USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# This allows users to `docker run` without specifying -u and -g
USER $USERNAME

RUN pip install pre-commit
#RUN pip install pre-commit

ENV RUSTUP_HOME=/home/$USERNAME/.cache/.rustup \
CARGO_HOME=/home/$USERNAME/.cache/.cargo \
Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ docker build \
```bash
# Run all build commands using the docker container.
# You can also execute build commands from inside the docker container by starting it without the build command.
docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image
docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/ubuntu/.cache" maplibre-native-image
```

You can also use the container to run just one specific commands, e.g. `cmake` or `bazel`. Any downloaded dependencies will be cached in the `docker/.cache` directory.

```bash
docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image cmake ...
docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/ubuntu/.cache" maplibre-native-image cmake ...
```
3 changes: 2 additions & 1 deletion docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ if [ ! -d /app/.github ] || [ ! -d ~/.cache ]; then
echo " From the root of this repo, run the following command."
echo " You may add any command to perform in the container at the end of this command."
echo " "
echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/'"$USERNAME"'/.cache" maplibre-native-image'
# shellcheck disable=SC2016
echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:'"$HOME"'/.cache" maplibre-native-image'
exit 1
fi

Expand Down

0 comments on commit c307171

Please sign in to comment.