Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dogweather/phoenix-docker-compose
Docker development environment for Elixir+Phoenix
https://github.com/dogweather/phoenix-docker-compose
developer-tools devops docker phoenix-framework
Last synced: 17 days ago
JSON representation
Docker development environment for Elixir+Phoenix
- Host: GitHub
- URL: https://github.com/dogweather/phoenix-docker-compose
- Owner: dogweather
- License: apache-2.0
- Created: 2018-02-02T09:03:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-17T22:50:40.000Z (almost 4 years ago)
- Last Synced: 2024-10-14T00:25:39.826Z (about 1 month ago)
- Topics: developer-tools, devops, docker, phoenix-framework
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 160
- Watchers: 5
- Forks: 38
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elixir / Phoenix containerized development environment
This repo contains simple boilerplate files that can be added to any [Phoenix](https://www.phoenixframework.org/) application so you may run it and its database inside Docker containers using [Docker Compose](https://docs.docker.com/compose/).
## What you get
* One-line dev environment setup: `docker-compose up`. This command creates the database, does the Dialyzer pre-work (if the project has [Dialyxer](https://github.com/jeremyjh/dialyxir) installed), and everything else.
* Developer-friendly setup: Source code is mounted so that changes in the container appear on the host and vice-versa.
* Fast re-builds because the `Dockerfile` is written to help Docker cache the images.
* Syncing with Postgres startup delay.
* All the crappy little dependencies installed.
* No weird hacks.Uses Elixir 1.9.4 (compatible with Phoenix 1.4), and latest Postgres.
## Instructions
1. Copy the three files (`Dockerfile`, `docker-compose.yml`, and `run.sh`) to an existing Phoenix project which you want to Dockerize.
2. Make `run.sh` executable, e.g. `chmod +x run.sh`
3. Edit the database connection settings for the environments which will use this setup (usually `dev.exs` and `test.exs`).
You can hard-code the credentials for the relevant environment(s) to reference the hostname of `db`, a username of `postgres`, and an empty password, or you can specify environment-variable overrides like the following:```elixir
# Inside config/dev.ex and/or config/test.exs
config :my_app, MyApp.Repo,
hostname: System.get_env("DB_HOST", "localhost"),
password: System.get_env("DB_PASS", "postgres"),
# ... etc...
```4. Spin it up with `docker-compose up`.
## Usage
Tests can be run in the container like so:
```bash
docker-compose run web mix test
```Or, for a slightly faster startup time,
```bash
docker-compose exec web mix test
```... I haven't found a disadvantage of re-using the running container this way.