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_modules separately
rebuilding the image whenever a new dependency is added to the project.
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 watch feature to automatically sync and rebuild, eliminating the need for bind mounting and manual management of node_modules.
Optimize MongoDB service by adding --quiet and --logpath /dev/null options to reduce log clutter.
Use Case
After running docker compose up --build:
Press w to Enable Watch
Syncing backend service after changes in code
Rebuilding backend service 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.
Description:
Current setup poses challenges and hampers developer productivity
Currently, our Docker Compose configuration uses bind mounting for the backend service, which requires
node_modules
separatelyAdditionally, the MongoDB service logs clutter the terminal, making it difficult to focus on relevant information and causing unnecessary distraction.
Proposed Changes:
Implement Docker Compose
watch
feature to automatically sync and rebuild, eliminating the need forbind mounting
and manual management ofnode_modules
.Optimize MongoDB service by adding
--quiet
and--logpath /dev/null
options to reduce log clutter.Use Case
After running
docker compose up --build
:Press
w
to Enable WatchSyncing
backend
service after changes in codeRebuilding
backend
service after changes in dependenciesAdditional 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
```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
```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: