You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/09/09 02:57:28 UTC

[skywalking-python] branch master updated: Add dockerfile and image releasing scripts (#159)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 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 64e7ee7  Add dockerfile and image releasing scripts (#159)
64e7ee7 is described below

commit 64e7ee75823fd19a422418a174f951a54e93843d
Author: Superskyyy <Su...@outlook.com>
AuthorDate: Wed Sep 8 22:57:25 2021 -0400

    Add dockerfile and image releasing scripts (#159)
---
 CHANGELOG.md                  |  7 ++---
 Makefile                      |  6 +++++
 README.md                     |  7 +++++
 docker/Dockerfile             | 26 +++++++++++++++++++
 docker/Makefile               | 51 +++++++++++++++++++++++++++++++++++++
 docker/README.md              | 53 ++++++++++++++++++++++++++++++++++++++
 docs/How-to-release-docker.md | 59 +++++++++++++++++++++++++++++++++++++++++++
 docs/How-to-release.md        | 12 ++++-----
 8 files changed, 211 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f9a6c34..323968b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@
     - Support profiling Python method level performance (#127
     - Add a new `sw-python` CLI that enables agent non-intrusive integration (#156)
     - Add exponential reconnection backoff strategy when OAP is down (#157)
-    - Suport ignoring traces by http method (#143)
+    - Support ignoring traces by http method (#143)
     - `NoopSpan` on queue full, propagation downstream (#141)
     - Support agent namespace. (#126)
     - Added `grpc.max_connection_age_grace_ms` (#130)
@@ -27,9 +27,10 @@
     - Fix grpc disconnect, add `SW_AGENT_MAX_BUFFER_SIZE` to control buffer queue size (#138)
 
 - Others:
-    - chore: bump up `requests` version to avoid license issue (#142)
-    - fix module wrapt as normal install dependancy (#123)
+    - Chore: bump up `requests` version to avoid license issue (#142)
+    - Fix module wrapt as normal install dependency (#123)
     - Explicit component inheritance (#132)
+    - Provide dockerfile & images for easy integration in containerized scenarios (#159)
  
 ### 0.6.0
 
diff --git a/Makefile b/Makefile
index e12c92e..6b8cfa3 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,12 @@ upload-test: package
 upload: package
 	twine upload dist/*
 
+build-image:
+	$(MAKE) -C docker build
+
+push-image:
+	$(MAKE) -C docker push
+
 clean:
 	rm -rf skywalking/protocol
 	rm -rf apache_skywalking.egg-info dist build
diff --git a/README.md b/README.md
index d2b0687..97936d8 100755
--- a/README.md
+++ b/README.md
@@ -34,6 +34,13 @@ pip install "apache-skywalking[kafka]"
 pip install apache-skywalking==0.1.0  # For example, install version 0.1.0 no matter what the latest version is
 ```
 
+### From Docker Hub
+
+SkyWalking Python agent provides convenient dockerfile and images for easy integration utilizing its auto-bootstrap
+capability. You can build your Python application image based on our agent-enabled Python images and start
+your applications with SkyWalking agent enabled for you. Please refer to our 
+[dockerfile guide](docker/README.md) for further instructions on building and configurations.
+
 ### From Source Codes
 
 Refer to the [FAQ](docs/FAQ.md#q-how-to-build-from-sources).
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..f610b38
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,26 @@
+# 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.
+
+ARG BASE_IMAGE
+
+FROM ${BASE_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}"
+
+ENTRYPOINT ["sw-python", "run"]
diff --git a/docker/Makefile b/docker/Makefile
new file mode 100644
index 0000000..ac0a059
--- /dev/null
+++ b/docker/Makefile
@@ -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.
+
+D := docker
+
+P := grpc http kafka
+
+TARGETS := py3.5 py3.6 py3.7 py3.8 py3.9
+
+py3.5: BASE_IMAGE = python:3.5
+py3.6: BASE_IMAGE = python:3.6
+py3.7: BASE_IMAGE = python:3.7
+py3.8: BASE_IMAGE = python:3.8
+py3.9: BASE_IMAGE = python:3.9
+
+PUSH_TARGETS := $(TARGETS:%=push-%)
+
+word-dash = $(word $2,$(subst -, ,$1))
+
+build: $(TARGETS)
+push: $(PUSH_TARGETS)
+
+$(TARGETS):
+	for p in $(P); do \
+		$(D) build $(SW_BUILD_ARGS) \
+				--build-arg BASE_IMAGE=$(BASE_IMAGE) \
+				--build-arg SW_PYTHON_AGENT_PROTOCOL=$$p \
+				--build-arg SW_PYTHON_AGENT_VERSION=${AGENT_VERSION} \
+				-t apache/skywalking-python:${AGENT_VERSION}-$$p-$@ \
+				. ; \
+	done
+
+
+$(PUSH_TARGETS):
+	$(eval version := $(call word-dash,$@,2))
+	for p in $(P); do \
+		$(D) push apache/skywalking-python:${AGENT_VERSION}-$$p-${version}; \
+	done
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..b27e416
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,53 @@
+# Apache SkyWalking Python Agent dockerfile and images
+
+**Docker images are not official ASF releases but provided for convenience. Recommended usage is always to build the
+source**
+
+**<img src="http://skywalking.apache.org/assets/logo.svg" alt="SkyWalking logo" height="90px" align="right" />**
+
+**SkyWalking**: an APM(application performance monitor) system, especially designed for microservices, cloud native and
+container-based (Docker, Kubernetes, Mesos) architectures.
+
+[![GitHub stars](https://img.shields.io/github/stars/apache/skywalking.svg?style=for-the-badge&label=Stars&logo=github)](https://github.com/apache/skywalking)
+[![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=for-the-badge&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking)
+
+This image hosts the SkyWalking Python agent package on top of official Python base images providing support from 
+Python 3.5 - 3.9.
+
+## How to use this image
+
+The images are hosted at [Docker Hub](https://hub.docker.com/r/apache/skywalking-python) and available from the `skywalking.docker.scarf.sh` endpoint.
+
+`skywalking.docker.scarf.sh/apache/skywalking-python`
+
+### Build your Python application image on top of this image
+
+Start by pulling the skywalking-python image as the base of your application image.
+Refer to [Docker Hub](https://hub.docker.com/r/apache/skywalking-python) for the list of tags available.
+
+```dockerfile
+FROM apache/skywalking-python:0.7.0-grpc-py3.9
+
+# ... build your Python application
+```
+
+You could start your Python application with `CMD`. For example - `CMD ['gunicorn', 'app.wsgi']` 
+
+You don't need to care about enabling the SkyWalking Python agent manually, 
+it should be adopted and bootstrapped automatically through the `sw-python` CLI.
+
+[Environment variables](../docs/EnvVars.md) can be provided to customize the agent behavior.
+
+### Build an image from the dockerfile 
+
+Provide the following arguments to build your own image from the dockerfile.
+
+```text
+BASE_IMAGE # the Python base image to build upon
+SW_PYTHON_AGENT_VERSION # agent version to be pulled from PyPI
+SW_PYTHON_AGENT_PROTOCOL # agent protocol - grpc/ http/ kafka
+```
+
+## License
+
+[Apache 2.0 License.](/LICENSE)
diff --git a/docs/How-to-release-docker.md b/docs/How-to-release-docker.md
new file mode 100644
index 0000000..a6793c8
--- /dev/null
+++ b/docs/How-to-release-docker.md
@@ -0,0 +1,59 @@
+# Apache SkyWalking Python Image Release Guide
+
+This documentation shows the way to build and push the SkyWalking Python images to DockerHub.
+
+## Prerequisites
+
+Before building the latest release of images, make sure an official release is pushed to PyPI where the dockerfile will depend on.
+
+# Images
+
+This process wil generate a list of images covering most used Python versions and variations(grpc/http/kafka) of the Python agent.
+
+The convenience images are published to Docker Hub and available from the `skywalking.docker.scarf.sh` endpoint.
+- `skywalking.docker.scarf.sh/apache/skywalking-python` ([Docker Hub](https://hub.docker.com/r/apache/skywalking-python))
+
+# How to build
+
+Issue the following commands to build relevant docker images for the Python agent.
+The `make` command will generate three images(grpc, http, kafka) for each Python version supported.
+
+At the root folder -
+```shell
+export AGENT_VERSION=<version>
+
+make build-image
+```
+
+Or at the docker folder -
+```shell
+cd docker
+
+export AGENT_VERSION=<version>
+
+make
+```
+
+# How to publish images
+
+1. After a SkyWalking Apache release for the Python agent, 
+please compose a new script named `<version>.sh` to `docker/v` folder.
+
+
+2. Build images from the project root:
+    
+    ```shell
+    export AGENT_VERSION=<version>
+
+    make build-image
+    ```
+
+
+3. Verify the images built.
+
+
+4. Push built images to docker hub repos:
+
+   ```shell
+   make push-image
+   ```
diff --git a/docs/How-to-release.md b/docs/How-to-release.md
index 1335cb9..10eb0e4 100644
--- a/docs/How-to-release.md
+++ b/docs/How-to-release.md
@@ -210,13 +210,11 @@ Vote result should follow these:
     Release Notes : https://github.com/apache/skywalking-python/blob/v$VERSION/CHANGELOG.md
 
     Website: http://skywalking.apache.org/
-
+    
     SkyWalking Python Resources:
-- Issue: https://github.com/apache/skywalking/issues
-    - Mailing list: dev@skywalking.apache.org
-    - Documents: https://github.com/apache/skywalking-python/blob/v$VERSION/README.md
+    - Issue: https://github.com/apache/skywalking/issues
+        - Mailing list: dev@skywalking.apache.org
+        - Documents: https://github.com/apache/skywalking-python/blob/v$VERSION/README.md
     
     The Apache SkyWalking Team
-```
-    
-    
+    ```