mirror of
https://github.com/maplibre/martin.git
synced 2024-12-18 20:31:54 +03:00
Cleanup docker and related docs (#752)
* Use same docker image for postgis & psql * Improve docker book * rename just target `mdbook` to `book` (more obvious choice) * Cleanup justfile to not duplicate "cargo install" check & installation
This commit is contained in:
parent
2829212c6a
commit
ed7d33a76d
@ -14,7 +14,7 @@ services:
|
|||||||
|
|
||||||
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
|
image: postgis/postgis:14-3.3-alpine
|
||||||
network_mode: host
|
network_mode: host
|
||||||
command:
|
command:
|
||||||
- "sh"
|
- "sh"
|
||||||
|
@ -48,7 +48,7 @@ Available recipes:
|
|||||||
test-unit *ARGS # Run Rust unit and doc tests (cargo test)
|
test-unit *ARGS # Run Rust unit and doc tests (cargo test)
|
||||||
test-int # Run integration tests
|
test-int # Run integration tests
|
||||||
bless # Run integration tests and save its output as the new expected output
|
bless # Run integration tests and save its output as the new expected output
|
||||||
mdbook # Build and open mdbook documentation
|
book # Build and open mdbook documentation
|
||||||
docs # Build and open code documentation
|
docs # Build and open code documentation
|
||||||
coverage FORMAT='html' # Run code coverage on tests and save its output in the coverage directory. Parameter could be html or lcov.
|
coverage FORMAT='html' # Run code coverage on tests and save its output in the coverage directory. Parameter could be html or lcov.
|
||||||
docker-build # Build martin docker image
|
docker-build # Build martin docker image
|
||||||
@ -57,6 +57,7 @@ Available recipes:
|
|||||||
print-conn-str # Print the connection string for the test database
|
print-conn-str # Print the connection string for the test database
|
||||||
lint # Run cargo fmt and cargo clippy
|
lint # Run cargo fmt and cargo clippy
|
||||||
fmt # Run cargo fmt
|
fmt # Run cargo fmt
|
||||||
|
fmt2 # Run Nightly cargo fmt, ordering imports
|
||||||
clippy # Run cargo clippy
|
clippy # Run cargo clippy
|
||||||
prepare-sqlite # Update sqlite database schema. Install SQLX cli if not already installed.
|
prepare-sqlite # Update sqlite database schema.
|
||||||
```
|
```
|
||||||
|
@ -2,25 +2,40 @@
|
|||||||
|
|
||||||
You can use official Docker image [`ghcr.io/maplibre/martin`](https://ghcr.io/maplibre/martin)
|
You can use official Docker image [`ghcr.io/maplibre/martin`](https://ghcr.io/maplibre/martin)
|
||||||
|
|
||||||
|
### Using Non-Local PostgreSQL
|
||||||
```shell
|
```shell
|
||||||
docker run \
|
docker run \
|
||||||
-p 3000:3000 \
|
-p 3000:3000 \
|
||||||
-e DATABASE_URL=postgresql://postgres@localhost/db \
|
-e DATABASE_URL=postgresql://postgres@postgres.example.com/db \
|
||||||
ghcr.io/maplibre/martin
|
ghcr.io/maplibre/martin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Exposing Local Files
|
||||||
|
|
||||||
|
You can expose local files to the Docker container using the `-v` flag.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run \
|
||||||
|
-p 3000:3000 \
|
||||||
|
-v /path/to/local/files:/files \
|
||||||
|
ghcr.io/maplibre/martin /files
|
||||||
|
```
|
||||||
|
|
||||||
|
### Accessing Local PostgreSQL on Linux
|
||||||
|
|
||||||
If you are running PostgreSQL instance on `localhost`, you have to change network settings to allow the Docker container to access the `localhost` network.
|
If you are running PostgreSQL instance on `localhost`, you have to change network settings to allow the Docker container to access the `localhost` network.
|
||||||
|
|
||||||
For Linux, add the `--net=host` flag to access the `localhost` PostgreSQL service.
|
For Linux, add the `--net=host` flag to access the `localhost` PostgreSQL service. You would not need to export ports with `-p` because the container is already using the host network.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run \
|
docker run \
|
||||||
--net=host \
|
--net=host \
|
||||||
-p 3000:3000 \
|
|
||||||
-e DATABASE_URL=postgresql://postgres@localhost/db \
|
-e DATABASE_URL=postgresql://postgres@localhost/db \
|
||||||
ghcr.io/maplibre/martin
|
ghcr.io/maplibre/martin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Accessing Local PostgreSQL on macOS
|
||||||
|
|
||||||
For macOS, use `host.docker.internal` as hostname to access the `localhost` PostgreSQL service.
|
For macOS, use `host.docker.internal` as hostname to access the `localhost` PostgreSQL service.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@ -30,6 +45,8 @@ docker run \
|
|||||||
ghcr.io/maplibre/martin
|
ghcr.io/maplibre/martin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Accessing Local PostgreSQL on Windows
|
||||||
|
|
||||||
For Windows, use `docker.for.win.localhost` as hostname to access the `localhost` PostgreSQL service.
|
For Windows, use `docker.for.win.localhost` as hostname to access the `localhost` PostgreSQL service.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
30
justfile
30
justfile
@ -65,12 +65,8 @@ bench: start
|
|||||||
cargo bench
|
cargo bench
|
||||||
|
|
||||||
# Run HTTP requests benchmark using OHA tool. Use with `just run-release`
|
# Run HTTP requests benchmark using OHA tool. Use with `just run-release`
|
||||||
bench-http:
|
bench-http: (cargo-install "oha")
|
||||||
@echo "Make sure Martin was started with 'just run-release'"
|
@echo "Make sure Martin was started with 'just run-release'"
|
||||||
@if ! command -v oha &> /dev/null; then \
|
|
||||||
echo "oha could not be found. Installing..." ;\
|
|
||||||
cargo install oha ;\
|
|
||||||
fi
|
|
||||||
@echo "Warming up..."
|
@echo "Warming up..."
|
||||||
oha -z 5s --no-tui http://localhost:3000/function_zxy_query/18/235085/122323 > /dev/null
|
oha -z 5s --no-tui http://localhost:3000/function_zxy_query/18/235085/122323 > /dev/null
|
||||||
oha -z 120s http://localhost:3000/function_zxy_query/18/235085/122323
|
oha -z 120s http://localhost:3000/function_zxy_query/18/235085/122323
|
||||||
@ -111,11 +107,7 @@ bless: start clean-test
|
|||||||
mv tests/output tests/expected
|
mv tests/output tests/expected
|
||||||
|
|
||||||
# Build and open mdbook documentation
|
# Build and open mdbook documentation
|
||||||
mdbook:
|
book: (cargo-install "mdbook")
|
||||||
@if ! command -v mdbook &> /dev/null; then \
|
|
||||||
echo "mdbook could not be found. Installing..." ;\
|
|
||||||
cargo install mdbook ;\
|
|
||||||
fi
|
|
||||||
mdbook serve docs --open --port 8321
|
mdbook serve docs --open --port 8321
|
||||||
|
|
||||||
# Build and open code documentation
|
# Build and open code documentation
|
||||||
@ -123,13 +115,9 @@ docs:
|
|||||||
cargo doc --no-deps --open
|
cargo doc --no-deps --open
|
||||||
|
|
||||||
# Run code coverage on tests and save its output in the coverage directory. Parameter could be html or lcov.
|
# Run code coverage on tests and save its output in the coverage directory. Parameter could be html or lcov.
|
||||||
coverage FORMAT='html':
|
coverage FORMAT='html': (cargo-install "grcov")
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if ! command -v grcov &> /dev/null; then \
|
|
||||||
echo "grcov could not be found. Installing..." ;\
|
|
||||||
cargo install grcov ;\
|
|
||||||
fi
|
|
||||||
if ! rustup component list | grep llvm-tools-preview &> /dev/null; then \
|
if ! rustup component list | grep llvm-tools-preview &> /dev/null; then \
|
||||||
echo "llvm-tools-preview could not be found. Installing..." ;\
|
echo "llvm-tools-preview could not be found. Installing..." ;\
|
||||||
rustup component add llvm-tools-preview ;\
|
rustup component add llvm-tools-preview ;\
|
||||||
@ -219,8 +207,12 @@ prepare-sqlite: install-sqlx
|
|||||||
|
|
||||||
# Install SQLX cli if not already installed.
|
# Install SQLX cli if not already installed.
|
||||||
[private]
|
[private]
|
||||||
install-sqlx:
|
install-sqlx: (cargo-install "cargo-sqlx" "sqlx-cli" "--no-default-features" "--features" "sqlite,native-tls")
|
||||||
@if ! command -v cargo-sqlx &> /dev/null; then \
|
|
||||||
echo "SQLX cargo plugin could not be found. Installing..." ;\
|
# Check if a certain Cargo command is installed, and install it if needed
|
||||||
cargo install sqlx-cli --no-default-features --features sqlite,native-tls ;\
|
[private]
|
||||||
|
cargo-install $COMMAND $INSTALL_CMD="" *ARGS="":
|
||||||
|
@if ! command -v $COMMAND &> /dev/null; then \
|
||||||
|
echo "$COMMAND could not be found. Installing it with cargo install ${INSTALL_CMD:-$COMMAND} {{ ARGS }}" ;\
|
||||||
|
cargo install ${INSTALL_CMD:-$COMMAND} {{ ARGS }} ;\
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user