From d311888f94c43dd26693dedd20f857aa6d713105 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 23 Nov 2023 21:14:32 -0500 Subject: [PATCH] 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 --- .dockerignore | 4 +++ .../homebrew.martin.rb.j2 | 2 +- .../files/multi-platform.Dockerfile | 0 .github/workflows/ci.yml | 8 ++--- Dockerfile | 23 --------------- arm64.Dockerfile | 23 --------------- demo/.dockerignore | 29 +++++++++++++++++++ demo/.gitignore | 2 +- docker-compose.yml | 11 ------- docs/src/run-with-docker-compose.md | 3 +- justfile | 4 --- 11 files changed, 41 insertions(+), 68 deletions(-) rename .github/{templates => files}/homebrew.martin.rb.j2 (97%) rename multi-platform.Dockerfile => .github/files/multi-platform.Dockerfile (100%) delete mode 100755 Dockerfile delete mode 100644 arm64.Dockerfile create mode 100644 demo/.dockerignore diff --git a/.dockerignore b/.dockerignore index 63338737..39dc2685 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/.github/templates/homebrew.martin.rb.j2 b/.github/files/homebrew.martin.rb.j2 similarity index 97% rename from .github/templates/homebrew.martin.rb.j2 rename to .github/files/homebrew.martin.rb.j2 index 17c06f12..c8bcbd03 100644 --- a/.github/templates/homebrew.martin.rb.j2 +++ b/.github/files/homebrew.martin.rb.j2 @@ -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 diff --git a/multi-platform.Dockerfile b/.github/files/multi-platform.Dockerfile similarity index 100% rename from multi-platform.Dockerfile rename to .github/files/multi-platform.Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68213db8..efba3140 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index 035f84ab..00000000 --- a/Dockerfile +++ /dev/null @@ -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"] diff --git a/arm64.Dockerfile b/arm64.Dockerfile deleted file mode 100644 index e15c4271..00000000 --- a/arm64.Dockerfile +++ /dev/null @@ -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"] diff --git a/demo/.dockerignore b/demo/.dockerignore new file mode 100644 index 00000000..9b81a8dd --- /dev/null +++ b/demo/.dockerignore @@ -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 diff --git a/demo/.gitignore b/demo/.gitignore index f7b58452..9b81a8dd 100644 --- a/demo/.gitignore +++ b/demo/.gitignore @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 04754d29..a7a91354 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docs/src/run-with-docker-compose.md b/docs/src/run-with-docker-compose.md index 85873eae..6e5d6956 100644 --- a/docs/src/run-with-docker-compose.md +++ b/docs/src/run-with-docker-compose.md @@ -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 ``` diff --git a/justfile b/justfile index d72da2fb..19173505 100644 --- a/justfile +++ b/justfile @@ -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 }}