DEV Community

Discussion on: Development environment for Elixir + Phoenix with Docker and Docker-compose

Collapse
 
robert197 profile image
Robert

First of all, by following the best practices of docker. An image should not have frontend and backend dependencies. It does not matter if its for local development environment or for non local environments.
Also docker is built to solve one big problem. The problem is called "it works on my machine". By defining different containers for local and non local you missuse power of docker.
The solution is to use 2 containers. One for front-end dependencies, one for backend and make use of multistage builds.
Doesn't matter if local or non local.
If you want i could make s pull request on your GitHub repo to show you how it works.
What do you think?

Greetings

Thread Thread
 
hlappa profile image
Aleksi Holappa • Edited

Well, if I use alpine based image on local development and on cloud deployments, how that does not solve the "it works on my machine" issue? I'm just curious.

I have one question, how I'm going to do rapid local development if I build the images locally with multistage Dockerfile? What happens to hot code reloading? Also, Elixir with Phoenix framework is SSR, so there is no separate frontend and backend as e.g. in Node and React. Nevertheless, you can separate the static assets and other browser rendered stuff and backend to own containers in cloud deployments, but on local environment I don't see the real benefit of it.

I opened the repo, you should be able to make a merge/pull request to it. You can find the link below, don't mind the naming of the repo. I'm waiting for MR!

gitlab.com/hlappa/url-shortener/

Thread Thread
 
sergio_101 profile image
sergio t. ruiz

I ended up finding this here: evolvingdev.io/phoenix-local-devel... ..

The trick is adding this:

    watchOptions: {
      poll: true
    },
Enter fullscreen mode Exit fullscreen mode

to your webpack.config.js.