dockerdockerfilefrontendbackenddevops

Multiple docker questions


Ok, I have searched through the Internet but I am not able to find a good answer to my current situation.

Got a project divided into three separate sub-folders, to know: database (postgresql), backend & frontend.

I want to:

  1. Have a standalone separate Dockerfile per sub-folder, one for the database, one for the backend and one for the frontend, as each images/container is going to operate into separate hosts.
  2. Allow docker images to have access to external sources but located in the same project root folder.

For example, at the backend sub-folder, which is a NodeJS + ExpressJS application I have a package.json file similar to this:

{
    "dependencies": {
        "my-project-dependency": "file:../folder/subfolder"
    },
    "devDependencies": {
        "@dotenvx/dotenvx": "~1.39.0",
        "@types/express": "~5.0.1",
        "@types/node": "~22.13.17",
        "@types/pg": "~8.11.11",
        "eslint": "~9.23.0",
        "express": "~5.1.0",
        "nodemon": "~3.1.9",
        "pg": "~8.14.1",
        "pg-format": "~1.0.4",
        "prettier": "~3.5.3",
        "ts-node": "~10.9.2",
        "typescript": "~5.8.2"
    }
}

Have you have any link to any valid example? Thank you.


Solution

  • As an example for separate subfolder/project with different environment docker files.

    enter image description here