Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge amd64 and arm64 docker images #625

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ on:
jobs:
docker:
# Don't change this name - it is used by the merge protection rules
name: Build ${{ matrix.platform }} docker image
strategy:
fail-fast: true
matrix:
include:
- platform: linux/amd64
file: Dockerfile
- platform: linux/arm64
file: arm64.Dockerfile
name: Build and test docker image
runs-on: ubuntu-latest
steps:

Expand All @@ -47,22 +39,20 @@ jobs:
uses: docker/[email protected]
with:
install: true
platforms: ${{ matrix.platform }}
platforms: linux/arm64,linux/amd64

- 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 }}
platforms: ${{ matrix.platform }}
platforms: linux/arm64,linux/amd64

- name: Start postgres
# arm64 cannot be tested just yet
if: matrix.platform == 'linux/amd64'
uses: nyurik/action-setup-postgis@v1
id: pg
with:
Expand All @@ -73,15 +63,13 @@ jobs:

- 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=-
Expand All @@ -103,9 +91,8 @@ jobs:
if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' }}
uses: docker/build-push-action@v4
with:
file: ${{ matrix.file }}
push: true
load: false
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: ${{ matrix.platform }}
platforms: linux/arm64,linux/amd64
26 changes: 22 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
FROM rust:alpine as builder
# syntax=docker/dockerfile:1

# This dockerfile must be ran with docker buildx build

ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=$BUILDPLATFORM rust:alpine as builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM

WORKDIR /usr/src/martin

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

RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
echo "Building on '$BUILDPLATFORM' for ARM64"; \
export CFLAGS=-mno-outline-atomics; \
else \
echo "Building on '$BUILDPLATFORM' for unrecognized target platform '$TARGETPLATFORM'"; \
fi \
&& export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \
&& env | sort | tee /build_log \
&& cargo build --release --features=vendored-openssl

FROM alpine:latest

LABEL org.opencontainers.image.description="Blazing fast and lightweight tile server with PostGIS, MBTiles, and PMTiles support"

RUN apk add --no-cache libc6-compat
COPY --from=builder /build_log /build_log
RUN env | sort | tee /build_log2 \
&& apk add --no-cache libc6-compat

COPY --from=builder \
/usr/src/martin/target/release/martin \
Expand Down
24 changes: 0 additions & 24 deletions arm64.Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ coverage FORMAT='html':
open "$OUTPUT_RESULTS_DIR/index.html"
fi

# Build martin docker image
# Build martin docker image (amd64)
docker-build:
docker build -t ghcr.io/maplibre/martin .
docker build --build-arg BUILDPLATFORM=linux/amd64 -t ghcr.io/maplibre/martin .

# Build and run martin docker image
docker-run *ARGS:
Expand Down