diff --git a/README.md b/README.md index ae1eb291..132c5330 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,47 @@ Next generation imageboard. -![](https://derpicdn.net/img/2019/8/23/2125268/full.png) +![](https://derpicdn.net/img/2019/8/23/2125268/full.svg) -To start your Phoenix server: +## Getting started +On systems with `docker` and `docker-compose` installed, the process should be as simple as: - * Install dependencies with `mix deps.get` - * Create and migrate your database with `mix ecto.setup` - * Install Node.js dependencies with `cd assets && npm install` - * Start Phoenix endpoint with `mix phx.server` +``` +docker-compose build +docker-compose up +``` -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. +If you use `podman` and `podman-compose` instead, the process for constructing a rootless container is nearly identical: -Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). +``` +podman-compose build +podman-compose up +``` -## Learn more +If you run into an Elasticsearch bootstrap error, you may need to increase your `max_map_count` on the host as follows: +``` +sudo sysctl -w vm.max_map_count=262144 +``` - * Official website: http://www.phoenixframework.org/ - * Guides: https://hexdocs.pm/phoenix/overview.html - * Docs: https://hexdocs.pm/phoenix - * Mailing list: http://groups.google.com/group/phoenix-talk - * Source: https://github.com/phoenixframework/phoenix +If you have SELinux enforcing, you should run the following in the application directory on the host before proceeding: +``` +chcon -Rt svirt_sandbox_file_t . +``` + +This allows Docker or Podman to bind mount the application directory into the containers. + +## Deployment +You need a key installed on the server you target, and the git remote installed in your ssh configuration. + + git remote add production philomena@:philomena/ + +The general syntax is: + + git push production master + +And if everything goes wrong: + + git reset HEAD^ --hard + git push -f production master + +(to be repeated until it works again) diff --git a/mix.exs b/mix.exs index 5e0e8f80..46b67275 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Philomena.MixProject do def project do [ app: :philomena, - version: "0.1.0", + version: System.get_env("PHILOMENA_VERSION") || "0.1.0", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), diff --git a/rel/config.exs b/rel/config.exs new file mode 100644 index 00000000..7b88a9eb --- /dev/null +++ b/rel/config.exs @@ -0,0 +1,58 @@ +# 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. +~w(rel plugins *.exs) +|> Path.join() +|> Path.wildcard() +|> Enum.map(&Code.eval_file(&1)) + +use Distillery.Releases.Config, + # This sets the default release built by `mix distillery.release` + default_release: :default, + # This sets the default environment used by `mix distillery.release` + default_environment: Mix.env() + +# For a full list of config options for both releases +# and environments, visit https://hexdocs.pm/distillery/config/distillery.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: :"5MEZn{TTU:$GyE/DgOAV0GhEWU>Gj>YwWXmo&pd3t~L8gHVrlSR>8W9API~YL=&^" +end + +# N.B.: this cookie has to do with how distributed Erlang authenticates +# communication between nodes. With correct firewall configuration, you do not +# need to change it. +environment :prod do + set include_erts: true + set include_src: false + set cookie: :";?PAn6iwn<<(~GAez2sS/|aNd{tV(k7j%0v3`eD]YN}Ii@?ws$RW|%iuBD@127.0.0.1 + +## Cookie for distributed erlang +-setcookie <%= release.profile.cookie %> + +## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive +## (Disabled by default..use with caution!) +##-heart + +## Enable kernel poll and a few async threads +##+K true +##+A 5 +## For OTP21+, the +A flag is not used anymore, +## +SDio replace it to use dirty schedulers +##+SDio 5 + +## Increase number of concurrent ports/sockets +##-env ERL_MAX_PORTS 4096 + +## Tweak GC to run more often +##-env ERL_FULLSWEEP_AFTER 10 + +# Enable SMP automatically based on availability +# On OTP21+, this is not needed anymore. +-smp auto