microsoft / CLRInstrumentationEngine

The CLR Instrumentation Engine is a cooperation profiler that allows running multiple profiling extensions in the same process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

make CLRIE builds possible on Alpine linux

sanikolov opened this issue · comments

This is a market driven requirement.
The following odd image + clang combination may prove useful to get you there quicker.

docker pull alpine:3.11      # min version where .net5.0 is supported by MSFT
apk add --no-cache bash sudo openssl xz git make musl-dev ca-certificates g++ wget
# manually add (append)   http://dl-cdn.alpinelinux.org/alpine/v3.6/main   to /etc/apk/repositories
apk add 'clang=4.0.0-r0'

CLRIE is already built on Alpine using an image built from the following Docker file: https://github.com/microsoft/CLRInstrumentationEngine/blob/main/src/unix/docker/dockerfiles/build/alpine/Dockerfile

I tried this locally recently, and I think that the base image that we are using for that docker file no longer exists.

I tried this locally recently, and I think that the base image that we are using for that docker file no longer exists.

Yup, those were deleted. See dotnet/dotnet-docker#2848

We just need to choose an appropriate base image from https://mcr.microsoft.com/v2/dotnet-buildtools/prereqs/tags/list, but probably something that is still maintained from this manifest: https://github.com/dotnet/dotnet-buildtools-prereqs-docker/blob/main/manifest.json

Or we can build our own with minimal dependencies and not have to use an arbitrary base image from the dotnet-buildtools/prereqs repo.

Great. Can you publish a spec for the Dockerfile that you end up defining?
It will keep our CI from breaking in case the image disappears from both the remote docker host and the local cache.

Or we can build our own with minimal dependencies and not have to use an arbitrary base image from the dotnet-buildtools/prereqs repo.

Is that base image arbitrary? I think it was just based on the version of alpine that we were trying to support a couple of years back. Probably time to update since it seems that the clr is no longer supporting it. Will we have to update our PAL as well?

When you say that we could build our own, do you mean, "build our own and put it on a public feed"? We still use a pre-built image for our internal builds.

Any alternatives to https://proddiagbuild.azurecr.io/v2/clrie-build-alpine/manifests/latest?

docker run --name clrie-build 
-v c:/tmp/CLRInstrumentationEngine/src:/root/ClrInstrumentationEngine/src:ro
-v c:/tmp/CLRInstrumentationEngine/tools:/root/ClrInstrumentationEngine/tools:ro
-v c:/tmp/CLRInstrumentationEngine/inc:/root/ClrInstrumentationEngine/inc:ro
-v c:/tmp/CLRInstrumentationEngine/build:/root/ClrInstrumentationEngine/build:ro 
--net=host proddiagbuild.azurecr.io/clrie-build-alpine:latest bash 
/root/ClrInstrumentationEngine/src/build.sh x64 Release clean
Unable to find image 'proddiagbuild.azurecr.io/clrie-build-alpine:latest' locally
docker: Error response from daemon: Head 
"https://proddiagbuild.azurecr.io/v2/clrie-build-alpine/manifests/latest": 
unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.

Also

C:\tmp\CLRInstrumentationEngine\src\unix\docker\dockerfiles\build\alpine>docker build .
[+] Building 2.2s (4/4) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 3.03kB                                                                             0.0s
 => [internal] load .dockerignore                                                                                  0.1s
 => => transferring context: 2B                                                                                    0.0s
 => ERROR [internal] load metadata for docker.io/microsoft/dotnet-buildtools-prereqs:alpine-3.6-3148f11-201711190  2.0s
 => [auth] microsoft/dotnet-buildtools-prereqs:pull token for registry-1.docker.io                                 0.0s
------
 > [internal] load metadata for docker.io/microsoft/dotnet-buildtools-prereqs:alpine-3.6-3148f11-20171119021156:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, 
repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Or we can build our own with minimal dependencies and not have to use an arbitrary base image from the dotnet-buildtools/prereqs repo.

Is that base image arbitrary? I think it was just based on the version of alpine that we were trying to support a couple of years back. Probably time to update since it seems that the clr is no longer supporting it. Will we have to update our PAL as well?

At the time, it was not arbitrary. It was probably whatever dotnet was using to build their musl binaries at that time. But that image is probably long out of support and no longer used. From what I can tell, it doesn't exist in https://mcr.microsoft.com/v2/dotnet-buildtools/prereqs/tags/list in some equivalent manner.

When you say that we could build our own, do you mean, "build our own and put it on a public feed"? We still use a pre-built image for our internal builds.

I would say that we create Dockerfiles that are checked into the repo that use publicly available packages and images. Everyone can then use those Dockerfiles and build the images as they see fit. We can probably use the images produced from dotnet/dotnet-docker as our base images and build on top of those.

I would say that we create Dockerfiles that are checked into the repo that use publicly available packages and images. Everyone can then use those Dockerfiles and build the images as they see fit. We can probably use the images produced from dotnet/dotnet-docker as our base images and build on top of those.

I think that that base image was publicly available but has just been deleted. According to this blog post: https://techcommunity.microsoft.com/t5/azure-developer-community-blog/deprecating-the-distribution-of-microsoft-container-images-via/ba-p/2366861, the dotnet team is deprecating the use of the base images from dockerhub, though. The Microsoft Container Registry should be used instead.

@sanikolov, you should be able to use that Dockerfile almost as-is to build on alpine. You will just have to change the base image at the top. This page: https://github.com/dotnet/dotnet-buildtools-prereqs-docker tells you what images are available to build with.

We can probably just replace the base image at the top with this:

mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.6-3e800f1-20190506161422

hmm still getting errors, unrelated to the image

C:\tmp\CLRInstrumentationEngine>powershell -file src\Scripts\DockerLocalBuild.ps1 musl
Executing inside container using docker image
'mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.6-3e800f1-20190506161422'
Unable to find image 'mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.6-3e800f1-20190506161422' 
locally alpine-3.6-3e800f1-20190506161422: Pulling from dotnet-buildtools/prereqs
5a3ea8efae5d: Pull complete
c531a8f53d2d: Pull complete
5042c3b814d0: Pull complete
1aadd4defbcb: Pull complete
Digest: sha256:3298495d462e7157de7fc684fe676497460a96543bebb1f6f2c4a1406d49a412
Status: Downloaded newer image for mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.6-3e800f1-20190506161422
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container
 process caused: exec: "/root/ClrInstrumentationEngine/src/build.sh": 
 stat /root/ClrInstrumentationEngine/src/build.sh: no such file or directory: unknown.

Also

C:\tmp\CLRInstrumentationEngine\src\Scripts>powershell -file DockerLocalBuild.ps1 C:\tmp\CLRInstrumentationEngine musl Debug
Executing inside container using docker image
 'mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.6-3e800f1-20190506161422'
Cleaning previous output for the selected configuration
Setting up directories for build
Checking pre-requisites...
found cmake version 3.8.1
Insufficient cmake version. Ensure cmake version 3.14 or later is installed

ping, plz post an update here if you have one

@WilliamXieMSFT
Can you publish the CLRIE binaries for Alpine the same way you publish windows MSIs and merge modules?
Alternatively, if you can provide the Dockerfile definitions I can build these binaries myself.

There is a docker file for building on alpine. It can be found in /src/unix/docker/dockerfiles/.

I just used this command to build a local image: cat /mnt/e/dd/CLRInstrumentationEngine/src/unix/docker/dockerfiles/alpine/Dockerfile | sudo docker build -t 'alpineclrie' -f - '/mnt/e/dd/CLRInstrumentationEngine
/src/unix/docker/context/'

(Note, the docker context is needed in order to pull in all of the additional prerequisites that we need).

From there, you should be able to create a container. Note, our build scripts are picky about where the clrie source lives. Mount your CLRIE repository root to /root/ClrInstrumentationEngine when creating the container.

I have not run a build on it yet, so I don't know if it will work. Good luck.

Thanks. Unfortunately I get

 => ERROR [internal] load metadata for docker.io/microsoft/dotnet-buildtools-prereqs:alpine-3.6-3148f11-20171119021156
failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

I think your branch is out of date. The Dockerfile at https://github.com/microsoft/CLRInstrumentationEngine/blob/main/src/unix/docker/dockerfiles/build/alpine/Dockerfile uses mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.13-20211214164113-8a6f4f3

@sanikolov Looks like you are running on Windows with docker? I was able to get a musl build using this powershell command. Note: I am doing this in a box with WSL ubuntu + docker installed.

.\DockerLocalBuild.ps1 -CLib musl -BuildDockerImage -RebuildImage -Wsl

Thank you both.
The branch was indeed not up-to-date and I had wsl1 on the dev box, instead of wsl2.
Build was successful on a more recent VM image.
Closing issue.