You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by yi...@apache.org on 2023/04/01 05:27:02 UTC
[skywalking-python] branch master updated: [feat]Build multi-architecture Docker images for Python agent (#297)
This is an automated email from the ASF dual-hosted git repository.
yihaochen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
The following commit(s) were added to refs/heads/master by this push:
new 128278a [feat]Build multi-architecture Docker images for Python agent (#297)
128278a is described below
commit 128278a1d61b6a92e67ee9c67cc2836a91370bbc
Author: jiang1997 <ji...@live.cn>
AuthorDate: Sat Apr 1 13:26:56 2023 +0800
[feat]Build multi-architecture Docker images for Python agent (#297)
Co-authored-by: 吴晟 Wu Sheng <wu...@foxmail.com>
---
.github/workflows/publish-docker.yaml | 51 +++++++++++++++++++++++++++++++++++
CHANGELOG.md | 3 +++
docker/Dockerfile | 19 ++++++++-----
docker/Makefile | 47 +++++++++++++++++++++++++++++---
4 files changed, 111 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml
new file mode 100644
index 0000000..2b033e1
--- /dev/null
+++ b/.github/workflows/publish-docker.yaml
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: publish-docker
+
+on:
+ push:
+ branches:
+ - master
+
+env:
+ HUB: ghcr.io/apache/skywalking-python
+ PROJECT: skywalking-python
+
+jobs:
+ build-docker:
+ if: github.repository == 'apache/skywalking-python'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ timeout-minutes: 120
+ env:
+ VERSION: ${{ github.sha }}
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Log in to the Container registry
+ uses: docker/login-action@v1.10.0
+ with:
+ registry: ${{ env.HUB }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Build and push docker image
+ run: |
+ make push-image -j 5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 155526f..cb1aee1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
### 1.1.0
+- Feature:
+ - Add a new workflow to push docker images for arm64 and amd64
+
### 1.0.0
- **Important Note and Breaking Changes:**
diff --git a/docker/Dockerfile b/docker/Dockerfile
index b2a4f7a..b98cf1c 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -15,13 +15,20 @@
# limitations under the License.
ARG BASE_PYTHON_IMAGE
+ARG BUILDER_PYTHON_IMAGE
+FROM ${BASE_PYTHON_IMAGE} AS base
-FROM ${BASE_PYTHON_IMAGE}
-
-ARG SW_PYTHON_AGENT_PROTOCOL
-ARG SW_PYTHON_AGENT_VERSION
-
-RUN pip install --no-cache-dir "apache-skywalking[${SW_PYTHON_AGENT_PROTOCOL}]==${SW_PYTHON_AGENT_VERSION}"
+FROM ${BUILDER_PYTHON_IMAGE} AS builder
+RUN pip install --upgrade pip
+RUN pip install poetry
+COPY ./ /tmp/
+RUN make -C /tmp package
+RUN pip wheel psutil -w /tmp/dist/
+FROM base AS final
+COPY --from=builder /tmp/dist/*.whl /tmp/
+RUN pip install --upgrade pip
+RUN pip install /tmp/psutil*.whl /tmp/apache_skywalking*.whl
+RUN rm /tmp/apache_skywalking*.whl /tmp/psutil*.whl
# So that the agent can be auto-started when container is started
ENTRYPOINT ["sw-python"]
diff --git a/docker/Makefile b/docker/Makefile
index 23c655d..c900c8b 100644
--- a/docker/Makefile
+++ b/docker/Makefile
@@ -14,11 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+HUB ?= docker.io/apache
+PROJECT ?= skywalking-python
+
D := docker
P := grpc http kafka
-TARGETS := py3.7 py3.8 py3.9 py3.10 py3.11 py3.7-slim py3.8-slim py3.9-slim py3.10-slim py3.11-slim
+TARGETS := py3.7 py3.8 py3.9 py3.10 py3.7-slim py3.8-slim py3.9-slim py3.10-slim
py3.7: BASE_PYTHON_IMAGE = python:3.7
py3.8: BASE_PYTHON_IMAGE = python:3.8
@@ -31,24 +34,62 @@ py3.9-slim: BASE_PYTHON_IMAGE = python:3.9-slim
py3.10-slim: BASE_PYTHON_IMAGE = python:3.10-slim
py3.11-slim: BASE_PYTHON_IMAGE = python:3.11-slim
+push-py3.7: BASE_PYTHON_IMAGE = python:3.7
+push-py3.8: BASE_PYTHON_IMAGE = python:3.8
+push-py3.9: BASE_PYTHON_IMAGE = python:3.9
+push-py3.10: BASE_PYTHON_IMAGE = python:3.10
+push-py3.11: BASE_PYTHON_IMAGE = python:3.11
+push-py3.7-slim: BASE_PYTHON_IMAGE = python:3.7-slim
+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
+
+push-py3.7: BUILDER_PYTHON_IMAGE = python:3.7
+push-py3.8: BUILDER_PYTHON_IMAGE = python:3.8
+push-py3.9: BUILDER_PYTHON_IMAGE = python:3.9
+push-py3.10: BUILDER_PYTHON_IMAGE = python:3.10
+push-py3.11: BUILDER_PYTHON_IMAGE = python:3.11
+push-py3.7-slim: BUILDER_PYTHON_IMAGE = python:3.7
+push-py3.8-slim: BUILDER_PYTHON_IMAGE = python:3.8
+push-py3.9-slim: BUILDER_PYTHON_IMAGE = python:3.9
+push-py3.10-slim: BUILDER_PYTHON_IMAGE = python:3.10
+push-py3.11-slim: BUILDER_PYTHON_IMAGE = python:3.11
+
PUSH_TARGETS := $(TARGETS:%=push-%)
build: $(TARGETS)
push: $(PUSH_TARGETS)
+
+
$(TARGETS):
+ cd ..; \
for p in $(P); do \
$(D) build $(SW_BUILD_ARGS) \
+ -f docker/Dockerfile \
--build-arg BASE_PYTHON_IMAGE=$(BASE_PYTHON_IMAGE) \
--build-arg SW_PYTHON_AGENT_PROTOCOL=$$p \
--build-arg SW_PYTHON_AGENT_VERSION=${AGENT_VERSION} \
- -t apache/skywalking-python:${AGENT_VERSION}-$$p-$@ \
+ -t $(HUB)/$(PROJECT):${AGENT_VERSION}-$$p-$@ \
. ; \
done
$(PUSH_TARGETS):
$(eval version := $(subst push-,,$@))
+ docker buildx create --driver docker-container --name skywalking_python_main_$(version) > /dev/null 2>&1 || true;
+ cd ..; \
for p in $(P); do \
- $(D) push apache/skywalking-python:${AGENT_VERSION}-$$p-${version}; \
+ $(D) buildx build $(SW_BUILD_ARGS) \
+ --builder skywalking_python_main_$(version) \
+ -f docker/Dockerfile \
+ --platform linux/amd64,linux/arm64 --push \
+ --build-arg BASE_PYTHON_IMAGE=$(BASE_PYTHON_IMAGE) \
+ --build-arg BUILDER_PYTHON_IMAGE=$(BUILDER_PYTHON_IMAGE) \
+ --build-arg SW_PYTHON_AGENT_PROTOCOL=$$p \
+ --build-arg SW_PYTHON_AGENT_VERSION=${AGENT_VERSION} \
+ -t $(HUB)/$(PROJECT):${AGENT_VERSION}-$$p-${version} \
+ . ; \
done
+ docker buildx rm skywalking_python_main_$(version) || true;