feat/add arm64 docker support (#613)

This PR adds the Dockerfile to make `linux/arm64` and `darwin/arm64`
builds easier/possible.

closes #603
closes #505

---------

Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com>
Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
This commit is contained in:
Ismayil Mirzali 2023-03-28 09:28:55 +03:00 committed by GitHub
parent c4d4fdc62a
commit c358ec53af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 9 deletions

View File

@ -12,7 +12,15 @@ on:
jobs:
docker:
# Don't change this name - it is used by the merge protection rules
name: Build and test docker image
name: Build ${{ matrix.platform }} docker image
strategy:
fail-fast: true
matrix:
include:
- platform: linux/amd64
file: Dockerfile
- platform: linux/arm64
file: arm64.Dockerfile
runs-on: ubuntu-latest
steps:
@ -28,26 +36,29 @@ jobs:
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v2.1.0
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v2.5.0
with:
install: true
platforms: ${{ matrix.platform }}
- name: Build the Docker image
id: docker_build
uses: docker/build-push-action@v4
with:
file: ${{ matrix.file }}
push: false
load: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
# TODO: enable for multi-platform build
# platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.platform }}
- name: Start postgres
# arm64 cannot be tested just yet
if: matrix.platform == 'linux/amd64'
uses: nyurik/action-setup-postgis@v1
id: pg
with:
@ -57,12 +68,16 @@ jobs:
rights: --superuser
- name: Init database
# arm64 cannot be tested just yet
if: matrix.platform == 'linux/amd64'
shell: bash
run: tests/fixtures/initdb.sh
env:
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
- name: Test Docker image
# arm64 cannot be tested just yet
if: matrix.platform == 'linux/amd64'
run: |
TAG=$(echo '${{ steps.docker_meta.outputs.json }}' | jq -r '.tags[0]')
export MARTIN_BUILD=-

View File

@ -1,10 +1,11 @@
FROM rust:alpine as builder
RUN apk update
RUN apk add --no-cache openssl-dev musl-dev perl build-base
WORKDIR /usr/src/martin
ADD . .
RUN apk update \
&& apk add --no-cache openssl-dev musl-dev perl build-base
COPY . .
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release --features=vendored-openssl

24
arm64.Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM rust:1.68-bullseye as builder
WORKDIR /usr/src/martin
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libssl-dev \
perl \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release --features=vendored-openssl
FROM debian:bullseye-slim
LABEL org.opencontainers.image.description="Blazing fast and lightweight tile server with PostGIS, MBTiles, and PMTiles support"
COPY --from=builder \
/usr/src/martin/target/release/martin \
/usr/local/bin/
EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/martin"]