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

[feat]Build multi-architecture Docker images for Python agent #297

Merged
merged 10 commits into from
Apr 1, 2023

Conversation

jiang1997
Copy link
Contributor

@jiang1997 jiang1997 commented Mar 17, 2023

@jiang1997
Copy link
Contributor Author

I have simply tried docker build buildx by referring to apache/skywalking-eyes#132 .
But it turns out that skywalking-python can't be installed directly on linux/arm64.

 => => extracting sha256:a2ae4d14db5909da83c9bbe5296aa28df736473d058728285f074eda6e427b0e                                                                      0
 => [linux/amd64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0"                                                                         26
 => ERROR [linux/arm64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0"                                                                   10
------                                                                                                                                                          
 > [linux/arm64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0":                                                                           
#0 8.577 ERROR: Exception:
#0 8.577 Traceback (most recent call last):
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
#0 8.577     status = run_func(*args)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
#0 8.577     return func(self, options, args)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 285, in run
#0 8.577     session = self.get_default_session(options)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 75, in get_default_session

To delve deeper, I'll be creating a Linux/ARM64 environment.

@Superskyyy
Copy link
Member

Superskyyy commented Mar 17, 2023

Welcome back! Please remember to add a changelog for this feature.

@Superskyyy Superskyyy added this to the 1.1.0 milestone Mar 17, 2023
@Superskyyy Superskyyy added the feature New feature label Mar 17, 2023
@Superskyyy
Copy link
Member

I cant tell what's wrong from the traceback you posted though.

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can build locally when I set the VERSION=1.0.0 (make build-image VERSION=1.0.0) so you might want to update your repo and set the same version.

  • We should also verify this in CI:
    • Build docker images without pushing to remote registry in PR checks, with make build-image.
    • Build and push images to ghcr.io with make push-image, example

docker/Makefile Outdated Show resolved Hide resolved
docker/Makefile Outdated Show resolved Hide resolved
@jiang1997
Copy link
Contributor Author

I have simply tried docker build buildx by referring to apache/skywalking-eyes#132 . But it turns out that skywalking-python can't be installed directly on linux/arm64.

 => => extracting sha256:a2ae4d14db5909da83c9bbe5296aa28df736473d058728285f074eda6e427b0e                                                                      0
 => [linux/amd64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0"                                                                         26
 => ERROR [linux/arm64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0"                                                                   10
------                                                                                                                                                          
 > [linux/arm64 2/2] RUN pip install --no-cache-dir "apache-skywalking[grpc]==0.8.0":                                                                           
#0 8.577 ERROR: Exception:
#0 8.577 Traceback (most recent call last):
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
#0 8.577     status = run_func(*args)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
#0 8.577     return func(self, options, args)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 285, in run
#0 8.577     session = self.get_default_session(options)
#0 8.577   File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 75, in get_default_session

To delve deeper, I'll be creating a Linux/ARM64 environment.

solved according to this docker/buildx#464 (comment)

@jiang1997
Copy link
Contributor Author

jiang1997 commented Mar 18, 2023

I can build locally when I set the VERSION=1.0.0 (make build-image VERSION=1.0.0) so you might want to update your repo and set the same version.

  • We should also verify this in CI:

    • Build docker images without pushing to remote registry in PR checks, with make build-image.
    • Build and push images to ghcr.io with make push-image, example

When building a new docker image with CI, would it be better to use the local skywalking-python package instead of the one provided by PyPI?

@kezhenxu94
Copy link
Member

I can build locally when I set the VERSION=1.0.0 (make build-image VERSION=1.0.0) so you might want to update your repo and set the same version.

  • We should also verify this in CI:
  • Build docker images without pushing to remote registry in PR checks, with make build-image.
  • Build and push images to ghcr.io with make push-image, example

When building a new docker image with CI, would it be better to use the local skywalking-python package instead of the one provided by PyPI?

Yes sure we should use the local skywalking Python package because that's what we want to verify.

@jiang1997 jiang1997 changed the title [wip]Build multi-architecture Docker images for Python agent [feat]Build multi-architecture Docker images for Python agent Mar 19, 2023
@jiang1997 jiang1997 marked this pull request as ready for review March 19, 2023 19:21
@jiang1997
Copy link
Contributor Author

For now, the version number has to be set inside publish-docker.yaml.

.github/workflows/publish-docker.yaml Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
@jiang1997 jiang1997 force-pushed the multi-architecture branch 3 times, most recently from 0c73ead to 36c5c45 Compare March 20, 2023 16:04
docker/Makefile Show resolved Hide resolved
.github/workflows/publish-docker.yaml Outdated Show resolved Hide resolved
.github/workflows/publish-docker.yaml Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
run: |
make push-image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build and push locally and hours passed it is still running, I think we can parallize this by adding make -j 10 push-image?

Copy link
Contributor Author

@jiang1997 jiang1997 Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried make -j 10 push-image, but seems that docker buildx can't run parallel.
Firstly, container skywalking_python_main can't be shared between parallel building tasks, secondly, even though we create target-specific containers, because this line works at system level, CI still runs into errors.

After some digging, I found that the most time-consuming step is building gRPC related whl packages when building image for arm64 python3.11. Cuz there is no needed binary whl package off the shelf so far. grpc/grpc#32454

Copy link
Contributor Author

@jiang1997 jiang1997 Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered that with the --builder option in Docker, we can make multiple targets simultaneously, but not to much(with make -j 10 may run out of disk space).
Compared with non-parallel building, we can save about 10 minutes.

kezhenxu94
kezhenxu94 previously approved these changes Mar 25, 2023
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed this PR to a branch in the repo and the workflow is verified to work, @Superskyyy wanna check the images number?

https://github.com/apache/skywalking-python/pkgs/container/skywalking-python%2Fskywalking-python

push-py3.8-slim: BASE_PYTHON_IMAGE = python:3.8-slim
push-py3.9-slim: BASE_PYTHON_IMAGE = python:3.9-slim
push-py3.10-slim: BASE_PYTHON_IMAGE = python:3.10-slim
push-py3.11-slim: BASE_PYTHON_IMAGE = python:3.11-slim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove this ? You removed 3.11 in the TARGETS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay to remove it. I'm reserving it for future needs.

@Superskyyy Superskyyy merged commit 128278a into apache:master Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants