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 justfile
# Remove self from the image too # Remove self from the image too
.dockerignore .dockerignore
# Unneeded code
**/tests
demo/
#### This must match .gitignore #### #### This must match .gitignore ####
.DS_Store .DS_Store
target/ target/
**/*.rs.bk **/*.rs.bk
.idea/ .idea/
.vscode/
test_log* test_log*
*.profraw *.profraw

View File

@ -1,6 +1,6 @@
# #
# ATTENTION: This is an autogenerated file. See original at # 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 class Martin < Formula

View File

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

View File

@ -1,17 +1,6 @@
version: "3" version: "3"
services: 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: db-is-ready:
# This should match the version of postgres used in the CI workflow # This should match the version of postgres used in the CI workflow
image: postgis/postgis:14-3.3-alpine image: postgis/postgis:14-3.3-alpine

View File

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

View File

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