An incubator for your Phoenix projects
Report Bug
·
Request Feature
Table of Contents
This in a nutshell is a Dockerfile with all set up to develop Phoenix Framework applications, with a docker-compose.yml and an executable file to go along.
You may configure the container and the executable by modifying the same environment file used to configure the docker-compose YML, thus keeping configuration in a single file.
To get a local copy up and running follow these simple example steps.
You first need to have docker and docker-compose installed in your system.
This docker-compose.yml file is meant to be used alongside the nginx-proxy project. If this is not your use case you will have to adapt the file. To run it as a standalone, change it so the container exposes HTTP and HTTPS ports, and drop the network definitions.
- Clone the repo
git clone https://github.com/Quarkex/phoenix-dev-docker-image.git && cd phoenix-dev-docker-image
- Fill in the minimal required configuration
touch .env echo "COMPOSE_PROJECT_NAME=the_project" >> .env echo "DOMAIN=the_project.domain.tld" >> .env
- If you are using the nginx-proxy setup, also add the Let's Encrypt email
echo "[email protected]" >> .env
- Build the image
docker-compose build
Once you have build the image, you can start the project. It will check it's configuration to see if it has to download a git project or spin up a new one.
-
Start the project in detached mode
./project up -d
-
Check the log output to see what's happening
./project logs -f
We suggest that you add the "project" executable to an alias so you can conveniently access it while working somewere else:
alias the_project="${PWD}/project"
Now you can use the_project <ACTION> [ARGS]
and it will know what to do.
These are the configurable variables that you may use inside the .env file and what they do.
-
COMPOSE_PROJECT_NAME:
REQUIRED
This is a unique identifier used by docker-compose to handle each project.
It is required, as this container will infer a few defaults from this, like the docker image name.
-
DOMAIN:
REQUIRED
The domain where this project will be exposed. This will be used as the container hostname, the nginx-proxy configuration file and phoenix itself.
-
USER_NAME:
default: elixir
The container non-root user name.
-
GROUP_NAME:
default: elixir
The container non-root user group.
-
USER_UID:
default: 40759
The container non-root user UID.
-
USER_GID:
default: 40759
The container non-root user GID.
-
LANGUAGE:
default: en_US
The language used to build the locale. Do not append ".UTF-8", it is assumed, as elixir requires this to be the case.
-
LETSENCRYPT_EMAIL:
The Let's Encrypt email that will be used in the autogenerated certificate if you are using the nginx-proxy project.
-
PORT:
default: 4000
The port that this container will expose. Using nginx-proxy it will also properly redirect here.
-
TITLE:
default: ${APP_NAME}
You may specify this to use inside your projects. This way you can define the default web title with an env variable.
-
GIT_REPO:
default: ""
If it's not an empty string (or if undefined) the container will fetch this repo instead of initializing a new project.
-
APP_NAME:
default: app
This will be used as the app name when starting a new project automatically.
The folder and default title are infered from here too when undefined.
-
APP_DIRECTORY:
default: app
The name of the app where the project will reside.
-
ERLANG_NAME:
default: app
This is used to alter the erlang name used by elixir when running the instance. Useful if you are working with erlang nodes.
-
ERLANG_COOKIE:
default: app
The secret cookie used to establish a connection between erlang nodes.
-
PGUSER:
default: postgres
This is the default user used by psql.
-
PGPASSWORD:
default: postgres
This is the default password used by psql.
-
PGDATABASE:
default: ${APP_NAME}
This is the default database used by psql.
-
PGPORT:
default: 5432
This is the default port used by psql.
-
PGHOST:
default: psql.${DOMAIN}
This is the default host used by psql.
-
MIX_ENV:
default: dev
The mix env variable. Useful if you need to run it in test or prod modes and you are not using releases.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Manlio Joaquín García González - @Quarkex - [email protected]
Project Link: https://github.com/Quarkex/phoenix-dev-docker-image