Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make CLRIE builds possible on Alpine linux #450

Closed
sanikolov opened this issue Oct 19, 2021 · 16 comments
Closed

make CLRIE builds possible on Alpine linux #450

sanikolov opened this issue Oct 19, 2021 · 16 comments

Comments

@sanikolov
Copy link

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'
@jander-msft
Copy link
Member

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

@delmyers
Copy link
Contributor

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

@jander-msft
Copy link
Member

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.

@sanikolov
Copy link
Author

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.

@delmyers
Copy link
Contributor

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.

@sanikolov
Copy link
Author

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

@jander-msft
Copy link
Member

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.

@delmyers
Copy link
Contributor

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

@sanikolov
Copy link
Author

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

@sanikolov
Copy link
Author

ping, plz post an update here if you have one

@sanikolov
Copy link
Author

@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.

@delmyers
Copy link
Contributor

delmyers commented Dec 8, 2022

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.

@sanikolov
Copy link
Author

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

@jander-msft
Copy link
Member

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

@delmyers
Copy link
Contributor

delmyers commented Dec 8, 2022

@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

@sanikolov
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants