A toy project for Elixir build
|
|
4 år sedan | |
|---|---|---|
| assets | 4 år sedan | |
| config | 4 år sedan | |
| lib | 4 år sedan | |
| priv | 4 år sedan | |
| test | 4 år sedan | |
| .formatter.exs | 4 år sedan | |
| .gitignore | 4 år sedan | |
| README.md | 4 år sedan | |
| mix.exs | 4 år sedan | |
| mix.lock | 4 år sedan |
This project is intended to be a (serious) playground for other Elixir projects of mine in the aspects of build, integration and deployment.
dev or prodFor some reason the default configuration of newly-generated Phoenix projects is
completely outdated, e.g. using Mix.Config when the standard is now Config.
It is advised above all to update the configuration, and try to match the master branch
The project version is read from a git tag in the form "vX.Y.Z", provided the
git hooks in priv/build/setup-git-hooks.sh are installed AND mix.exs is
updated with the from_file function.
The version can then be read directly from the VERSION file or using the command :
mix run -e "Mix.Project.config[:version] |> IO.puts"
This command is not really handy to run to get build metadata, though, because
it requires the project to have been compiled at least once in dev mode. It is
therefore more handy to read the VERSION file.
Note : do not forget to push the tags onto the origin repository !
In dev as well as in prod modes, the role used in config/#{mode}.exs must
be created using e.g. the command line : sudo -u postgres createuser -P role_name
(add -d flag to allow database creation)
In dev as well as in prod modes, the role used in config/#{mode}.exs must
be created using e.g. the command line : sudo -u postgres createdb -O role_name db_name
The PostgreSQL role/database must be installed, if required.
To start the server in dev mode :
mix deps.getmix cmd npm install --prefix assetsmix phx.server or iex -S mix phx.server to run within a shellThe server can now be accessed on localhost:4000.
In production mode some configuration is extracted from the environment.
mix phx.gen.secretmix deps.get --only prodMIX_ENV=prod mix compilepriv/static : npm run deploy --prefix ./assetsmix phx.digestMIX_ENV=prod DATABASE_URL=db-url SECRET_KEY_BASE=secret_key PORT=port mix phx.serverThe latest release can be easily found using the following shell command :
find _build/prod/ -name "*.tar.gz" -exec stat -c "%n %Y" {} \; | sort -rnk 2,2 | head -1 | cut -d ' ' -f 1 | xargs realpath
To find the directory of the latest release :
find _build/prod/rel/app_name/releases -type d -exec stat -c "%n %Y" {} \; | sort -rnk 2,2 | head -1 | cut -d ' ' -f 1 | xargs realpath