├── .github ├── dependabot.yml └── workflows │ ├── build-single-image.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.MD ├── cloudbuild.yaml ├── docker ├── basic-alpine.Dockerfile ├── basic-debian.Dockerfile ├── basic-scratch.Dockerfile ├── frontend-alpine.Dockerfile ├── frontend-debian.Dockerfile ├── frontend-scratch.Dockerfile ├── maplibre-native-debian.Dockerfile ├── tilemaker-debian.Dockerfile └── tippecanoe-alpine.Dockerfile ├── helpers ├── build_and_test.sh ├── notes.md └── selftest.sh ├── package-lock.json ├── package.json ├── scripts └── download_versatiles_binary.sh └── src ├── generate_tiles.sh └── process_vars.js /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: docker 4 | directory: / 5 | schedule: { interval: monthly } 6 | groups: { github-action: { patterns: ['*'] } } 7 | - package-ecosystem: github-actions 8 | directory: / 9 | schedule: { interval: monthly } 10 | groups: { github-action: { patterns: ['*'] } } 11 | -------------------------------------------------------------------------------- /.github/workflows/build-single-image.yml: -------------------------------------------------------------------------------- 1 | name: Build a single Docker image 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | repo: { default: "versatiles", description: repo } 6 | tag: { required: true, description: tag } 7 | variants: { default: "", description: variants } 8 | filename: { required: true, description: filename } 9 | platforms: { default: "linux/amd64,linux/arm64", description: platforms } 10 | workflow_call: 11 | inputs: 12 | repo: { type: string, default: "versatiles" } 13 | tag: { type: string, required: true } 14 | variants: { type: string, default: "" } 15 | filename: { type: string, required: true } 16 | platforms: { type: string, default: "linux/amd64,linux/arm64" } 17 | 18 | env: 19 | CARGO_TERM_COLOR: always 20 | 21 | jobs: 22 | build: 23 | name: ${{ inputs.repo }}:${{ inputs.variants }} 24 | runs-on: ubuntu-latest 25 | permissions: 26 | packages: write 27 | contents: read 28 | steps: 29 | - name: Log in to Docker Hub 30 | uses: docker/login-action@v3 31 | with: 32 | username: ${{ secrets.DOCKERHUB_USERNAME }} 33 | password: ${{ secrets.DOCKERHUB_TOKEN }} 34 | 35 | - name: Set up QEMU 36 | uses: docker/setup-qemu-action@v3 37 | 38 | - name: Set up Docker Buildx 39 | uses: docker/setup-buildx-action@v3 40 | 41 | - name: Log in to GitHub Container Registry 42 | uses: docker/login-action@v3 43 | with: 44 | registry: ghcr.io 45 | username: ${{ github.repository_owner }} 46 | password: ${{ secrets.GITHUB_TOKEN }} 47 | 48 | - uses: actions/setup-node@v4 49 | with: 50 | node-version: 'latest' 51 | 52 | - uses: actions/checkout@v4 53 | 54 | - run: npm ci 55 | 56 | - id: init 57 | run: node src/process_vars.js '${{ toJSON(inputs) }}' | tee -a "$GITHUB_OUTPUT" 58 | 59 | - name: Build and push 60 | uses: docker/build-push-action@v6 61 | with: 62 | platforms: ${{ steps.init.outputs.platforms }} 63 | file: "docker/${{ steps.init.outputs.filename }}.Dockerfile" 64 | push: true 65 | tags: ${{ steps.init.outputs.tags }} 66 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Build all Docker images 2 | on: 3 | repository_dispatch: 4 | inputs: 5 | run_jobs: 6 | default: "all" 7 | workflow_dispatch: 8 | inputs: 9 | run_jobs: 10 | description: "Run which image build process?" 11 | default: "all" 12 | type: choice 13 | options: 14 | - all 15 | - basic 16 | - frontend 17 | - tilemaker 18 | - tippecanoe 19 | 20 | env: 21 | FORCE_COLOR: 1 22 | 23 | jobs: 24 | init: 25 | name: Init 26 | runs-on: ubuntu-latest 27 | outputs: 28 | tag: ${{ steps.result.outputs.tag }} 29 | steps: 30 | - name: Get Latest Tag 31 | id: result 32 | run: curl -s https://api.github.com/repos/versatiles-org/versatiles-rs/tags | jq -r '"tag=" + first(.[] | .name | select(startswith("v")))' >> "$GITHUB_OUTPUT" 33 | 34 | ### BASIC IMAGES 35 | 36 | basic: 37 | name: Basic 38 | if: contains( fromJSON('["all", "basic", "frontend", "tilemaker"]'), github.event.inputs.run_jobs ) 39 | needs: [init] 40 | strategy: 41 | max-parallel: 2 42 | fail-fast: false 43 | matrix: 44 | include: 45 | - { variants: "alpine,", filename: basic-alpine } 46 | - { variants: "debian", filename: basic-debian } 47 | - { variants: "scratch", filename: basic-scratch } 48 | uses: ./.github/workflows/build-single-image.yml 49 | secrets: inherit 50 | with: 51 | variants: ${{ matrix.variants }} 52 | filename: ${{ matrix.filename }} 53 | tag: ${{ needs.init.outputs.tag }} 54 | 55 | ### FRONTEND IMAGES 56 | 57 | frontend: 58 | name: Frontend 59 | if: contains( fromJSON('["all", "frontend"]'), github.event.inputs.run_jobs ) 60 | needs: [init, basic] 61 | strategy: 62 | max-parallel: 2 63 | fail-fast: false 64 | matrix: 65 | include: 66 | - { variants: "alpine,", filename: frontend-alpine } 67 | - { variants: "debian", filename: frontend-debian } 68 | - { variants: "scratch", filename: frontend-scratch } 69 | uses: ./.github/workflows/build-single-image.yml 70 | secrets: inherit 71 | with: 72 | repo: versatiles-frontend 73 | variants: ${{ matrix.variants }} 74 | filename: ${{ matrix.filename }} 75 | tag: ${{ needs.init.outputs.tag }} 76 | 77 | ### TILEMAKER IMAGES 78 | 79 | tilemaker: 80 | name: Tilemaker 81 | if: contains( fromJSON('["all", "tilemaker"]'), github.event.inputs.run_jobs ) 82 | needs: [init, basic] 83 | uses: ./.github/workflows/build-single-image.yml 84 | secrets: inherit 85 | with: 86 | repo: versatiles-tilemaker 87 | variants: "debian," 88 | filename: "tilemaker-debian" 89 | platforms: "linux/amd64" 90 | tag: ${{ needs.init.outputs.tag }} 91 | 92 | ### MAPLIBRE-NATIVE IMAGES 93 | 94 | tippecanoe: 95 | name: Tippecanoe 96 | if: contains( fromJSON('["all", "tippecanoe"]'), github.event.inputs.run_jobs ) 97 | needs: [init] 98 | uses: ./.github/workflows/build-single-image.yml 99 | secrets: inherit 100 | with: 101 | repo: tippecanoe 102 | variants: "alpine," 103 | filename: "tippecanoe-alpine" 104 | platforms: "linux/amd64" 105 | tag: ${{ needs.init.outputs.tag }} 106 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /result/ 3 | /temp/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 VersaTiles 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | 2 | [![Docker Hub Pulls](https://img.shields.io/docker/pulls/versatiles/versatiles)](https://hub.docker.com/r/versatiles/versatiles/latest-debian) 3 | 4 | # VersaTiles Docker 5 | 6 | This repo contains .Dockerfiles and GitHub workflows for building Docker images with VersaTiles. 7 | 8 | ## Images `versatiles` 9 | 10 | - Contains only the [versatiles](https://github.com/versatiles-org/versatiles-rs) binary 11 | - Supported OS: Alpine, Debian and Scratch 12 | - Supported architectures: AMD64, ARM64 13 | - Images are available on [GitHub Container Registry](https://github.com/versatiles-org/versatiles-docker/pkgs/container/versatiles) and [Docker Hub](https://hub.docker.com/r/versatiles/versatiles) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
OSVersionImage Size
Linux: AlpineDocker Image version versatiles/alpineDocker Image size versatiles/alpine
Linux: DebianDocker Image version versatiles/debianDocker Image size versatiles/debian
Linux: ScratchDocker Image version versatiles/scratchDocker Image size versatiles/scratch
37 | 38 | ## Images `versatiles-frontend` 39 | 40 | - Contains: [versatiles](https://github.com/versatiles-org/versatiles-rs) and the latest [frontend](https://github.com/versatiles-org/versatiles-frontend) 41 | - Supported OS: Alpine, Debian and Scratch 42 | - Supported architectures: AMD64, ARM64 43 | - Images are available on [GitHub Container Registry](https://github.com/versatiles-org/versatiles-docker/pkgs/container/versatiles-frontend) and on [Docker Hub](https://hub.docker.com/r/versatiles/versatiles-frontend) 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
OSVersionImage Size
Linux: AlpineDocker Image version versatiles-frontend/alpineDocker Image size versatiles-frontend/alpine
Linux: DebianDocker Image version versatiles-frontend/debianDocker Image size versatiles-frontend/debian
Linux: ScratchDocker Image version versatiles-frontend/scratchDocker Image size versatiles-frontend/scratch
67 | 68 | ## Images `versatiles-tilemaker` 69 | 70 | - Contains: [versatiles](https://github.com/versatiles-org/versatiles-rs), [tilemaker](https://github.com/systemed/tilemaker) and some helpers like: [aria2](https://aria2.github.io), [curl](https://curl.se/), [gdal](https://gdal.org), [osmium tool](https://osmcode.org/osmium-tool/) 71 | - Supported OS: Debian 72 | - Supported architectures: AMD64 73 | - Images are available on [GitHub Container Registry](https://github.com/versatiles-org/versatiles-docker/pkgs/container/versatiles-tilemaker) and on [Docker Hub](https://hub.docker.com/r/versatiles/versatiles-tilemaker) 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
OSVersionImage Size
Linux: DebianDocker Image version versatiles-tilemaker/debianDocker Image size versatiles-tilemaker/debian
87 | 88 | ## Next steps: 89 | 90 | We are planning to add: 91 | - `versatiles-nginx` containing nginx, lets encrypt and [frontend](https://github.com/versatiles-org/versatiles-frontend) to have everything to run a simple server ([Issue #5](https://github.com/versatiles-org/versatiles-docker/issues/5)) 92 | 93 | ## Notes: 94 | 95 | Build and generate tiles locally: 96 | ```bash 97 | docker build --file=docker/tilemaker-debian.Dockerfile --tag=test . 98 | mkdir -p result 99 | docker run -it --rm --privileged --mount="type=bind,source=$(pwd)/result,target=/app/result" test generate_tiles.sh https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf osm.berlin "13.0,52.3,13.8,52.7" 100 | ``` 101 | 102 | 108 | -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | options: 2 | machineType: "N1_HIGHCPU_8" 3 | timeout: 7200s 4 | steps: 5 | - name: gcr.io/cloud-builders/docker 6 | env: 7 | - DOCKER_BUILDKIT=1 8 | args: 9 | - buildx 10 | - build 11 | - "--progress=plain" 12 | - "--file=docker/tilemaker-debian.Dockerfile" 13 | - "--tag=test" 14 | - . 15 | -------------------------------------------------------------------------------- /docker/basic-alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM --platform=$BUILDPLATFORM curlimages/curl AS builder 3 | ARG TARGETPLATFORM 4 | COPY scripts/download_versatiles_binary.sh . 5 | RUN sh ./download_versatiles_binary.sh "$TARGETPLATFORM-musl" 6 | 7 | # create production system 8 | FROM alpine:latest 9 | 10 | # copy versatiles and selftest 11 | WORKDIR /app 12 | COPY --from=builder --chmod=0755 --chown=root /home/curl_user/versatiles /app/ 13 | ENV PATH="/app/:$PATH" 14 | -------------------------------------------------------------------------------- /docker/basic-debian.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM --platform=$BUILDPLATFORM curlimages/curl AS builder 3 | ARG TARGETPLATFORM 4 | COPY scripts/download_versatiles_binary.sh . 5 | RUN sh ./download_versatiles_binary.sh "$TARGETPLATFORM-gnu" 6 | 7 | # create production system 8 | FROM debian:stable-slim 9 | 10 | # copy versatiles and selftest 11 | WORKDIR /app 12 | COPY --from=builder --chmod=0755 --chown=root /home/curl_user/versatiles /app/ 13 | ENV PATH="/app/:$PATH" 14 | -------------------------------------------------------------------------------- /docker/basic-scratch.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM --platform=$BUILDPLATFORM curlimages/curl AS builder 3 | ARG TARGETPLATFORM 4 | COPY scripts/download_versatiles_binary.sh . 5 | RUN sh ./download_versatiles_binary.sh "$TARGETPLATFORM-musl" 6 | 7 | # create production system 8 | FROM scratch 9 | 10 | # copy versatiles and selftest 11 | WORKDIR /app 12 | COPY --from=builder --chmod=0755 --chown=root /home/curl_user/versatiles /app/ 13 | ENV PATH="/app/:$PATH" 14 | -------------------------------------------------------------------------------- /docker/frontend-alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM curlimages/curl AS builder 3 | 4 | # download frontend 5 | RUN curl -sL "https://github.com/versatiles-org/versatiles-frontend/releases/latest/download/frontend-dev.br.tar.gz" | gzip -d > frontend-dev.br.tar 6 | 7 | FROM ghcr.io/versatiles-org/versatiles:latest-alpine 8 | 9 | COPY --from=builder /home/curl_user/frontend-dev.br.tar . 10 | -------------------------------------------------------------------------------- /docker/frontend-debian.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM curlimages/curl AS builder 3 | 4 | # download frontend 5 | RUN curl -sL "https://github.com/versatiles-org/versatiles-frontend/releases/latest/download/frontend-dev.br.tar.gz" | gzip -d > frontend-dev.br.tar 6 | 7 | FROM ghcr.io/versatiles-org/versatiles:latest-debian 8 | 9 | COPY --from=builder /home/curl_user/frontend-dev.br.tar . 10 | -------------------------------------------------------------------------------- /docker/frontend-scratch.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM curlimages/curl AS builder 3 | 4 | # download frontend 5 | RUN curl -sL "https://github.com/versatiles-org/versatiles-frontend/releases/latest/download/frontend-dev.br.tar.gz" | gzip -d > frontend-dev.br.tar 6 | 7 | FROM ghcr.io/versatiles-org/versatiles:latest-scratch 8 | 9 | COPY --from=builder /home/curl_user/frontend-dev.br.tar . 10 | -------------------------------------------------------------------------------- /docker/maplibre-native-debian.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM debian:latest AS builder 3 | 4 | RUN apt update 5 | RUN apt install -y ccache cmake g++ git libcurl4-openssl-dev libglfw3-dev libicu-dev libjpeg-dev libpng-dev libuv1-dev libwebp-dev ninja-build pkg-config 6 | 7 | #RUN mkdir -p /tmp 8 | RUN git clone --depth 1 --recurse-submodules --shallow-submodules -j8 https://github.com/maplibre/maplibre-native.git /tmp 9 | 10 | WORKDIR /tmp 11 | RUN cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ 12 | RUN cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null) 13 | RUN cd /; find . | grep "libcurl.so.4" 14 | 15 | # create production system 16 | FROM debian:bookworm-slim 17 | COPY --from=builder /tmp/build/bin/* /usr/bin/ 18 | COPY --from=builder /usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu/ 19 | #RUN apk add --no-cache libgcc libstdc++ sqlite-libs 20 | WORKDIR /data 21 | #RUN cd /usr/bin/; ls -lah 22 | ENTRYPOINT ["/usr/bin/mbgl-render"] 23 | -------------------------------------------------------------------------------- /docker/tilemaker-debian.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/versatiles-org/versatiles:latest-debian 2 | 3 | RUN apt update -y && apt install -y \ 4 | aria2 \ 5 | build-essential \ 6 | curl \ 7 | gdal-bin \ 8 | git \ 9 | libboost-dev \ 10 | libboost-filesystem-dev \ 11 | libboost-iostreams-dev \ 12 | libboost-program-options-dev \ 13 | libboost-system-dev \ 14 | liblua5.3-dev lua5.3 \ 15 | libshp-dev \ 16 | libsqlite3-dev \ 17 | osmium-tool \ 18 | rapidjson-dev \ 19 | unzip \ 20 | wget \ 21 | zlib1g-dev 22 | 23 | # Install Tilemaker 24 | RUN \ 25 | git clone --depth 1 -q https://github.com/systemed/tilemaker.git tilemaker && \ 26 | cd tilemaker && \ 27 | make && \ 28 | make install && \ 29 | cd .. && \ 30 | rm -r tilemaker 31 | 32 | # Add Shortbread configuration 33 | RUN \ 34 | git clone --depth 1 -q --branch versatiles https://github.com/versatiles-org/shortbread-tilemaker shortbread-tilemaker && \ 35 | cd shortbread-tilemaker && \ 36 | bash get-shapefiles.sh && \ 37 | rm data/*.zip && \ 38 | rm -r .git data/simplified-water-polygons-split-3857 39 | 40 | # Add Scripts 41 | COPY --chmod=0755 src/generate_tiles.sh . 42 | -------------------------------------------------------------------------------- /docker/tippecanoe-alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | # create builder system 2 | FROM alpine:latest AS builder 3 | 4 | RUN apk update 5 | RUN apk add git make sqlite-dev zlib-dev bash g++ 6 | RUN mkdir -p /tmp 7 | RUN git clone --depth 1 https://github.com/mapbox/tippecanoe.git /tmp 8 | ENV PREFIX=/tmp 9 | RUN cd /tmp && make -j && make install 10 | 11 | # create production system 12 | FROM alpine:latest 13 | COPY --from=builder /tmp/bin/* /usr/bin/ 14 | RUN apk add --no-cache libgcc libstdc++ sqlite-libs 15 | WORKDIR /data 16 | ENTRYPOINT ["tippecanoe"] 17 | -------------------------------------------------------------------------------- /helpers/build_and_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd "$(dirname "$0")/.." 4 | 5 | set -e 6 | 7 | RED="\033[1;31m" 8 | GRE="\033[1;32m" 9 | YEL="\033[1;33m" 10 | END="\033[0m" 11 | 12 | run_arch() { 13 | case $1 in 14 | "x86") 15 | platform=linux/amd64 16 | ;; 17 | "arm") 18 | platform=linux/arm64 19 | ;; 20 | *) 21 | echo "Unknown target plattform $1" 22 | exit 1 23 | ;; 24 | esac 25 | 26 | name=$2 27 | 28 | if [ -z $name ]; then echo "name not set"; fi 29 | if [ -z $platform ]; then echo "platform not set"; fi 30 | 31 | echo -e "${YEL}Build and Test $name on $platform${END}" 32 | 33 | docker buildx build --platform=$platform --file=docker/$name.Dockerfile --tag=test . 34 | docker run --platform=$platform -it --rm test versatiles serve --auto-shutdown 1000 -p 8088 "https://download.versatiles.org/osm.versatiles" 35 | } 36 | 37 | function run() { 38 | run_arch x86 $1 39 | run_arch arm $1 40 | } 41 | 42 | run basic-alpine 43 | run basic-debian 44 | run basic-scratch 45 | run frontend-alpine 46 | run frontend-debian 47 | run frontend-scratch 48 | run tilemaker-debian 49 | #run debian-nginx 50 | -------------------------------------------------------------------------------- /helpers/notes.md: -------------------------------------------------------------------------------- 1 | 2 | Trigger single build: 3 | ```bash 4 | gh workflow run build-single-image.yml -R versatiles-org/versatiles-docker -F name="alpine" -F platform="linux/amd64" -F tag="v0.5.6" 5 | ``` 6 | 7 | Build locally: 8 | ```bash 9 | docker build --progress="plain" --file="docker/frontend-scratch.Dockerfile" . 10 | docker buildx build --platform="linux/amd64" --progress="plain" --file="docker/basic-alpine.Dockerfile" . 11 | ``` 12 | 13 | Build and test Docker: 14 | ```bash 15 | docker buildx build --platform=linux/amd64 --progress=plain --file=docker/basic-alpine.Dockerfile --tag=test . && docker run -it --rm test serve --auto-shutdown 1000 -p 8088 "https://download.versatiles.org/planet-20230605.versatiles" 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /helpers/selftest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -ex 3 | 4 | versatiles serve --auto-shutdown 1000 -p 8088 "https://download.versatiles.org/planet-20230605.versatiles" 5 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "versatiles-docker", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "versatiles-docker", 9 | "version": "1.0.0", 10 | "license": "MIT" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "versatiles-docker", 3 | "version": "1.0.0", 4 | "description": "This Repo contains .Dockerfiles and GitHub Workflows to build Docker images", 5 | "author": "Michael Kreil (https://github.com/MichaelKreil)", 6 | "type": "module", 7 | "license": "MIT" 8 | } 9 | -------------------------------------------------------------------------------- /scripts/download_versatiles_binary.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | TARGETPLATFORM=$1 6 | URL="https://github.com/versatiles-org/versatiles-rs/releases/latest/download/versatiles" 7 | 8 | case $TARGETPLATFORM in 9 | "linux/amd64-musl") 10 | curl -sL "${URL}-linux-musl-x86_64.tar.gz" | tar x -z -f - versatiles 11 | ;; 12 | "linux/arm64-musl") 13 | curl -sL "${URL}-linux-musl-aarch64.tar.gz" | tar x -z -f - versatiles 14 | ;; 15 | "linux/amd64-gnu") 16 | curl -sL "${URL}-linux-gnu-x86_64.tar.gz" | tar x -z -f - versatiles 17 | ;; 18 | "linux/arm64-gnu") 19 | curl -sL "${URL}-linux-gnu-aarch64.tar.gz" | tar x -z -f - versatiles 20 | ;; 21 | *) 22 | echo "Unknown target plattform $TARGETPLATFORM" 23 | exit 1 24 | ;; 25 | esac 26 | 27 | chmod +x versatiles 28 | -------------------------------------------------------------------------------- /src/generate_tiles.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # if you convert the whole planet you need: 4 | # - 170 GB RAM 5 | # - 400 GB SSD 6 | # - time: 7 | # - 3 minutes for download 8 | # - 50 minutes for osmium 9 | # - 70 minutes for tilemaker 10 | # - 180 minutes for versatiles 11 | 12 | mkdir -p data 13 | 14 | set -ex 15 | 16 | # reading arguments 17 | TILE_URL=$1 # url of pbf file 18 | TILE_NAME=$2 # name of the result 19 | TILE_BBOX=$3 # bbox 20 | 21 | if [[ $TILE_URL != http* ]] 22 | then 23 | echo "First argument must be a valid URL" 24 | exit 1 25 | fi 26 | 27 | if [ -z "$TILE_NAME" ] 28 | then 29 | echo "Second argument must be a name" 30 | exit 1 31 | fi 32 | 33 | if [ -z "$TILE_BBOX" ] 34 | then 35 | TILE_BBOX="-180,-86,180,86" 36 | fi 37 | 38 | echo "GENERATE OSM VECTOR TILES:" 39 | echo " URL: $TILE_URL" 40 | echo " NAME: $TILE_NAME" 41 | echo " BBOX: $TILE_BBOX" 42 | 43 | echo "DOWNLOAD DATA" 44 | aria2c --seed-time=0 --dir=data "$TILE_URL" 45 | pbf_file=$(ls data/*.pbf) 46 | if [ $(echo $pbf_file | wc -l) -ne 1 ] 47 | then 48 | echo "There should be only one PBF file" 49 | exit 1 50 | fi 51 | mv "${pbf_file}" data/input.pbf 52 | 53 | echo "PREPARE DATA" 54 | time osmium renumber --progress -o data/prepared.pbf data/input.pbf 55 | rm data/input.pbf 56 | 57 | echo "RENDER TILES" 58 | cd shortbread-tilemaker 59 | time tilemaker --input ../data/prepared.pbf --config config.json --process process.lua --bbox $TILE_BBOX --output ../data/output.mbtiles --compact --store ../tmp 60 | cd .. 61 | rm -rf tmp || true 62 | rm data/prepared.pbf 63 | 64 | echo "CONVERT TILES" 65 | file_size=$(stat -c %s data/output.mbtiles) 66 | ram_disk_size=$(perl -E "use POSIX;say ceil($file_size/1073741824 + 0.3)") 67 | mkdir -p ramdisk 68 | mount -t tmpfs -o size=${ram_disk_size}G ramdisk ramdisk 69 | mv data/output.mbtiles ramdisk 70 | time versatiles convert -c brotli ramdisk/output.mbtiles data/output.versatiles 71 | 72 | echo "RETURN RESULT" 73 | mv data/output.versatiles "/app/result/${TILE_NAME}.versatiles" 74 | -------------------------------------------------------------------------------- /src/process_vars.js: -------------------------------------------------------------------------------- 1 | 2 | // Used for GitHub Workflow build-single-image.yml 3 | 4 | import { argv } from 'node:process'; 5 | 6 | let args = JSON.parse(argv[2]); 7 | let keys = 'filename,platforms,repo,tag,variants'.split(','); 8 | 9 | 10 | 11 | // cleanup values, set to undefined if not defined 12 | keys.forEach(key => { 13 | if (typeof args[key] !== 'string') return args[key] = undefined; 14 | args[key] = args[key].trim(); 15 | let value = args[key].toLowerCase(); 16 | if ((value === '') || (value === 'false')) return args[key] = undefined; 17 | }) 18 | 19 | // check undefined values 20 | if (!args.filename) throw Error('filename not defined'); 21 | args.platforms ??= 'linux/amd64,linux/arm64'; 22 | args.repo ??= 'versatiles'; 23 | if (!args.tag) throw Error('tag not defined'); 24 | args.variants ??= ''; 25 | 26 | // calc suffixes 27 | let suffixes = args.variants.split(',').map(v => { 28 | v = v.trim().toLowerCase(); 29 | return v === '' ? '' : '-' + v 30 | }) 31 | 32 | // calc tags 33 | let tags = new Set(); 34 | 'versatiles,ghcr.io/versatiles-org'.split(',').forEach(org => { 35 | suffixes.forEach(suffix => { 36 | tags.add(`${org}/${args.repo}:${args.tag}${suffix}`) 37 | tags.add(`${org}/${args.repo}:latest${suffix}`) 38 | if (suffix.startsWith('-')) { 39 | tags.add(`${org}/${args.repo}:${suffix.slice(1)}`) 40 | } 41 | }) 42 | }) 43 | 44 | args.tags = Array.from(tags.values()).join(',') 45 | 46 | for (let [key, value] of Object.entries(args)) { 47 | process.stdout.write(`${key}=${value}\n`) 48 | } 49 | --------------------------------------------------------------------------------