Legacy Workflow Explanations - Arthyon/microservice-poc GitHub Wiki
This section contains explanations for the commands presented in the developer workflow.
Starting development
docker-compose up -d will run the system in detached mode, returning terminal control to us. It is of course also possible to use two different terminals and not running in detached mode. One reason to not doing this is to look at container output, as stdout from each container is redirected to the terminal.
Changing a node-service without adding new dependencies to package.json:
In this situation we can just restart the service. We have mounted our filesystem in the container, so all local changes is automatically present inside the container. This means that yarn build will see the updated .ts-files without having to rebuild the image. We still need to restart the container as hot reloading is not available for node service. See section Notes on hot reload+debug in node containers for more information.
Changing a node-service that adds a new dependency
When adding a dependency, we need to rebuild the container. We are resolving node_modules when creating the image so we don't need to download them every time we start a container. This saves time in the long run, as we typically do not add dependencies as often as we make code changes.
Before building the new image, shut down everything and set it up with the new container afterwards.
TODO: Could we only shut down a single container and then set it up again?
Changing a .Net-service without adding new nuget-packages
In this situation we can just restart the service. We have mounted our filesystem in the container, so all local changes is automatically present inside the container. This means that dotnet run watch will see the updated .cs-files without having to rebuild the image. Dotnet apps have hot reloading enabled, so we do not need to restart the container.
Changing a .Net-service that adds new nuget-packages
When adding a dependency, we need to rebuild the container. We are resolving nuget-packages when creating the image so we don't need to download them every time we start a container. This saves time in the long run, as we typically do not add dependencies as often as we make code changes.
Before building the new image, shut down everything and set it up with the new container afterwards.
TODO: Could we only shut down a single container and then set it up again?
Adding a new service
When adding a new service, we need to add it two places, docker-compose.yml and Ocelot.
Docker-compose
We need to add an entry here to be able to create it using docker-compose up. This command scans the docker-compose.yml file (and also docker-compose.override.yml if present). We also set up volume mounting and port-exposing here.
Ocelot
To enable Ocelot to redirect traffic to the new service, an entry needs to be added to this config file. After adding the entry we need to rebuild the image. This is because the config-file is copied into the image in build time.
We can also set up volume mounting to read the updated config-file if this becomes a problem.