ericlathrop
When I spin up a new project, I always want a dev environment with a database and test runner. I’ve had a set of files I’ve copied from project to project over the years, but it’s manual and error prone. I’ve finally gotten annoyed enough to create a mix task that sets it all up for you.
You install it with mix archive.install hex dockerize_elixir then you can run mix dockerize path/to/my_app to install all the docker stuff into your project. Then a docker compose up will start the whole thing.
It creates 3 containers:
- your app
- postgres
- your tests (
mix testormix test.watch, if installed)
Things it does for you:
- It configures ecto to connect to the
postgrescontainer instead oflocalhost. - It exposes port 4000 to your host machine, which is the default port for Phoenix. It also configures Phoenix to listen on 0.0.0.0, so you can actually access it.
- It makes a volume to share the code between your host machine and the containers.
- It makes volumes to isolate
_buildanddepsfolders from your host machine.
It also installs a few helper scripts:
bin/iexrunsiexinside theappcontainerbin/psqlrunspsqlinside thepostgrescontainerbin/rollbackrolls back the migration. Amigratescript is not necessary because it runs migrations when the container starts.
This should work for Phoenix apps, or vanilla elixir apps that use ecto.
Please give it a try and let me know how it works for you.
Trending in Announcing
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
New
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Other Trending Topics
Bond brings Design by Contract to Elixir: preconditions, postconditions and invariants as executable specifications, checked at runtime a...
New
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
omattman
Just wanted to say thank you, @ericlathrop, for this guide. It helped me immensely, since I refuse to test anything without a basic Docker environment. Much appreciated!