Skip to content

Commit

Permalink
Updated geoprox usage docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrasingh committed Aug 23, 2024
1 parent 221c768 commit fa8abe7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 31 deletions.
2 changes: 1 addition & 1 deletion contrib/docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN \

USER geoprox:geoprox

WORKDIR /usr/local/bin
WORKDIR /var/lib/geoprox
COPY --from=builder --chown=geoprox:geoprox /code/target/release/geoprox /usr/local/bin/

ENTRYPOINT [ "geoprox", "run" ]
2 changes: 1 addition & 1 deletion contrib/docker/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN \

USER geoprox:geoprox

WORKDIR /usr/local/bin
WORKDIR /var/lib/geoprox
COPY --from=builder --chown=geoprox:geoprox /code/target/release/geoprox /usr/local/bin/

ENTRYPOINT [ "geoprox", "run" ]
30 changes: 22 additions & 8 deletions contrib/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,43 @@ Check the respective registry for available tags.

> For complete settings and configuration details, refer to the [Geoprox CLI README](../../geoprox/README.md#configuration).
To use a custom configuration file, simply mount your configuration file into the container at `/var/lib/geoprox`. Geoprox will automatically detect and parse configuration files in formats like `YAML`, `TOML`, `JSON`, or `INI` if they are named `geoprox.yaml`, `geoprox.toml`, `geoprox.json`, or `geoprox.ini`, respectively.
Geoprox allows specifying a configuration file using the `-c` or `--config` option or set the `GEOPROX_CONFIG` environment variable. Geoprox will automatically detect and parse configuration files in formats like `YAML`, `TOML`, `JSON`, or `INI` if they are named `geoprox.yaml`, `geoprox.toml`, `geoprox.json`, or `geoprox.ini`, respectively.

For example, if you have a configuration file named `geoprox.yaml` in your current directory, you can run the container with the following command:
For example, if you have a configuration file named `geoprox.toml` in your current directory, you can run the container with the following command:

```sh
docker run -t -p 5000:5000 \
-v $(pwd)/geoprox.yaml:/etc/geoprox/geoprox.yaml:ro \
ezrasingh/geoprox:latest
-v $(pwd)/geoprox.toml:/var/lib/geoprox/geoprox.toml:ro \
ezrasingh/geoprox:latest \
-c geoprox.toml
```

If you need to specify a different path or file name for your configuration, use the `-c` or `--config` option:

```sh
docker run -t -p 5000:5000 \
-v $(pwd)/custom-config.toml:/some/path/custom-config.toml:ro \
-v $(pwd)/custom-config.yaml:/some/path/custom-config.yaml:ro \
ezrasingh/geoprox:latest \
-c /some/path/custom-config.toml
-c /some/path/custom-config.yaml
```

In this command:

- `-v $(pwd)/custom-config.yaml:/some/path/custom-config.yaml:ro` mounts the local configuration file into the container.
- `-c /some/path/custom-config.yaml` specifies the configuration file to be used by the Geoprox server.

Or use the `GEOPROX_CONFIG` environment variable:

```sh
docker run -t -p 5000:5000 \
-v $(pwd)/custom-config.yaml:/some/path/custom-config.yaml:ro \
-e GEOPROX_CONFIG='/some/path/custom-config.yaml' \
ezrasingh/geoprox:latest
```

In this command:

- `-v $(pwd)/custom-config.toml:/some/path/custom-config.toml:ro` mounts the local configuration file into the container.
- `-c /some/path/custom-config.toml` specifies the configuration file to be used by the Geoprox server.
- `-e GEOPROX_CONFIG='/some/path/custom-config.yaml'` specifies the configuration file to be used by the Geoprox server.

## Quick Start

Expand Down
5 changes: 1 addition & 4 deletions contrib/docker/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ services:
dockerfile: contrib/docker/Dockerfile.alpine
context: ../../../

environment:
GEOPROX_CONFIG: /var/lib/geoprox/geoprox.toml
GEOPROX_HTTP_ADDR: 0.0.0.0
GEOPROX_HTTP_PORT: 5000
command: -c geoprox.toml

ports:
- 5000:5000
Expand Down
5 changes: 3 additions & 2 deletions contrib/docker/quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ services:
# Available tags can be found at https://hub.docker.com/repository/docker/ezrasingh/geoprox/tags
image: ezrasingh/geoprox:${IMAGE_TAG:-latest}
restart: on-failure:3
command: -c geoprox.toml

# This is optional, demonstrating how to specify env vars
# These are all the defaults
environment:
GEOPROX_CONFIG: /var/lib/geoprox/geoprox.toml
# either use -c flag or this env var
# GEOPROX_CONFIG: /my/custom/path/geoprox.toml
GEOPROX_HTTP_ADDR: 0.0.0.0
GEOPROX_HTTP_PORT: 5000

Expand Down
21 changes: 16 additions & 5 deletions geoprox-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ extern crate geoprox_core;
let mut geo_index = geoprox_core::SpatialIndex::default();

// ? place object keys into index
let insert_depth = 6; // insert precision (higher means objects get grouped into bigger regions)
geo_index.insert("alice", &geohash::encode([40.7129, 74.007].into(), depth).unwrap());
geo_index.insert("bob", &geohash::encode([40.7127, 74.005].into(), depth).unwrap());
geo_index.insert("alice", "s00j8n0");
geo_index.insert("bob", "s00j8n1");

// ? search index for objects near New York
let nearby: LatLngCoord = [40.7128, 74.006];
Expand Down Expand Up @@ -76,8 +75,20 @@ let mut shard = geoprox_core::GeoShard::default();
shard.create_index("drivers").unwrap();

// ? place drivers into index
shard.insert_key("drivers", "alice", [36.2049, 138.253]).unwrap();
shard.insert_key("drivers", "bob", [36.2047, 138.2528]).unwrap();
let ttl = std::time::Duration::from_secs(10);
shard.insert_key(
"drivers",
"alice",
[36.2049, 138.253],
Some(ttl)
).unwrap();

shard.insert_key(
"drivers",
"bob",
[36.2047, 138.2528],
None
).unwrap();

// ? search drivers near Japan
let nearby: LatLngCoord = [36.2048, 138.2529];
Expand Down
19 changes: 9 additions & 10 deletions geoprox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Geoprox provides several commands to start the server and work with geohashes:

```sh
geoprox help
Usage: geoprox [OPTIONS] [COMMAND]
Usage: geoprox [COMMAND]

Commands:
run Start Geoprox server
Expand All @@ -34,9 +34,8 @@ Commands:
help Print this message or the help of the given subcommand(s)

Options:
-c, --config <CONFIG> Specify a config file
-h, --help Print help
-V, --version Print version
-h, --help Print help
-V, --version Print version
```

## Getting Started
Expand Down Expand Up @@ -65,7 +64,7 @@ geoprox help encode

## Configuration

Geoprox allows specifying a configuration file using the `-c` or `--config` option or set the `GEOPROX_CONFIG` environment variable. This file can contain various settings to customize the behavior of the Geoprox server and commands. The configuration can be provided in any common format such as `YAML`, `TOML`, `JSON`, or `INI`. By default, configurations are expected to be found under `/var/lib/geoprox`.
Geoprox allows specifying a configuration file using the `-c` or `--config` option or set the `GEOPROX_CONFIG` environment variable. This file can contain various settings to customize the behavior of the Geoprox server and commands. The configuration can be provided in any common format such as `YAML`, `TOML`, `JSON`, or `INI`.

### Example Config

Expand Down Expand Up @@ -104,11 +103,11 @@ every = '30s'

These are the currently supported environment variables. They will take precedence over settings defined in the configuration file.

| Environment Variable | Description | Default Value |
| -------------------- | -------------------------------------- | --------------------------------------------------------- |
| `GEOPROX_CONFIG` | Specifies the configuration file path. | `/var/lib/geoprox/geoprox.{toml,yaml,json,ini,ron,json5}` |
| `GEOPROX_HTTP_ADDR` | The address the server will bind to. | `0.0.0.0` |
| `GEOPROX_HTTP_PORT` | The port the server will listen on. | `5000` |
| Environment Variable | Description | Default Value |
| -------------------- | -------------------------------------- | ------------- |
| `GEOPROX_CONFIG` | Specifies the configuration file path. | |
| `GEOPROX_HTTP_ADDR` | The address the server will bind to. | `0.0.0.0` |
| `GEOPROX_HTTP_PORT` | The port the server will listen on. | `5000` |

## Fine Tuning

Expand Down

0 comments on commit fa8abe7

Please sign in to comment.