Skip to content

Commit

Permalink
update readme with docker instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tnn4 committed May 8, 2023
1 parent 0357a49 commit dcc2725
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,51 @@ Directory | Description
|poke-rs-api | source code for rust backend

# Quick Start
1. Download the release

1. Download the release [here]()
2. Download the source, go to the root of the project
3. drop the binary into the `bin` folder
4. Run it with: `$ ./bin/poke-rs-api`
- If you want to use a different port `$./bin/poke-rs-api --port <your-port>`


The server should be listening on localhost:3001.

## Serving the API over the Internet

The server listens on `localhost:<port>` and serves JSON for the request at its endpoint at `http://localhost:<port>/pokeapi/v2/<endpoint>/<id>` so this has to be combined with a reverse proxy like [Nginx](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/), or [Apache proxy server](https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html) to forward requests to localhost and serve data over the internet securely.
The server should be listening on `http://localhost:3001` on local mode and `http://0.0.0.0:3001` on docker mode.

The default port is `3001` but can be changed with an argument when running the server.

e.g.
```bash
$ bin/poke-rs-api --port <your-port>
```

## With docker


Manually:

Build image:
- `docker build -t poke-rs-api -f Dockerfile-main .`
Run container from image:
- `docker run --name my_container_name -p 3001:3001 poke-rs-api`
Delete image:
- `docker rm my_container_name`

Or use the script - `./docker-build.sh`

- If you want to change the port in docker: change the line at `CMD` in the `Dockerfile-main` to something like:

`Dockerfile-main`
```dockerfile
CMD ["bin/poke-rs-api","--docker", "--port", "<your-port>"]
```

## Serving the API over the Internet

The server listens on `localhost:<port>` and serves JSON for the request at its endpoint at `http://localhost:<port>/pokeapi/v2/<endpoint>/<id>` so this has to be combined with a reverse proxy like [Nginx](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/), or [Apache proxy server](https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html) to forward requests to localhost and serve data over the internet securely.
- [nginx example configuration](#nginx-example)



# Development
---

Expand Down Expand Up @@ -139,6 +167,7 @@ pokemon | pokemon information | http://localhost/pokeapi/v2/pokemon/1 | yes
---


### Nginx example

Nginx example conf in `/etc/nginx/nginx.conf`:

Expand Down

0 comments on commit dcc2725

Please sign in to comment.