-
Notifications
You must be signed in to change notification settings - Fork 76
Tips for Developing in Docker
This page will help developers work with their local docker environment.
Refer to the docker README.md
for a detailed setup explanation. This page assumes you have both cveawg
and mongo
containers running locally using our compose file or building your own cve-services/docker/Dockerfile.dev
container.
Populating the mongo
docker container can be done from a shell inside the cveawg
container, the same way a local environment can be populated, once prerequisites are met.
The current docker setup copies static fixtures from cve-services/datadump/pre-population/
into the development container for your use. Warning: the populate script generates many UUIDs for this data and will take a while to run.
If you have a custom data set you can load them into the container in the same folder so long as the same files are there (the populate script requires them):
docker cp yourdata/ cveawg:/app/datadump/pre-population
The /app
folder inside the cveawg
container is a subset of the cve-services
repository. A shell inside the container has access to the application's Node environment. The following command, from outside the container, will run the container's dev
population script:
docker exec -it cveawg npm run populate:dev
One can also open a shell inside the container, then run the script:
docker exec -it cveawg /bin/sh
npm run populate:dev
Once one understands the process for populating the mongo
container, any additional task that is familiar in a local environment becomes a pattern on the same theme to run that task in Docker. For example, the following will run tests in the running docker environment:
docker exec -it cveawg npm run test
Noting the pattern for developing in docker, here is a set of aliases that one could add to their ~/.bashrc
to streamline their local development process:
alias cveawg='docker exec -it cveawg'
alias cveawgdb='docker exec -it mongo'
alias cveawg-sh='cveawg /bin/sh'
alias cveawg-mongo='cveawgdb mongo'
alias cveawg-populate='cveawg npm run populate:dev'
alias cveawg-test='cveawg npm run test'