From c358ec53af3ef6e239093d69c8a7790f6eb1f68e Mon Sep 17 00:00:00 2001 From: Ismayil Mirzali Date: Tue, 28 Mar 2023 09:28:55 +0300 Subject: [PATCH] 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 Co-authored-by: Yuri Astrakhan --- .github/workflows/docker.yml | 25 ++++++++++++++++++++----- Dockerfile | 9 +++++---- arm64.Dockerfile | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 arm64.Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1ce0849a..b68684a5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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=- diff --git a/Dockerfile b/Dockerfile index e817a0b8..71ffdf5e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/arm64.Dockerfile b/arm64.Dockerfile new file mode 100644 index 00000000..4912078d --- /dev/null +++ b/arm64.Dockerfile @@ -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"]