move configurations in to phoenix.org
parent
1813072429
commit
fe4a8c83fc
|
@ -21,3 +21,5 @@ lipu_kasi-*.tar
|
|||
/mix.exs
|
||||
# /mix.lock is checked in.
|
||||
.formatter.exs
|
||||
/config/*.exs
|
||||
!/config/prod.secret.exs
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# This file is responsible for configuring your application
|
||||
# and its dependencies with the aid of the Mix.Config module.
|
||||
#
|
||||
# This configuration file is loaded before any dependency and
|
||||
# is restricted to this project.
|
||||
|
||||
# General application configuration
|
||||
use Mix.Config
|
||||
|
||||
config :lipu_kasi,
|
||||
ecto_repos: [LipuKasi.Repo]
|
||||
|
||||
# Configures the endpoint
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
secret_key_base: "qjGyFdguDBSm8O7R4TI5M084mtgZ2vPE5p7a/2kTMuDCaPRUz9JiFdLK1RNUBggy",
|
||||
render_errors: [view: LipuKasiWeb.ErrorView, accepts: ~w(html json)],
|
||||
pubsub: [name: LipuKasi.PubSub, adapter: Phoenix.PubSub.PG2]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{Mix.env()}.exs"
|
|
@ -1,76 +0,0 @@
|
|||
use Mix.Config
|
||||
|
||||
# Configure your database
|
||||
config :lipu_kasi, LipuKasi.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "lipu_kasi_dev",
|
||||
hostname: "localhost",
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10
|
||||
|
||||
# For development, we disable any cache and enable
|
||||
# debugging and code reloading.
|
||||
#
|
||||
# The watchers configuration can be used to run external
|
||||
# watchers to your application. For example, we use it
|
||||
# with webpack to recompile .js and .css sources.
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
http: [port: 4000],
|
||||
debug_errors: true,
|
||||
code_reloader: true,
|
||||
check_origin: false,
|
||||
watchers: [
|
||||
node: [
|
||||
"node_modules/webpack/bin/webpack.js",
|
||||
"--mode",
|
||||
"development",
|
||||
"--watch-stdin",
|
||||
cd: Path.expand("../assets", __DIR__)
|
||||
]
|
||||
]
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# In order to use HTTPS in development, a self-signed
|
||||
# certificate can be generated by running the following
|
||||
# Mix task:
|
||||
#
|
||||
# mix phx.gen.cert
|
||||
#
|
||||
# Note that this task requires Erlang/OTP 20 or later.
|
||||
# Run `mix help phx.gen.cert` for more information.
|
||||
#
|
||||
# The `http:` config above can be replaced with:
|
||||
#
|
||||
# https: [
|
||||
# port: 4001,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: "priv/cert/selfsigned_key.pem",
|
||||
# certfile: "priv/cert/selfsigned.pem"
|
||||
# ],
|
||||
#
|
||||
# If desired, both `http:` and `https:` keys can be
|
||||
# configured to run both http and https servers on
|
||||
# different ports.
|
||||
|
||||
# Watch static and templates for browser reloading.
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||
~r"priv/gettext/.*(po)$",
|
||||
~r"lib/lipu_kasi_web/{live,views}/.*(ex)$",
|
||||
~r"lib/lipu_kasi_web/templates/.*(eex)$"
|
||||
]
|
||||
]
|
||||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
config :logger, :console, format: "[$level] $message\n"
|
||||
|
||||
# Set a higher stacktrace during development. Avoid configuring such
|
||||
# in production as building large stacktraces may be expensive.
|
||||
config :phoenix, :stacktrace_depth, 20
|
||||
|
||||
# Initialize plugs at runtime for faster development compilation
|
||||
config :phoenix, :plug_init_mode, :runtime
|
|
@ -1,55 +0,0 @@
|
|||
use Mix.Config
|
||||
|
||||
# For production, don't forget to configure the url host
|
||||
# to something meaningful, Phoenix uses this information
|
||||
# when generating URLs.
|
||||
#
|
||||
# Note we also include the path to a cache manifest
|
||||
# containing the digested version of static files. This
|
||||
# manifest is generated by the `mix phx.digest` task,
|
||||
# which you should run after static files are built and
|
||||
# before starting your production server.
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
url: [host: "example.com", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Do not print debug messages in production
|
||||
config :logger, level: :info
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
# to the previous section and set your `:url` port to 443:
|
||||
#
|
||||
# config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
# ...
|
||||
# url: [host: "example.com", port: 443],
|
||||
# https: [
|
||||
# :inet6,
|
||||
# port: 443,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
|
||||
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
|
||||
# ]
|
||||
#
|
||||
# The `cipher_suite` is set to `:strong` to support only the
|
||||
# latest and more secure SSL ciphers. This means old browsers
|
||||
# and clients may not be supported. You can set it to
|
||||
# `:compatible` for wider support.
|
||||
#
|
||||
# `:keyfile` and `:certfile` expect an absolute path to the key
|
||||
# and cert in disk or a relative path inside priv, for example
|
||||
# "priv/ssl/server.key". For all supported SSL configuration
|
||||
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
|
||||
#
|
||||
# We also recommend setting `force_ssl` in your endpoint, ensuring
|
||||
# no data is ever sent via http, always redirecting to https:
|
||||
#
|
||||
# config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
# force_ssl: [hsts: true]
|
||||
#
|
||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||
|
||||
# Finally import the config/prod.secret.exs which loads secrets
|
||||
# and configuration from environment variables.
|
||||
import_config "prod.secret.exs"
|
|
@ -1,18 +0,0 @@
|
|||
use Mix.Config
|
||||
|
||||
# Configure your database
|
||||
config :lipu_kasi, LipuKasi.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "lipu_kasi_test",
|
||||
hostname: "localhost",
|
||||
pool: Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
http: [port: 4002],
|
||||
server: false
|
||||
|
||||
# Print only warnings and errors during test
|
||||
config :logger, level: :warn
|
174
phoenix.org
174
phoenix.org
|
@ -1,4 +1,4 @@
|
|||
#+TITLE: An Auto-generated Phoenix Application for Lipu Kasi
|
||||
#+TITLE: Project Configuration, Mix, etc
|
||||
|
||||
In here I de-tangle the Phoenix and Mix infrastructure for [[file:../lipu_kasi.org][§Lipu Kasi]]. In general, when I work in a code module it should get moved in to its own file, but I don't know how to address that for these "infrastructure" elements. For now they'll live here. I also need to design some build systems and build scripts, and set up my =.gitignore=
|
||||
|
||||
|
@ -10,7 +10,7 @@ The repo will contain docs and assets and a build script that will call up an [[
|
|||
|
||||
This starts with a .gitignore, =phx.new= provides one that I will expand.
|
||||
|
||||
#+begin_src conf :tangle .gitignore :noweb yes
|
||||
#+begin_src conf :tangle .gitignore
|
||||
# elixir and mix outputs
|
||||
/_build/
|
||||
/cover/
|
||||
|
@ -30,16 +30,16 @@ lipu_kasi-*.tar
|
|||
# The directory NPM downloads your dependencies sources to.
|
||||
/assets/node_modules/
|
||||
/priv/static/
|
||||
|
||||
<<tangled-files>>
|
||||
#+end_src
|
||||
|
||||
Files which are provided from tangles will need to be managed here:
|
||||
|
||||
#+begin_src conf :noweb-ref tangled-files
|
||||
#+begin_src conf :tangle .gitignore
|
||||
/mix.exs
|
||||
# /mix.lock is checked in.
|
||||
.formatter.exs
|
||||
/config/*.exs
|
||||
!/config/prod.secret.exs
|
||||
#+end_src
|
||||
|
||||
This file should be checked in when it's changed, along with =mix.lock=
|
||||
|
@ -127,7 +127,7 @@ In =:test= environment
|
|||
defp elixirc_paths(_), do: ["lib"]
|
||||
#+end_src
|
||||
|
||||
* Formatters
|
||||
* Elixir Formatter Configurations
|
||||
|
||||
There are two =.formatter.exs= files, one in the project root, and one stored with the migrations. I'm not sure if this will be used by the org-babel programming, but I'll provide them for now so that I can =git clean=
|
||||
|
||||
|
@ -139,9 +139,171 @@ There are two =.formatter.exs= files, one in the project root, and one stored wi
|
|||
]
|
||||
#+end_src
|
||||
|
||||
This one is in =priv/repo/migrations/=
|
||||
|
||||
#+begin_src elixir :tangle priv/repo/migrations/.formatter.exs
|
||||
[
|
||||
import_deps: [:ecto_sql],
|
||||
inputs: ["*.exs"]
|
||||
]
|
||||
#+end_src
|
||||
|
||||
* Runtime Configurations
|
||||
|
||||
This is *not* noweb-tangled since it's not wrapped in a =defmodule=, just tangled line-by-line and concatenated.
|
||||
|
||||
This file is responsible for configuring your application and its dependencies with the aid of the Mix.Config module:
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
use Mix.Config
|
||||
#+end_src
|
||||
|
||||
We've just got the one Ecto repo, it might be all we need. I don't expect this application to have a lot of weight to it.
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
config :lipu_kasi,
|
||||
ecto_repos: [LipuKasi.Repo]
|
||||
#+end_src
|
||||
|
||||
The Phoenix endpoint configuration is pretty straightforward, we use Phoenix's PostgreSQL PubSub adapter these days to have a durable message passing channel between frontend and backend. And this damned secret key will have to be provided for production builds somehow, that'll be fun.
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
secret_key_base: "qjGyFdguDBSm8O7R4TI5M084mtgZ2vPE5p7a/2kTMuDCaPRUz9JiFdLK1RNUBggy",
|
||||
render_errors: [view: LipuKasiWeb.ErrorView, accepts: ~w(html json)],
|
||||
pubsub: [name: LipuKasi.PubSub, adapter: Phoenix.PubSub.PG2]
|
||||
#+end_src
|
||||
|
||||
Logger configuration is simple, I haven't changed this, though I probably would like to have JSON logs some day.
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
#+end_src
|
||||
|
||||
Use Jason for the Phoenix JSON library, this is also a default. I've used Poison in the past for personal projects, but I don't have anything resembling strong feelings.
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
config :phoenix, :json_library, Jason
|
||||
#+end_src
|
||||
|
||||
Lastly, config.exs loads environment-specific configuration.
|
||||
|
||||
#+begin_src elixir :tangle config/config.exs
|
||||
import_config "#{Mix.env()}.exs"
|
||||
#+end_src
|
||||
|
||||
** Development Configuration
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
use Mix.Config
|
||||
#+end_src
|
||||
|
||||
The database configuration for local development is pretty simple, a local postgres instance is required, which makes it a bit heavy to do on older hardware, but this is an Elixir decision not mine. There is a sqlite for ecto2, but I only use that in the [[file:../arcology.org][§Arcology]] project right now.
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
config :lipu_kasi, LipuKasi.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "lipu_kasi_dev",
|
||||
hostname: "localhost",
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10
|
||||
#+end_src
|
||||
|
||||
Disable the cache and enable debugging and hot code reloading, as well as setting up the webpack development server for assets.
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
http: [port: 4000],
|
||||
debug_errors: true,
|
||||
code_reloader: true,
|
||||
check_origin: false,
|
||||
watchers: [
|
||||
node: [
|
||||
"node_modules/webpack/bin/webpack.js",
|
||||
"--mode",
|
||||
"development",
|
||||
"--watch-stdin",
|
||||
cd: Path.expand("../assets", __DIR__)
|
||||
]
|
||||
]
|
||||
#+end_src
|
||||
|
||||
Configure Phoenix's LiveReload functionality, which watches some file paths and will recompile and reload the browser page if any of the files change:
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||
~r"priv/gettext/.*(po)$",
|
||||
~r"lib/lipu_kasi_web/{live,views}/.*(ex)$",
|
||||
~r"lib/lipu_kasi_web/templates/.*(eex)$"
|
||||
]
|
||||
]
|
||||
#+end_src
|
||||
|
||||
In development we don't need timestamps or other metadata in the logs, and provide more stacktrace context when there is an error.
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
config :logger, :console, format: "[$level] $message\n"
|
||||
config :phoenix, :stacktrace_depth, 20
|
||||
#+end_src
|
||||
|
||||
"Initialize plugs at runtime for faster development compilation", sure!
|
||||
|
||||
#+begin_src elixir :tangle config/dev.exs
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
#+end_src
|
||||
|
||||
** Testing Configuration
|
||||
|
||||
Testing is pretty simple and similar to development, just less stuff going on. The server doesn't run, the logger is less loud, warnings and errors only.
|
||||
|
||||
#+begin_src elixir :tangle config/test.exs
|
||||
use Mix.Config
|
||||
|
||||
config :lipu_kasi, LipuKasi.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "lipu_kasi_test",
|
||||
hostname: "localhost",
|
||||
pool: Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
http: [port: 4002],
|
||||
server: false
|
||||
|
||||
config :logger, level: :warn
|
||||
#+end_src
|
||||
|
||||
** Production Configuration
|
||||
|
||||
#+begin_src elixir :tangle config/prod.exs
|
||||
use Mix.Config
|
||||
#+end_src
|
||||
|
||||
Note we also include the path to a cache manifest containing the digested version of static files. This manifest is generated by the `mix phx.digest` task, which you should run after static files are built and before starting your production server.
|
||||
|
||||
#+begin_src elixir :tangle config/prod.exs
|
||||
config :lipu_kasi, LipuKasiWeb.Endpoint,
|
||||
url: [host: "lipu.garden", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
#+end_src
|
||||
|
||||
Don't print debug messages in production.
|
||||
|
||||
#+begin_src elixir :tangle config/prod.exs
|
||||
config :logger, level: :info
|
||||
#+end_src
|
||||
|
||||
Keeping this secrets file in sync is an [[file:../open_threads.org][§open thread]].
|
||||
|
||||
#+begin_src elixir :tangle config/prod.exs
|
||||
import_config "prod.secret.exs"
|
||||
#+end_src
|
||||
|
||||
When deployed, we'll probably do SSL termination in =nginx=, it's not so hard.
|
||||
|
|
Loading…
Reference in New Issue