DEV Community

Cover image for Dockerizing Phoenix Development (2) Folders & Files
Alastair Measures
Alastair Measures

Posted on • Updated on

Dockerizing Phoenix Development (2) Folders & Files

The overall objective is to construct a development environment within Docker for a website based on Phoenix and Elixir backed by PostgreSQL with PostGIS.

We are working through 'docker-compose', with project parameters in an explicit, indented YAML file rather than a bash script.

This step is intended to set out the organisation of files and folders being used, and explain each.

Hierarchy

  • ./base_folder/ (folder - might be $HOME)
    • /myp_dev/ (folder of entire project)
      • /docker-compose.yml (text file scripting images to run together)
      • /Dockerfile.alpine (text file defining image for web server)
      • /source/ (folder where your Elixir code goes)

./myp_dev

  • This is a folder that encapsulates our whole exercise. The docker-compose commands should be issued from this folder.

  • Note: when docker-compose starts our collection of containers: it names them including this folder name as a prefix. This feature is helpful and makes it easier to run, say, a beta version alongside a development version for comparison purposes.

./myp_dev/docker-compose.yml

  • This is a text file; which scripts the necessary images required to bring up a group of containers as a system.

./myp_dev/Dockerfile.alpine

  • This is a text file, we use to build an image for Elixir and Phoenix.

./myp_dev/source

  • This folder will contain all our Elixir and Phoenix coding. This folder will be mounted as a volume into the container. In this way we can run our web server inside the container, and, at the same time, use editors and IDE software on the host system (from outside the container).

Remarks

  • By default: the user inside the container is 'root' (for that container) and will not let you edit files created if you are anything less!

  • To make this work smoothly, the 'user id' and 'group id' used for development within the container will need to match those of the development user on the host machine.

  • This exercise has been assembled under Linux and will very probably work hosted on a Mac. Windows, however, formats text files differently and trying to use the same folders from a container (Linux) and the host (Windows) is likely to give you gremlins! (End of line and end of file are coded differently). Some IDE software such as KomodoIDE may have preference settings that help, however it remains a courageous practice.

Top comments (0)