Update Docker build process (#1022)

* Fix docker file builds to use debian
* add a few more things to `.dockerignore`
* remove unused `martin` from docker-compose.yml
* delete unused arm64.Dockerfile

This should also fix #1021
This commit is contained in:
Yuri Astrakhan 2023-11-23 21:14:32 -05:00 committed by GitHub
parent e4c31384dc
commit d311888f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 41 additions and 68 deletions

View File

@ -6,12 +6,16 @@ Dockerfile
justfile
# Remove self from the image too
.dockerignore
# Unneeded code
**/tests
demo/
#### This must match .gitignore ####
.DS_Store
target/
**/*.rs.bk
.idea/
.vscode/
test_log*
*.profraw

View File

@ -1,6 +1,6 @@
#
# ATTENTION: This is an autogenerated file. See original at
# https://github.com/maplibre/martin/blob/main/.github/templates/homebrew.martin.rb.j2
# https://github.com/maplibre/martin/blob/main/.github/files/homebrew.martin.rb.j2
#
class Martin < Formula

View File

@ -170,7 +170,7 @@ jobs:
# https://github.com/docker/build-push-action
with:
context: .
file: multi-platform.Dockerfile
file: .github/files/multi-platform.Dockerfile
load: true
tags: ${{ github.repository }}:linux-arm64
platforms: linux/arm64
@ -191,7 +191,7 @@ jobs:
# https://github.com/docker/build-push-action
with:
context: .
file: multi-platform.Dockerfile
file: .github/files/multi-platform.Dockerfile
load: true
tags: ${{ github.repository }}:linux-amd64
platforms: linux/amd64
@ -227,7 +227,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: multi-platform.Dockerfile
file: .github/files/multi-platform.Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
@ -630,7 +630,7 @@ jobs:
- name: Create Homebrew formula
uses: cuchi/jinja2-action@master
with:
template: .github/templates/homebrew.martin.rb.j2
template: .github/files/homebrew.martin.rb.j2
output_file: target/homebrew/martin.rb
data_file: target/homebrew_config.yaml

View File

@ -1,23 +0,0 @@
FROM rust:alpine as builder
WORKDIR /usr/src/martin
RUN apk update \
&& apk add --no-cache musl-dev perl build-base
COPY . .
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release
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 \
/usr/src/martin/target/release/martin \
/usr/local/bin/
EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/martin"]

View File

@ -1,23 +0,0 @@
FROM rust:1.68-bullseye as builder
WORKDIR /usr/src/martin
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
perl \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release
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"]

29
demo/.dockerignore Normal file
View File

@ -0,0 +1,29 @@
#### This must match .dockerignore ####
# dependencies
frontend/node_modules
# testing
frontend/coverage
# production
frontend/build
frontend/dist
db/initdb/taxi_zones
db/initdb/taxi_trips
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
data
db/db

2
demo/.gitignore vendored
View File

@ -1,4 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
#### This must match .dockerignore ####
# dependencies
frontend/node_modules

View File

@ -1,17 +1,6 @@
version: "3"
services:
martin:
image: ghcr.io/maplibre/martin:v0.8.7
restart: unless-stopped
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgres://postgres:postgres@db/db
- RUST_LOG=actix_web=info,martin=debug,tokio_postgres=debug
depends_on:
- db
db-is-ready:
# This should match the version of postgres used in the CI workflow
image: postgis/postgis:14-3.3-alpine

View File

@ -7,7 +7,7 @@ version: '3'
services:
martin:
image: ghcr.io/maplibre/martin:v0.8.7
image: ghcr.io/maplibre/martin:v0.11.1
restart: unless-stopped
ports:
- "3000:3000"
@ -24,6 +24,7 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
volumes:
# persist PostgreSQL data in a local directory outside of the docker container
- ./pg_data:/var/lib/postgresql/data
```

View File

@ -233,10 +233,6 @@ coverage FORMAT='html': (cargo-install "grcov")
open "$OUTPUT_RESULTS_DIR/index.html"
fi
# Build martin docker image
docker-build:
docker build -t ghcr.io/maplibre/martin .
# Build and run martin docker image
docker-run *ARGS:
docker run -it --rm --net host -e DATABASE_URL -v $PWD/tests:/tests ghcr.io/maplibre/martin {{ ARGS }}