i’m desperate in need of help :(.
Oke, so i’m trying to deploy microservices to a local docker server. My attempt is that the ci/cd pipeline will do a docker build and then a docker push to the registery so my docker server can simply do a docker pull.
My first attempt works when using the shell executer. I have setup a vm as build server with all the tools installed that I need. → works like a charm
However i’d like to insert semantic release to my pipeline and transfer to docker executer.
Now the very very first attempt was already with the docker executer and that part failed.
Why? because my deployment part used the docker image which is necessary to use docker build Dockerfile; but in .net dockerfile includes dotnet publish command so I was continiously getting the error dotnet command not found.
Now I tought hey I can replicate my build server in my pipeline with a alpine image or in my case I used ubuntu. So In my deployment part I used ubuntu image installed docker and dotnet and the went on with my deployment script. → failed yet again :(.
my yaml: → script is what it needs to do and before script was trying to replicate build server and yes I know it’s complex.
image: Microsoft Artifact Registry
stages:
- build
- test
- deploy
before_script:- dotnet restore Test.sln
build:
stage: buildtags:
- devscript:
- ‘dotnet build --no-restore Test.sln’tests:
stage: testtags:
- dev
script:
- ‘dotnet test --no-restore Test.sln’deploy:
stage: deploytags:
- dev
image: ubuntu:20.04
before_script:
- ‘echo installing prequisites’
- ‘apt update && apt upgrade -y’
- ‘apt install wget -y’
- ‘apt install curl -y’
- ‘echo done updating - installing dotnet’
- ‘wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb’
- ‘dpkg -i packages-microsoft-prod.deb’
- ‘rm packages-microsoft-prod.deb’
- ‘echo installing docker’
- ‘apt update’
- ‘apt install ca-certificates gnupg lsb-release -y’
- ‘mkdir -p /etc/apt/keyrings’
- ‘curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg’
- ‘echo “deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] Index of linux/ubuntu/ $(lsb_release -cs) stable” | tee /etc/apt/sources.list.d/docker.list > /dev/null’
- ‘apt update’
- ‘apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y’
- ‘docker --version’
- ‘apt update’
- ‘apt install docker-compose -y’
- ‘docker-compose --version’
- ‘echo done with prequicites’
script:
- ‘docker-compose build’
- ‘echo $dockerHub >> pw.txt’
- ‘cat pw.txt | docker login --username technologyresearcher --password-stdin’
- ‘docker push technologyresearcher/test:latest’
- ‘rm pw.txt’
The problem here is that docker-compose build gives my python errors which I don’t heck know about, but since it is throwing me filenotfound I assume it is search for something, or in this case I think it is stuck on connecting to the outside.
Oke, so What i’m looking for is A) what is the error how can I fix this?
B) if i’m doing it totally wrong, give some information, guides, any internet source cause, I don’t find any sources to deploy with gitlab and microservices at the same time.
EDIT:
so after alternating my yaml file the first attempt I had a problem on docker info.
when removing that I have got this and this is exactly what it tought it would do.
I think this is because the dockerfile contains a dotnet command which cannot be found inside the docker image
EDIt EDit:
Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY [“Test/Test.csproj”, “Test/”]
RUN dotnet restore “Test/Test.csproj”
COPY . .
WORKDIR “/src/Test”
RUN dotnet build “Test.csproj” -c Release -o /app/buildFROM build AS publish
RUN dotnet publish “Test.csproj” -c Release -o /app/publish /p:UseAppHost=falseFROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [“dotnet”, “Test.dll”]