Skip to content

Mounting the entire root source directory is bad practice #183

@eladavron

Description

@eladavron

Docker containers should contain as little content as possible, and when possible - not be live.
Using:

volumes:
  - .:/app

Both loads the container with a lot of unnecessary files AND makes it "live", meaning that any changes in the source code automatically get applied inside the container, which is an antipattern. Containers should be self-sustaining and isolated.
Mounting source code like this should only be done for debugging.

A few required corrections:

  • In the Dockerfiles, use the COPY or ADD directives to copy the necessary files to the container image, as selectively as possible.
  • Maintain a seperate docker-compose.yaml file for debugging and for production, with only the debugging one containing the mounting.
  • The style container might also be redundant in such a case - just compile SASS once and avoid having to use watch (since again, that is for live debugging)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions