Skip to content

Commit

Permalink
The release now works under local testing #94
Browse files Browse the repository at this point in the history
  • Loading branch information
x-ji committed Oct 12, 2020
1 parent 78392c1 commit efcd17a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
23 changes: 10 additions & 13 deletions config/runtime.exs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import Config

config :magpie, Magpie.Endpoint,
http: [port: System.fetch_env!("PORT") |> String.to_integer()],
http: [port: System.get_env("PORT", "443") |> String.to_integer()],
url: [
scheme: System.fetch_env!("URL_SCHEME"),
scheme: System.get_env("URL_SCHEME", "https"),
host: System.fetch_env!("HOST"),
path: System.fetch_env!("PATH"),
port: System.fetch_env!("PORT") |> String.to_integer()
path: System.get_env("MAGPIE_PATH", "/"),
port: System.get_env("PORT", "443") |> String.to_integer()
],
# Don't use force_ssl if the URL_SCHEME is http
force_ssl:
(if System.fetch_env!("URL_SCHEME") == "https" do
[rewrite_on: [:x_forwarded_proto]]
else
(if System.get_env("URL_SCHEME") == "http" do
[]
else
[rewrite_on: [:x_forwarded_proto]]
end),
server: true,
# Allow clients from anywhere to connect to use the interactive experiment facilities. We can't constrain where the user chooses to host the frontend anyways.
Expand All @@ -30,12 +31,8 @@ config :magpie, Magpie.Endpoint,
# Configure the database
config :magpie, Magpie.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.fetch_env!("DATABASE_USERNAME"),
password: System.fetch_env!("DATABASE_PASSWORD"),
hostname: System.fetch_env!("DATABASE_HOST"),
database: System.fetch_env!("DATABASE_NAME"),
url: System.fetch_env!("DATABASE_URL"),
pool_size: String.to_integer(System.get_env("POOL_SIZE", "2")),
ssl: true,
log:
(if System.get_env("USE_TIMBER") == "true" do
false
Expand Down Expand Up @@ -70,5 +67,5 @@ config :timber,
api_key: System.get_env("TIMBER_API_KEY"),
source_id: System.get_env("TIMBER_SOURCE_ID")

# This is useful when the app is behind a reverse proxy and you need to actually use the URL shown to the outside by the reverse proxy, e.g. in template generation in web/templates/experiments/edit.html..ex
# This is useful when the app is behind a reverse proxy and you need to actually use the URL shown to the outside by the reverse proxy, e.g. in template generation in web/templates/experiments/edit.html.eex
config :magpie, :real_url, System.get_env("REAL_URL", System.fetch_env!("HOST"))
21 changes: 21 additions & 0 deletions deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Deploying magpie-backend

magpie-backend is now deployed using Elixir's native release mechanism and requires at least Elixir v1.11 to run. When running the app, the following environment variables need to be provided:

Mandatory:
- `HOST`: The URL of the host the app is supposed to run on, e.g. "www.example.com"
- `SECRET_KEY_BASE`: A random secret for the Phoenix app. A random one be generated with `phx.gen.secret`
- `DATABASE_URL`: The URL to the production database. If you use Heroku, this environment variable will be automatically generated
- `AUTH_USERNAME`: The auth username to access the system
- `AUTH_PASSWORD`: The auth password to access the system

Optional:
- `PORT`: The port at which the app is available. By default 443
- `MAGPIE_PATH`: The path of the app at the host. By default `/`. Useful for when deploying the app in a multi-tenant way.
- `URL_SCHEME`: Whether the app is run on `https` or `http`. By default `https`
- `USE_TIMBER`: Whether to use Timber as a logging backend
- `MAGPIE_NO_BASIC_AUTH`: Whether to allow accessing the app without basic name (i.e. username + pw)
Note: Even with this variable set to `true`, the `AUTH_USERNAME` and `AUTH_PASSWORD` environment variables are still needed to start the app.
- `TIMBER_API_KEY`: The API key for Timber
- `TIMBER_SOURCE_ID`: The source ID for Timber
- `REAL_URL`: Useful when the app is behind a reverse proxy and you need to actually use the URL shown to the outside by the reverse proxy, e.g. in template generation in web/templates/experiments/edit.html.eex

0 comments on commit efcd17a

Please sign in to comment.