Created
September 6, 2022 09:33
-
-
Save garry-jeromson/1ef2163dd85e6433fe6b3f71f3c887a3 to your computer and use it in GitHub Desktop.
Docker compose config with node_modules volume mount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
services: | |
web: | |
user: ${TEST_USER} | |
image: migrosonline/some-component:develop | |
build: | |
target: develop | |
environment: | |
NODE_ENV: development | |
ENVIRONMENT: local | |
JEST_JUNIT_OUTPUT_DIR: "/srv/app/test_reports/junit" | |
volumes: | |
- ./app:/srv/app | |
# Mount a named volume to the node_modules folder. This is a workaround to ensure that we never accidentally | |
# mount our local node_modules volume in the container; it allows us to develop both inside and outside of the | |
# container without having to worry about conflict (e.g. macOS vs Linux node dependencies). We use a named | |
# volume rather than an anonymous volume so we can easily identify the volume, and so that multiple anonymous | |
# volumes don't clog up our hard drives. | |
- node_modules:/srv/app/node_modules:delegated | |
networks: | |
- no-internet | |
command: npm run test | |
volumes: | |
node_modules: | |
networks: | |
no-internet: | |
driver: bridge | |
internal: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment