Docker build image#
The CI build steps are run in a docker container. Running the build steps inside a container has several advantages. One of them is the ability to create reproducible builds. This is done by defining the the docker image and tag to be used by the pipeline inside the pipeline files. If in the future we want to build an old commit then we exactly know which docker image and tag we should use. Furthermore we can also easily debug a failing build by running the container locally on our machine.
Dockerfile#
The dockerfile can be found at .teamcity\Dockerfile\Dockerfile and is displayed below as well.
# escape=`
FROM mcr.microsoft.com/windows/server:ltsc2022
LABEL maintainer="sunny.titus@deltares.nl"
ARG PIXI_VERSION=v0.34.0
## Setup user
USER "NT Authority\System"
# Install .NET 4.8
ADD https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe /ndp48-x86-x64-allos-enu.exe
RUN C:\ndp48-x86-x64-allos-enu.exe /quiet /install && del C:\ndp48-x86-x64-allos-enu.exe
## Install chocolatey
ENV ChocolateyUseWindowsCompression false
RUN powershell Set-ExecutionPolicy Bypass -Scope Process -Force;`
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;`
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
## Install useful packages
RUN choco install -y --no-progress `
git.install `
powershell-core
## Install Pixi
RUN ["powershell", "iwr -useb https://pixi.sh/install.ps1 | iex"]
CMD [ "cmd" ]
How to build#
A prerequisite of building the image is that you have Docker Desktop installed on your machine. Once installed open a console and navigate to the folder where the dockerfile resides.
To build the image:
docker context use desktop-windows
docker build -t windows-pixi:34.0 . -m 2GB
The image tag is not randomly chosen. It matches the Pixi version shipped with the image. So make sure the tag equals the version inside the dockerfile.
Updating the Pixi version#
Updating the Pixi version is easy. In the dockerfile there is an argument called PIXI_VERSION
. Change this and follow the steps at How to build to rebuild the image. Don’t forget to add the correct tag
Pushing the image#
Once build you can upload it to the Deltares repository. To do this you do need to have the required credentials.
The first step is to connect to the docker registry. You only have to do this once. The settings thereafter will be stored on your machine. To connect you need your email address and your cli secret. The secret can be found here by clicking on your username in the top right, and then selecting your user profile.
To connect:
docker login -u <<deltares_email>> -p <<cli_secret>> https://containers.deltares.nl
After you connected to the registry you can tag and push your image:
docker tag windows-pixi:34.0 containers.deltares.nl/hydrology_product_line_imod/windows-pixi:34.0
docker push containers.deltares.nl/hydrology_product_line_imod/windows-pixi:34.0
Again, make sure the tags match the PIXI_VERSION
inside the dockerfile.