Home

Awesome

Renew

This is a universal project generator that grow out of Nebo #15 requirements:

So it includes:

Installation

Install this package globally:

mix archive.install https://github.com/Nebo15/renew/releases/download/0.20.0/renew.ez

Usage

Usage is very similar to mix new, but with many additional feature flags:

Run renew mix task to create new projects:

mix renew myapp --ecto --ci --docker --phoenix

You can get more info in renew mix task.

Docker Helpers

Dockerfile needs enhancements, so take look in it's source. Sometimes you need to expose some ports to talk to a container, and change CMD of your application.

There are ./bin/build.sh script that removes routine in building container for production.

$ ./bin/build.sh
[I] Building a Docker container 'myapp' from path '/Users/andrew/Projects/www/myapp'..
Sending build context to Docker daemon 24.96 MB
Step 1 : FROM trenpixster/elixir:1.3.2
 ---> e22fdfc62c5a
...
Successfully built eae970501b13

Another one is ./bin/start.sh that will run your app in detached mode.

Environment variables

Use ${ENV_VAR} inside config/config.exs since Distillery is configured to replace OS vars on each run of application.

config :myapp, :mykey,
  db_user: "${DB_USER}"

When configuring your code you can also use Confex and {:system, VAR_NAME, default_value} tuples:

config :myapp, :mykey,
  somevar: {:system, "MY_VAR_NAME", "default"}

and read it later:

Confex.get_map(:myapp, :mykey)

Later you can start Docker container passing .env file to set appropriate configuration of your application:

$ docker run --env-file .env [rest..]

Migrations

Whenever you make a release for your app you can't use mix anymore, but you still want to be able to run migrations. For this cases we include migrator module. This post tells how to run migration without mix.

Your migrations will be preserved within container in ./priv/repo folder.

To run a migration set DB_MIGRATE=true in your environment.

Useful links

Thanks