Docker offers numerous benefits, particularly in software development and deployment. Firstly, it ensures consistency by encapsulating applications and their dependencies into containers, making them portable across environments. This minimizes “it works on my machine” issues. Secondly, Docker accelerates development cycles by enabling quick, reproducible, and isolated testing environments. It enhances scalability, as containers can be easily scaled up or down to meet demand. Using lightweight containers reduces overhead compared to traditional virtual machines, enhancing performance and efficiency. Furthermore, Docker integrates well with CI/CD pipelines, streamlining deployment. Its vast ecosystem and rich community support make it a go-to tool for modern DevOps workflows.
Nomirun CLI offers 2 approaches with Docker images and containers.
In this method, Docker runs the container with configuration instructions for building application modules during startup. While convenient for dynamic or development environments, this approach is less optimal for production as the Docker image becomes mutable. It may increase container start-up time and risk runtime variations or inconsistency.
You can achieve this behaviour by configuring and running the Nomirun cluster by:
❯ nomirun cluster configure --cluster-name MyShopMonolith --nuget-server-name "GitHub"
❯ nomirun cluster generate --cluster-name MyShopMonolith --target-format DockerEnvFile
❯ nomirun cluster start --cluster-name MyShopMonolith --host-type ContainerThis will take a pre-build Nomirun host Docker image and configure it to run the hosts and modules in the specified cluster.
Switch
--nuget-server-namedefines a NuGet Repository, in case above its local NuGet folder (“GitHub”). Define this with nomirun init command.
Here, the application is fully built first, and the compiled files are copied into the Docker image. The resulting container is immutable, ensuring consistency across environments. Since the image contains the pre-built application, it starts faster, is more reliable for production usage, and adheres to best practices in image creation.
nomi cluster generate and specify the --target-format for the configuration output format. In the case below we are generating .env file. We will support more formats in the future, depending on the need.❯ nomi cluster configure -c MyShopMonolith --nuget-server-name "Feedz.io"
❯ nomi cluster generate -c MyShopMonolith --target-format DockerEnvFile
❯ nomi cluster build -c MyShopMonolith --host-type Container --docker-image-tag v1.0The output of the nomi cluster build command looks like this:
...
Container information about cluster host saved to:
C:\Users\MyUser\.nomirun\clusters\SolarPlatformKubernetes\container-custer-info-SolarPlatformKubernetes-v1.txtIf you have multiple hosts in the cluster, you’ll get a docker image and docker run command for all of them in the txt file.
You can see the convention of docker image names - HOST_NAME.app:TAG.
Docker containers will use the same ports as you used for development, but you can always change then depending on your need. Docker always exposes six ports, 5000, 5001, 5002, 5003, 5004, 5005. Read more about it here.
Now you can re-tag docker images for your registry and push them.
❯ docker tag myshopmonolith.myshopapi.app:v1.0 mydocker-hub.com/myshopmonolith.myshopapi.app:v1.0 ...
❯ docker push mydocker-hub.com/myshopmonolith.myshopapi.app:v1.0 ...You can also build a standalone Nomirun host application. That means CLI will create a ZIP file containing a pre-built host application.
It’s analogous to the approach above - if you have multiple hosts in the cluster, multiple ZIP files will be created.
You can configure and build it like this:
❯ nomi cluster configure -c MyShopMonolith --nuget-server-name "Feedz.io"
❯ nomi cluster build -c MyShopMonolith --output d:\NomirunYou need to specify the
--host-platformand--outputwhere all the ZIP files are stored.
This is particularly useful when you want to build a single host from the CI/CD pipeline.
To build container image for a single host, you can use the following command:
❯ nomi cluster build-host -c MyShopMonolith -h BillingHost --host-type Container --docker-image-tag v1.0To build a standalone host, you can use the following command:
❯ nomi cluster build-host -c MyShopMonolith -h BillingHost --host-type Standalone -o c:\hosts