This is a template repo and it can be utilized using the following pattern.
[GitHub Documentation] git-from-template
- Go to https://github.com/aviumlabs/phoenix-compose
- Select Use this template
- Select Create a new repository
Repository name: gutentag Description: A hello world application Public
- Select 'Create repository from template'
Generating your repository...
GitHub CLI
$ cd <projects/directory>
$ gh repo clone aviumlabs/gutentag
$ cd <projects/directory>
$ gh repo create gutentag -c -d "A hello world app" --public \
-p aviumlabs/phoenix-compose
Created repository aviumlabs/gutentag on GitHub Cloning into 'gutentag'...
The included prepare script will create a Phoenix Framework project.
Run $ ./prepare -h
to get started.
Running the prepare script to initialize the Phoenix Framework project:
$ cd gutentag
$ ./prepare -i gutentag -u
... We are almost there! ...
$ ./prepare -f
Running mix ecto.create... ... Running docker compose up; press cntl-c a to stop. ...
The example application is now running in the foreground and can be shutdown
with cntl-c a
.
The Phoenix Framework application is exposed on port 4000.
The src directory in the project working directory is bind mounted to the APP_CONTAINER_ROOT directory which by default is set to /opt when initialized and is then set to /opt/<application_name> after running finalize.
The default APP_CONTAINER_ROOT can be set during the project initialization phase by specifying the -r flag to the prepare script.
$ ./prepare -i gutentag -r /usr/local
The prepare script performs the following actions during initialization:
- generates a docker environment file (.env)
- generates a random password for the Postgres account
The prepare script performs the following actions during finalization:
- prepares the config/dev.exs dev environment:
- sets the ip address to 0, 0, 0, 0
- sets the database host
- sets the database password (pulled from the .env file)
- Phoenix Framework image: aviumlabs/phoenix:latest-alpine
- PostgreSQL image: postgres:15.2-alpine
A Phoenix Framework umbrella project can also be created with the prepare script.
$ ./prepare -i <app_name> -r /opt -u
$ ./prepare -i <app_name> -u
Official Elixir umbrella documentation here
With the src directory bind mounted to the application directory, you can use your favorite local development environment to continue with developing your application.
To run mix against the container, setting an alias can reduce some typing:
If running zsh in macOS, to permanently set the alias; add the following line to the ~/.zshrc file:
alias mix="docker compose run --rm app mix"