I am trying to understand how one is supposed compile+test a dotnet 7 project (no ASP).
According to documentation:
I can only find dotnet runtime pre-installed:
FROM public.ecr.aws/lambda/dotnet:7
Looking at the typical template in gitlab:
a reference image with sdk pre-installed is used:
image: microsoft/dotnet:latest
Which image should one use to build/test/deploy code that is suppose to run on public.ecr.aws/lambda/dotnet:7
? Here is what I see on my side:
> docker run -it --entrypoint /var/lang/bin/dotnet public.ecr.aws/lambda/dotnet:7 --info
Host:
Version: 7.0.7
Architecture: x64
Commit: 5b20af47d9
.NET SDKs installed:
No SDKs were found.
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.7 [/var/lang/bin/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.7 [/var/lang/bin/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/var/lang/bin]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Obviously I could use mcr.microsoft.com/dotnet/sdk:7.0
as base image for compilation, do the publish step, store as artefact, then load public.ecr.aws/lambda/dotnet:7
load artefacts from previous step and then eventually do the testing...but that seems overly complex to setup.
Simple solution is to build it during a pre-build stage of gitlab-ci:
stages:
- image
- build
- test
- deploy
Prepare docker image:
stage: image
image: docker:stable
tags:
- dind
- linux
only:
changes:
- docker/Dockerfile
script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --build-arg BUILDKIT_INLINE_CACHE=1
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA docker
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
where Dockerfile is simply:
FROM amazonlinux:2
ARG SDK_VERSION=6.0
ENV SDK_VERSION=$SDK_VERSION
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-sdk-$SDK_VERSION