Scott Hiett commited on
Commit
d007060
·
1 Parent(s): b2ff4b5

Docker, port updates

Browse files
Files changed (5) hide show
  1. README.md +10 -4
  2. config/config.exs +3 -2
  3. config/prod.exs +3 -0
  4. config/runtime.exs +3 -2
  5. lib/srh.ex +5 -1
README.md CHANGED
@@ -20,10 +20,16 @@ You can read about it here: [Upstash Redis GitHub](https://github.com/upstash/up
20
  Soon I will add specific documentation for the endpoints so you can implement clients in other languages.
21
 
22
  ## 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`
 
 
 
 
 
 
27
 
28
  To configure Redis targets:\
29
  Create a file: `srh-config/tokens.json`
 
20
  Soon I will add specific documentation for the endpoints so you can implement clients in other languages.
21
 
22
  ## Installation
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*
33
 
34
  To configure Redis targets:\
35
  Create a file: `srh-config/tokens.json`
config/config.exs CHANGED
@@ -1,7 +1,8 @@
1
  import Config
2
 
3
  config :srh,
4
- mode: "file",
5
- file_path: "srh-config/tokens.json"
 
6
 
7
  import_config "#{config_env()}.exs"
 
1
  import Config
2
 
3
  config :srh,
4
+ mode: "file",
5
+ file_path: "srh-config/tokens.json",
6
+ port: 8080
7
 
8
  import_config "#{config_env()}.exs"
config/prod.exs CHANGED
@@ -1 +1,4 @@
1
  import Config
 
 
 
 
1
  import Config
2
+
3
+ config :srh,
4
+ port: 80
config/runtime.exs CHANGED
@@ -1,5 +1,6 @@
1
  import Config
2
 
3
  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"
 
 
1
  import Config
2
 
3
  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",
6
+ port: Integer.parse(System.get_env("PORT") || "8080")
lib/srh.ex CHANGED
@@ -1,7 +1,11 @@
1
  defmodule Srh do
2
  use Application
3
 
 
 
4
  def start(_type, _args) do
 
 
5
  children = [
6
  Srh.Auth.TokenResolver,
7
  {GenRegistry, worker_module: Srh.Redis.Client},
@@ -10,7 +14,7 @@ defmodule Srh do
10
  scheme: :http,
11
  plug: Srh.Http.BaseRouter,
12
  options: [
13
- port: 8080
14
  ]
15
  }
16
  ]
 
1
  defmodule Srh do
2
  use Application
3
 
4
+ @port Application.fetch_env!(:srh, :port)
5
+
6
  def start(_type, _args) do
7
+ IO.puts("Using port #{@port}")
8
+
9
  children = [
10
  Srh.Auth.TokenResolver,
11
  {GenRegistry, worker_module: Srh.Redis.Client},
 
14
  scheme: :http,
15
  plug: Srh.Http.BaseRouter,
16
  options: [
17
+ port: @port
18
  ]
19
  }
20
  ]