From 89a5ff3c7b4795864f918470d85a1186ed593845 Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 10 Sep 2021 19:17:24 -0400 Subject: [PATCH] use host and port variables --- config/config.exs | 5 +++-- config/dev.exs | 1 - config/prod.exs | 2 -- config/releases.exs | 5 ++++- docker-compose.yml | 5 +++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/config.exs b/config/config.exs index 7596f45..19e10fb 100644 --- a/config/config.exs +++ b/config/config.exs @@ -12,13 +12,14 @@ config :cannery, # Configures the endpoint config :cannery, CanneryWeb.Endpoint, - url: [host: "localhost"], + url: [host: System.get_env("HOST") || "localhost"], + http: [port: String.to_integer(System.get_env("PORT") || "80")], secret_key_base: "KH59P0iZixX5gP/u+zkxxG8vAAj6vgt0YqnwEB5JP5K+E567SsqkCz69uWShjE7I", render_errors: [view: CanneryWeb.ErrorView, accepts: ~w(html json), layout: false], pubsub_server: Cannery.PubSub, live_view: [signing_salt: "zOLgd3lr"], registration: System.get_env("REGISTRATION") || "invite" - + config :cannery, :generators, migration: true, binary_id: true, diff --git a/config/dev.exs b/config/dev.exs index 27dcbef..c2279a9 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -14,7 +14,6 @@ config :cannery, Cannery.Repo, # watchers to your application. For example, we use it # with webpack to recompile .js and .css sources. config :cannery, CanneryWeb.Endpoint, - http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, diff --git a/config/prod.exs b/config/prod.exs index 106c953..ce7b7a3 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -10,8 +10,6 @@ import Config # which you should run after static files are built and # before starting your production server. config :cannery, CanneryWeb.Endpoint, - url: [host: "localhost"], - http: [port: 4000], cache_static_manifest: "priv/static/cache_manifest.json" config :cannery, Cannery.Repo, diff --git a/config/releases.exs b/config/releases.exs index d2d8e7d..dc6b3f2 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -20,9 +20,12 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ +host = System.get_env("HOST") || "localhost" + config :cannery, CanneryWeb.Endpoint, + url: [host: host], http: [ - port: String.to_integer(System.get_env("PORT") || "4000"), + port: String.to_integer(System.get_env("PORT") || "80"), transport_options: [socket_opts: [:inet6]] ], secret_key_base: secret_key_base, diff --git a/docker-compose.yml b/docker-compose.yml index dd4110f..6aebcae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,15 +6,16 @@ services: context: . container_name: cannery environment: + HOST: "your.domain.com" DATABASE_URL: "ecto://postgres:postgres@cannery-db/cannery" # generate a random base64 string 64 characters long, preferably not from a website SECRET_KEY_BASE: "change-me-to-something-random-this-is-really-important-change-it" - # uncomment enable sign ups, watch for spam! + # uncomment to enable sign ups, watch for spam! # REGISTRATION: "public" ports: # do not expose this publically! # always host from behind a reverse proxy with a properly configured certificate - - "4000:4000" + - "80:80" restart: always depends_on: - cannery-db