{"id":18677346,"url":"https://github.com/kaplunmaxym/dockerdocs","last_synced_at":"2025-08-31T00:31:21.291Z","repository":{"id":245836417,"uuid":"819348116","full_name":"KaplunMaxym/DockerDocs","owner":"KaplunMaxym","description":"This project was created for educational purposes to practice working with Docker. It demonstrates how to set up a Node.js application using Docker, and includes a Makefile for easy management of Docker commands. Below is an explanation of each component in the project.","archived":false,"fork":false,"pushed_at":"2024-06-26T08:38:40.000Z","size":2410,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-07T09:46:10.449Z","etag":null,"topics":["ci-cd","containers","docker","images","nodejs","volumes"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KaplunMaxym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-24T10:23:48.000Z","updated_at":"2024-09-08T18:33:54.000Z","dependencies_parsed_at":"2024-11-07T09:36:17.292Z","dependency_job_id":null,"html_url":"https://github.com/KaplunMaxym/DockerDocs","commit_stats":null,"previous_names":["kaplunmaxym/dockerdocs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaplunMaxym%2FDockerDocs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaplunMaxym%2FDockerDocs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaplunMaxym%2FDockerDocs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaplunMaxym%2FDockerDocs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KaplunMaxym","download_url":"https://codeload.github.com/KaplunMaxym/DockerDocs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231539814,"owners_count":18392341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci-cd","containers","docker","images","nodejs","volumes"],"created_at":"2024-11-07T09:33:32.374Z","updated_at":"2024-12-27T21:12:09.380Z","avatar_url":"https://github.com/KaplunMaxym.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Educational Docker Project Documentation\n#### This project is designed for educational purposes to practice working with Docker. It demonstrates how to set up a Node.js application using Docker, and includes a Makefile for easy management of Docker commands. Below is an explanation of each component in the project.\n## Dockerfile\n```dockerfile\nFROM node\nWORKDIR /app\nCOPY package.json /app\nRUN npm install\nCOPY . .\nENV PORT 4200\nEXPOSE $PORT\nVOLUME [\"/app/data\"]\nCMD [\"node\", \"main.js\"]\n```\n#### The Dockerfile contains the instructions to build a Docker image for the Node.js application. Here is a breakdown of each command:\n```dockerfile\nFROM node\n```\n#### This line specifies the base image for the Docker image. The node image includes Node.js and npm pre-installed.\n```dockerfile\nWORKDIR /app\n```\n#### This command sets the working directory inside the container to /app. All subsequent commands will be run in this directory.\n```dockerfile\nCOPY package.json /app\n```\n#### This line copies the package.json file from the host machine to the /app directory in the container. This file contains the dependencies required for the Node.js application.\n```dockerfile\nRUN npm install\n```\n#### This command runs npm install inside the container to install the dependencies listed in the package.json file.\n```dockerfile\nCOPY . .\n```\n#### This line copies all files from the current directory on the host machine to the /app directory in the container.\n```dockerfile\nENV PORT 4200\n```\n#### This command sets an environment variable PORT inside the container to 4200. The application will use this port to listen for incoming requests.\n```dockerfile\nEXPOSE $PORT\n```\n#### This line informs Docker that the container will listen on the specified port (4200). This is used for documentation purposes and doesn't actually publish the port.\n```dockerfile\nVOLUME [\"/app/data\"]\n```\n#### This command creates a volume at /app/data inside the container. Volumes are used to persist data generated by and used by Docker containers.\n```dockerfile\nCMD [\"node\", \"main.js\"]\n```\n#### This command specifies the default command to run when the container starts. It runs the Node.js application by executing node main.js.\n\n## .dockerignore\n```.dockerignore\nnode_modules\n.idea\n.git\nDockerfile\n```\n#### node_modules: This directory contains local Node.js dependencies and should not be included in the Docker image.\n#### .idea: This directory contains project-specific settings for IDEs and should be excluded.\n#### .git: This directory contains version control data and should be excluded.\n#### Dockerfile: Excluding the Dockerfile itself to prevent it from being copied into the image.\n\n## Makefile\n```makefile\ncreate_image:\n\tdocker build -t node_docker:env .\nrun:\n\tdocker run -d -p 3000:4200 -v logs:/app/data --env-file .env --rm --name node_docker node_docker:env\nrun_dev:\n\tdocker run -d -p 3000:4200 -v $(shell pwd):/app -v /app/node_modules --env-file .env --rm --name node_docker node_docker:env\nrun_dev_nodemon:\n\tdocker run -d -p 3000:4200 -v $(shell pwd):/app -v /app/node_modules --env-file .env --rm --name node_docker --entrypoint \"npx\" node_docker:env nodemon main.js\nstop:\n\tdocker stop node_docker\n```\n#### The Makefile defines a set of commands to manage Docker operations. Here is an explanation of each command:\n```makefile\ncreate_image:\n\tdocker build -t node_docker:env .\n```\n#### create_image: This target builds the Docker image with the tag node_docker:env using the Dockerfile in the current directory (.).\n![ref](refs/r1.png)\n```makefile\nrun:\n\tdocker run -d -p 3000:4200 -v logs:/app/data --env-file .env --rm --name node_docker node_docker:env\n```\n#### run: This target runs the Docker container in detached mode (-d), mapping port 3000 on the host to port 4200 in the container (-p 3000:4200). It also mounts the logs volume to /app/data inside the container and loads environment variables from the .env file. The container is named node_docker and will be removed automatically when stopped (--rm).\n![ref](refs/r2.png)\n![ref](refs/r3.png)\n```makefile\nrun_dev:\n\tdocker run -d -p 3000:4200 -v $(shell pwd):/app -v /app/node_modules --env-file .env --rm --name node_docker node_docker:env\n```\n#### run_dev: This target runs the Docker container in development mode. It mounts the current directory ($(shell pwd)) to /app inside the container, allowing live editing of files. It also mounts a volume for node_modules to use local dependencies. The rest of the parameters are the same as the run target.\n![ref](refs/r2.png)\n![ref](refs/r4.png)\n```makefile\nrun_dev_nodemon:\n\tdocker run -d -p 3000:4200 -v $(shell pwd):/app -v /app/node_modules --env-file .env --rm --name node_docker --entrypoint \"npx\" node_docker:env nodemon main.js\n```\n#### run_dev_nodemon: This target runs the Docker container in development mode with nodemon to automatically restart the server on file changes. It overrides the default entry point to use npx nodemon main.js.\n```makefile\nstop:\n\tdocker stop node_docker\n```\n#### stop: This target stops the running container named node_docker.\n## Working with Volumes\n#### Volumes are used to persist data generated by and used by Docker containers. In this project, there are both named and anonymous volumes:\n* **-v logs:/app/data**: This command creates a named volume called logs and mounts it to /app/data in the container. This is useful for persisting log data.\n* **-v $(shell pwd):/app**: This command mounts the current directory on the host machine to /app in the container. This allows for live editing of files during development.\n* **-v /app/node_modules**: This command mounts an anonymous volume for the node_modules directory, preventing local node_modules from being overwritten in the container.\n#### These volumes help in managing data and development workflows efficiently, ensuring that changes are reflected immediately and data is persisted as needed.\n#### This documentation should provide a comprehensive understanding of how the Dockerfile and Makefile work together to manage the Node.js application in both production and development environments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaplunmaxym%2Fdockerdocs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaplunmaxym%2Fdockerdocs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaplunmaxym%2Fdockerdocs/lists"}