Stuck on ci/cd

So i’m stuck at my ci/cd pipeline on a dotcore (.net5.0) application i made.

The problem i’m stuck at is testing: my pipline fails because i have got a sqlexception aka it cannot connect to the sql server.

My application consists of 4 containers including database container.
The application works perfectly on my computer under docker for desktop with linux containers.

my idea deploy the application to a custom docker compose.

I have a virtual machine running gitlab( latest version of writing today)
I have a docker-compose virtual machine with ms sql server installed on it.

Server=192.168.0.241,1433;Database=Portfolio;Integrated Security=false;MultipleActiveResultSets=true;User Id=sa;Password=password

my connectionstring. → I have learned for the server it has to be the ipaddress of the host machine as for docker it contacts the sql server which is running on the host machine and not the sql image container.

I assume in production I have to change this ipaddress to the address of my docker-compose container.

my current ci/cd file:

image: mcr.microsoft.com/dotnet/sdk:5.0

stages:

  • build
  • test
  • deploy

variables:
publishdir: “bin/release/”

build:
stage: build
tags:
- dev
script:
- “dotnet build Portfolio-Frontend/Portfolio-Frontend.sln”
artifacts:
expire_in: 1 week
paths:
- “bin”

test:
stage: test
tags:
- dev

script:
- “dotnet test Portfolio-Frontend/Portfolio-Frontend.sln”
- echo “testing”

deploy:
stage: deploy
tags:
- dev
variables:
deploy_path: “src/App/”
only:
- dev
artifacts:
paths:
- src/App/bin/release
expire_in: 1 week
script:

cd to where csproj is

  • cd $deploy_path

publish the files - this will generate the publish files in bin/release

  • dotnet publish -c release

my build succeeds and my test fails
error:
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)

for deploying on docker i checked this: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

What should I do to fix this kind of error.

Any other information or guide to deploy ci/cd with sql server would be very appreciated.

I don’t find usefull information on google to this matter.