Skip to content

Commit

Permalink
Move docker files to /docker
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jul 24, 2024
1 parent cca9a92 commit daa5c7d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 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
2 changes: 1 addition & 1 deletion platform/linux/Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create docker user as passed in by the build command
# 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
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Linux

These steps will allow you to compile code as described [platform/linux/README.md](../platform/linux/README.md) using a docker container. All the steps should be executed from the root of the repository.

ATTENTION: You cannot build MapLibre native using both Docker and host methods at the same time. If you want to switch, you need to clean the repository first, e.g. by using this command:

```bash
git clean -dxfi -e .idea -e .clwb -e .vscode
```

### Build Docker Image

You must build your own docker image, specific with your user and group IDs to ensure file permissions stay correct.

```bash
# Build docker image from the repo __root__
# Specifying USER_ID and GROUP_ID allows container to create files with the same owner as the host user,
# and avoids having to pass -u $(id -u):$(id -g) to docker run.
docker build \
-t maplibre-native-image \
--build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \
-f platform/linux/Dockerfile \
platform/linux
```

## Run Docker Container

```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
```

You can also run any command inside the container, for example:

```bash
docker run --rm -it -v "$PWD:/app/" -v "$PWD/.docker_cache:/home/user/.cache" maplibre-native-image cmake ...
```
File renamed without changes.
24 changes: 2 additions & 22 deletions platform/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,7 @@ Optional: `libsqlite3-dev` (also available as vendored dependency).

### Building with Docker

You can use a Docker container to build MapLibre Native. Note that you cannot build using both Docker and host methods at the same time. If you want to switch, you need to clean the repository first, e.g. by using `git clean -dxfi -e .idea -e .clwb -e .vscode`

```bash
# Build docker image from the repo root
# Specifying USER_ID and GROUP_ID allows container to create files with the same owner as the host user,
# and avoids having to pass -u $(id -u):$(id -g) to docker run.
docker build \
-t maplibre-native-image \
--build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \
-f platform/linux/Dockerfile \
platform/linux

# 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 ___any_build_command___
```
See instructions in [docker/README.md](../../docker/README.md) to build docker container

## Build

Expand All @@ -59,16 +43,12 @@ Running `mbgl-render --style https://raw.githubusercontent.com/maplibre/demotile

![Sample image of world from mbgl-render command](/misc/sample-maplibre-style-mbgl-render-out.png)

### Outside of Docker

Render output image using default MapLibre demo tiles server. You can run this binary on your host machine even if you built it inside a Docker container.

```bash
./build/bin/mbgl-render --style https://raw.githubusercontent.com/maplibre/demotiles/gh-pages/style.json --output out.png
xdg-open out.png
```

### Inside Docker
### Headless rendering

If you run `mbgl-render` inside a Docker or on a remote headless server, you will likely get this error because there is no X server running in the container.

Expand Down

0 comments on commit daa5c7d

Please sign in to comment.