[enhancement]: Enhance Developer Experience with Docker Compose
Description:
Current setup poses challenges and hampers developer productivity
-
Currently, our Docker Compose configuration uses bind mounting for the backend service, which requires
- managing the
node_modulesseparately - rebuilding the image whenever a new dependency is added to the project.
- managing the
-
Additionally, the MongoDB service logs clutter the terminal, making it difficult to focus on relevant information and causing unnecessary distraction.
Proposed Changes:
-
Implement Docker Compose
watchfeature to automatically sync and rebuild, eliminating the need forbind mountingand manual management ofnode_modules. -
Optimize MongoDB service by adding
--quietand--logpath /dev/nulloptions to reduce log clutter.
Use Case
After running docker compose up --build:
-
Press
wto Enable Watch -
Syncing
backendservice after changes in code -
Rebuilding
backendservice after changes in dependencies
Additional Information
-
By implementing these changes, we aim to streamline the development workflow, improve developer productivity, and reduce the overhead of managing dependencies and logs.
-
This enhancement aligns with our goal of providing a seamless development experience for contributors.
Additional context or Information
-
Initial Configuration:
docker-compose.yaml
version: '3.8' services: backend: image: freeapi-server build: . ports: - 8080:8080 volumes: - ./:/usr/src/freeapi - /usr/src/freeapi/node_modules env_file: - ./.env depends_on: - mongodb mongodb: image: mongo container_name: mongodb volumes: - data:/data/db ports: - 27017:27017 volumes: data:
-
Proposed Configuration:
docker-compose.yaml
version: '3.8' services: backend: image: freeapi-server build: . ports: - 8080:8080 env_file: - ./.env depends_on: - mongodb develop: watch: - action: sync path: . target: /usr/src/freeapi ignore: - node_modules/ - action: rebuild path: ./package.json mongodb: image: mongo container_name: mongodb command: ['--quiet', '--logpath', '/dev/null'] volumes: - data:/data/db ports: - 27017:27017 volumes: data:
Suggested Tools
-
Docker Compose Watch
Docker Compose documentation for file watching feature.
-
Hands on
Practical demo on implementing Docker Compose improvements.
Labels:
- enhancement
- docker
- developer-experience
@KadlagAkash Looks good. You can proceed with opening a PR for the same. Thank you