Skip to content

Commit

Permalink
Makefile and release
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmonjo committed Oct 5, 2017
1 parent 96d71f8 commit b314ba5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Makefile
@@ -0,0 +1,3 @@
release:
cd apps/blockchain_web && MIX_ENV=prod mix phx.digest
MIX_ENV=prod mix release --env=prod
7 changes: 4 additions & 3 deletions apps/blockchain_web/config/prod.exs
Expand Up @@ -14,9 +14,10 @@ use Mix.Config
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :blockchain_web, Blockchain.Web.Endpoint,
on_init: {Blockchain.Web.Endpoint, :load_from_system_env, []},
url: [host: "example.com", port: String.to_integer(System.get_env("PORT") || "80")],
cache_static_manifest: "priv/static/cache_manifest.json"
load_from_system_env: true,
url: [host: "localhost", port: String.to_integer(System.get_env("PORT") || "4000")],
cache_static_manifest: "priv/static/cache_manifest.json",
server: true

# ## SSL Support
#
Expand Down
10 changes: 7 additions & 3 deletions apps/blockchain_web/lib/blockchain_web/endpoint.ex
Expand Up @@ -47,8 +47,12 @@ defmodule Blockchain.Web.Endpoint do
It receives the endpoint configuration from the config files
and must return the updated configuration.
"""
def load_from_system_env(config) do
port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
def init(_key, config) do
if config[:load_from_system_env] do
port = System.get_env("PORT") || 4000
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
else
{:ok, config}
end
end
end
56 changes: 56 additions & 0 deletions rel/config.exs
@@ -0,0 +1,56 @@
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
# This sets the default release built by `mix release`
default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
# If you are running Phoenix, you should make sure that
# server: true is set and the code reloader is disabled,
# even in dev mode.
# It is recommended that you build with MIX_ENV=prod and pass
# the --env flag to Distillery explicitly if you want to use
# dev mode.
set dev_mode: true
set include_erts: false
set cookie: :"ZtuW<2IogOJ?ErLgyq(cka;,1WN<^o(0Qb/xXdR}>]VT:D(8j>yE~(Cvm&)9(pU?"
end

environment :prod do
set include_erts: true
set include_src: false
set cookie: :"xEFajKzg[~b/*!j7ryB1&;nZ<6*Bcjgg{FU([du!`}wK?]]XB=tSX3x,A::GEft="
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :coincoin do
set version: "0.1.0"
set applications: [
:runtime_tools,
blockchain: :permanent,
blockchain_web: :permanent,
token: :permanent
]
end

0 comments on commit b314ba5

Please sign in to comment.