https://www.docker.com/blog/how-to-setup-your-local-node-js-development-environment-using-docker/
docker/- Docker configurationsdev/- development configurationDockerfile- Docker file for the development environmentdocker-compose.yml- Docker compose configuration; to launch from the root folder
prod/- production configurationDockerfile- production Docker filedocker-compose.yml- Docker compose configuration; to launch from the root folder
traefic/- Traefic reverse proxy configuration (manages domain names, ceritifcates etc)docker-compose.yml- Traefic Docker compose configuration
scripts/- shell/bash scriptsbuild.sh- builds prod Docker imagedev.sh- starts the dev configurationkill.sh- removes all running docker containersrun.sh- utility script used by thebuild.sh,start.shandstop.shto perform a command on a set of Docker compose configurationsstart.sh- starts prod applicationsstop.sh- stops prod applicationsshell.sh- connects to the dev container and opens a bash shell
webapp/- application foldersrc/- source code for this projectindex.js- the application entry pointpackage.json- node configuration file
.env.template- template with default environment variables; this template is copied to the.envfile (if it was not explicity defined)
TLDR:
./scripts/dev.sh- starts dev containers./scripts/shell.sh- opens a bash shell in the running dev container./scripts/kill.sh- kills all running containers
To launch the development configuration for the project you should run:
./scripts/dev.shThis scripts launches the docker containers and the application in dev mode.
Internally it uses the yarn dev command in the package.json file.
To stop containers you should just exit from this shell. The script will automatically stop the docker containers.
All source files and installed packages are shared with the host.
Internally the docker uses the current user and group IDs so the host machine should have normal read/write access to
generated/installed files (ex: node_modules/, yarn.lock etc).
To get access to the running development container you can use the ./scripts/shell.sh script:
./scripts/shell.shTLDR:
./scripts/build.sh- builds a prod Docker container./scripts/start.sh- starts the production container./scripts/stop.sh- stops the production container./scripts/kill.sh- kills all running containers
When applications started with the ./scripts/dev.sh (dev mode) or the ./scripts/start.sh script (in production mode)
then it uses variables defined in the .envfile.
If there is no such file found in the root directory then it is automatically created from the .env.template.
There are following parameters in this file used by Docker configurations to start applications:
CONTEXT_NAME- default name of the context; this name is used to prefix all services launched by DockerCONTEXT_DIR- root directory where all data are storedCONTEXT_EMAIL- default mail used to contact with the administrator of the siteMAIN_URL- the main URL of the systemHTTP_PORT(default: 80) - the port of the reverse proxy (traefic)HTTPS_PORT(default: 443) - default port of the secured http connection with the proxyTRAEFIK_DASHBOARD_HOST(default:traefik.localhost) - URL of the traefic web portalTRAEFIK_DEBUG(default: false) - flag defining if traefic shows or not debug messagesDEV_HOST- host of the dev servicePROD_HOST- host name for the production service