Home | Blogs | TILs | Papers | Projects | Writings | Books | Astro |
I mostly code in Ruby. And I tend to bootstrap lots of project to test out my ideas. I create lots of projects, and experiment different languages and frameworks and docker helps to keep them segragated and help in managing the dependencies easily. Though it has limitations on mac I still tend to use it.
I was trying to get started with a Phoenix app and thougth this might help others as well. It has been taken from multiple places and helps me get started quickly.
I have the following Dockerfile and docker-compose.yml
You will notice that I have used a file called entrypoint.sh
. It has the following content:
Let us assume that I want to create a project called mvp-app
. Create a directory called the same and put these three files inside it.
To init the app run the following commands:
The first one should exit (may be with some error, I dont remember). The second one will create another directory called mvp-app inside the current directory. Move all the contents inside the new directory to its parent and delete the new one.
You can continue with what Phoenix suggests to continue setting up the project:
Once you are done with this the initial landing page will be visible with simple
Once you have the containers running you can use exec
instead of run
in docker-compose.
You can generate models like this
and run migration as mention before, may be with exec
this time!
To access you can visit localhost:4000
on you browser. Dont forget to git init
:)