GithubHelp home page GithubHelp logo

brendanmoyer / phoenix-docker-compose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dogweather/phoenix-docker-compose

0.0 0.0 0.0 20 KB

Docker development environment for Elixir+Phoenix

License: Apache License 2.0

Shell 71.52% Dockerfile 28.48%

phoenix-docker-compose's Introduction

Elixir / Phoenix containerized development environment

This repo contains simple boilerplate files that can be added to any Phoenix application so you may run it and its database inside Docker containers using Docker 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 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:
# 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...
  1. Spin it up with docker-compose up.

Usage

Tests can be run in the container like so:

docker-compose run web mix test

Or, for a slightly faster startup time,

docker-compose exec web mix test

... I haven't found a disadvantage of re-using the running container this way.

phoenix-docker-compose's People

Contributors

dogweather avatar bdiasti avatar fireproofsocks avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.