Skip to content

Commit d007060

Browse files
committed
Docker, port updates
1 parent b2ff4b5 commit d007060

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ You can read about it here: [Upstash Redis GitHub](https://github.com/upstash/up
2020
Soon I will add specific documentation for the endpoints so you can implement clients in other languages.
2121

2222
## Installation
23-
Soon, I will provide a Docker container for this. Right now, you need Elixir 1.13+ installed. Clone down the repo, then run:
24-
`mix deps.get`
25-
then
26-
`iex -S mix`
23+
You have to options to run this:
24+
- Via docker: `docker pull hiett/serverless-redis-http:latest`
25+
- Via elixir: `(clone this repo)` -> `mix deps.get` -> `iex -S mix`
26+
27+
If you are running via Docker, you will need to mount the configuration file to `/app/srh-config/tokens.json`.\
28+
An example of a run command is the following:
29+
30+
`docker run -it -d -p 8080:80 --name srh --mount type=bind,source=$(pwd)/srh-config/tokens.json,target=/app/srh-config/tokens.json hiett/serverless-redis-http:latest`
31+
32+
*Note that it is running on port 80*
2733

2834
To configure Redis targets:\
2935
Create a file: `srh-config/tokens.json`

config/config.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Config
22

33
config :srh,
4-
mode: "file",
5-
file_path: "srh-config/tokens.json"
4+
mode: "file",
5+
file_path: "srh-config/tokens.json",
6+
port: 8080
67

78
import_config "#{config_env()}.exs"

config/prod.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
import Config
2+
3+
config :srh,
4+
port: 80

config/runtime.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Config
22

33
config :srh,
4-
mode: System.get_env("TOKEN_RESOLUTION_MODE") || "file",
5-
file_path: System.get_env("TOKEN_RESOLUTION_FILE_PATH") || "srh-config/tokens.json"
4+
mode: System.get_env("TOKEN_RESOLUTION_MODE") || "file",
5+
file_path: System.get_env("TOKEN_RESOLUTION_FILE_PATH") || "srh-config/tokens.json",
6+
port: Integer.parse(System.get_env("PORT") || "8080")

lib/srh.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
defmodule Srh do
22
use Application
33

4+
@port Application.fetch_env!(:srh, :port)
5+
46
def start(_type, _args) do
7+
IO.puts("Using port #{@port}")
8+
59
children = [
610
Srh.Auth.TokenResolver,
711
{GenRegistry, worker_module: Srh.Redis.Client},
@@ -10,7 +14,7 @@ defmodule Srh do
1014
scheme: :http,
1115
plug: Srh.Http.BaseRouter,
1216
options: [
13-
port: 8080
17+
port: @port
1418
]
1519
}
1620
]

0 commit comments

Comments
 (0)