Skip to content

Configuring Docker

The Suite 3.0 uses Docker to run the services. There is already a development deployment configuration that allows developers to run all the services locally as in a k3s cluster. We need to add our components: the microservice, the application service and the Backend for Frontend to that deployment configuration so we, and all teams working on the Suite, can run them.

The configuration for Docker will also be use to run our microservice in development and staging environments.

Before continuing, ensure you have read and followed the development deployment. You need to have the cluster up and running in order to deploy our new service.

Configuring the Image Build

The building information for a service is configured on a file called container-build.hcl that must be saved on the root folder of each service project. This file contains all the parameters that will be used to issue a docker build command, using docker buildx bake. The Suite takes care of all this, we just need to provide the hcl file.

Lets start with the Equipments microservice. Since we created the service with the Suite Framework template, we already have the file. We need to set a correct IMAGE_NAME, in this case, we use the name of the services, all in lowercase. The CSPROJ_PATH and RUNTIME_DLL variables should already be set correctly:

Terraform
target "equipments" {
    inherits = ["default-service"]

    tags = [
        "${REGISTRY_NAME}/equipments:${TAG_NAME}",
        "${REGISTRY_NAME}/equipments:${TAG_VERSION}"
    ]

    contexts = {
        binaries = "src/services/Equipments/ITsynch.Suite.Equipments.Application/bin/${BUILD_CONFIGURATION}"
    }

    args = {
        RUNTIME_DLL = "ITsynch.Suite.Equipments.Application.dll"
        CSPROJ_PATH = "src/services/Equipments/ITsynch.Suite.Equipments.Application/ITsynch.Suite.Equipments.Application.csproj"
    }
}

Similarly, the EMA.Bff project will have the container-build.hcl file thanks to the bff template. We are going to call the service ema-bff, and make sure the path an DLL name are correct:

Terraform
target "ema-bff" {
    inherits = ["default-service"]

    tags = [
        "${REGISTRY_NAME}/ema-bff:${TAG_NAME}",
        "${REGISTRY_NAME}/ema-bff:${TAG_VERSION}"
    ]

    contexts = {
        binaries = "src/services/EMA/ITsynch.Suite.EMA.Bff/bin/${BUILD_CONFIGURATION}"
    }

    args = {
        RUNTIME_DLL = "ITsynch.Suite.EMA.Bff.dll"
        CSPROJ_PATH = src/services/EMA/ITsynch.Suite.EMA.Bff/ITsynch.Suite.EMA.Bff.csproj"
    }
}

Finally for our EMA.Application service, we do not have a pre-configured file because it is not included on the template. We just need to add it by hand and put the correct content in it:

Terraform
target "ema-app" {
    inherits = ["default-service"]

    tags = [
        "${REGISTRY_NAME}/ema-app:${TAG_NAME}",
        "${REGISTRY_NAME}/ema-app:${TAG_VERSION}"
    ]

    contexts = {
        binaries = "src/services/EMA/ITsynch.Suite.EMA.Application/bin/${BUILD_CONFIGURATION}"
    }

    args = {
        RUNTIME_DLL = "ITsynch.Suite.EMA.Application.dll"
        CSPROJ_PATH = "src/services/EMA/ITsynch.Suite.EMA.Application/ITsynch.Suite.EMA.Application.csproj"
    }
}

Adding our services to the Kubernetes deployment

In order to run our services in the local development environment, we need to generate the Kubernetes manifests to do so.

Now, we need to run the following commands inside an activated deployment container.

Bash
1
2
3
cd deployment
./activate.sh
# wait for the container to open up the zsh shell..

We can use the suite-gen-app script to generate the manifests for our application.

Bash
1
2
3
suite-gen-app backend-service equipments
suite-gen-app backend-service ema-app
suite-gen-app bff ema-bff

You should review the new manifests created inside deployment/k8s/applications/equipments, deployment/k8s/applications/ema-app and deployment/k8s/applications/ema-bff. Next, as the development deployment instructs, review and change the Ingress host name to ema-bff inside the `deployment/k8s/applications/ema-bff/ingress.yaml file.

Adding the services to the localdev deployment

Once you have reviewed the manifests, we need add them to the localdev deployment, in order to get started quickly we'll add them to the hub. These manifests need to be linked into the applications kustomization file that will get deployed when we run the suite-installer. If you have just deployed a cluster following the development deployment guide you should modify the deployment/k8s/environments/localdev/hub/teams/landings since you ran it with --apps=./k8s/environments/localdev/hub/teams/landings

Edit the kustomization file to add the service, app and bff to the resources field.

Running the services in kubernetes

You can use the Suite Installer or suite-apply to deploy your service. Feel free to just run the installer again and let it take care, or run suite-apply against your kustomization file which should be faster.

Once they are deployed,we can check the status using kubectl get pod and looking for our services. They should be healthy and ready and we should be able to access them using the Ingress we declared, so we should be able to access https://ema-bff.localdev.suite.itsynch.com/graphql/ and see the GraphQL playground of the BFF running on Docker.