Skip to content

Commit 64e7ee7

Browse files
authored
Add dockerfile and image releasing scripts (#159)
1 parent 3672a51 commit 64e7ee7

File tree

8 files changed

+211
-10
lines changed

8 files changed

+211
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Support profiling Python method level performance (#127
88
- Add a new `sw-python` CLI that enables agent non-intrusive integration (#156)
99
- Add exponential reconnection backoff strategy when OAP is down (#157)
10-
- Suport ignoring traces by http method (#143)
10+
- Support ignoring traces by http method (#143)
1111
- `NoopSpan` on queue full, propagation downstream (#141)
1212
- Support agent namespace. (#126)
1313
- Added `grpc.max_connection_age_grace_ms` (#130)
@@ -27,9 +27,10 @@
2727
- Fix grpc disconnect, add `SW_AGENT_MAX_BUFFER_SIZE` to control buffer queue size (#138)
2828

2929
- Others:
30-
- chore: bump up `requests` version to avoid license issue (#142)
31-
- fix module wrapt as normal install dependancy (#123)
30+
- Chore: bump up `requests` version to avoid license issue (#142)
31+
- Fix module wrapt as normal install dependency (#123)
3232
- Explicit component inheritance (#132)
33+
- Provide dockerfile & images for easy integration in containerized scenarios (#159)
3334

3435
### 0.6.0
3536

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ upload-test: package
5252
upload: package
5353
twine upload dist/*
5454

55+
build-image:
56+
$(MAKE) -C docker build
57+
58+
push-image:
59+
$(MAKE) -C docker push
60+
5561
clean:
5662
rm -rf skywalking/protocol
5763
rm -rf apache_skywalking.egg-info dist build

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ pip install "apache-skywalking[kafka]"
3434
pip install apache-skywalking==0.1.0 # For example, install version 0.1.0 no matter what the latest version is
3535
```
3636

37+
### From Docker Hub
38+
39+
SkyWalking Python agent provides convenient dockerfile and images for easy integration utilizing its auto-bootstrap
40+
capability. You can build your Python application image based on our agent-enabled Python images and start
41+
your applications with SkyWalking agent enabled for you. Please refer to our
42+
[dockerfile guide](docker/README.md) for further instructions on building and configurations.
43+
3744
### From Source Codes
3845

3946
Refer to the [FAQ](docs/FAQ.md#q-how-to-build-from-sources).

docker/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
ARG BASE_IMAGE
18+
19+
FROM ${BASE_IMAGE}
20+
21+
ARG SW_PYTHON_AGENT_PROTOCOL
22+
ARG SW_PYTHON_AGENT_VERSION
23+
24+
RUN pip install --no-cache-dir "apache-skywalking[${SW_PYTHON_AGENT_PROTOCOL}]==${SW_PYTHON_AGENT_VERSION}"
25+
26+
ENTRYPOINT ["sw-python", "run"]

docker/Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
D := docker
18+
19+
P := grpc http kafka
20+
21+
TARGETS := py3.5 py3.6 py3.7 py3.8 py3.9
22+
23+
py3.5: BASE_IMAGE = python:3.5
24+
py3.6: BASE_IMAGE = python:3.6
25+
py3.7: BASE_IMAGE = python:3.7
26+
py3.8: BASE_IMAGE = python:3.8
27+
py3.9: BASE_IMAGE = python:3.9
28+
29+
PUSH_TARGETS := $(TARGETS:%=push-%)
30+
31+
word-dash = $(word $2,$(subst -, ,$1))
32+
33+
build: $(TARGETS)
34+
push: $(PUSH_TARGETS)
35+
36+
$(TARGETS):
37+
for p in $(P); do \
38+
$(D) build $(SW_BUILD_ARGS) \
39+
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
40+
--build-arg SW_PYTHON_AGENT_PROTOCOL=$$p \
41+
--build-arg SW_PYTHON_AGENT_VERSION=${AGENT_VERSION} \
42+
-t apache/skywalking-python:${AGENT_VERSION}-$$p-$@ \
43+
. ; \
44+
done
45+
46+
47+
$(PUSH_TARGETS):
48+
$(eval version := $(call word-dash,$@,2))
49+
for p in $(P); do \
50+
$(D) push apache/skywalking-python:${AGENT_VERSION}-$$p-${version}; \
51+
done

docker/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Apache SkyWalking Python Agent dockerfile and images
2+
3+
**Docker images are not official ASF releases but provided for convenience. Recommended usage is always to build the
4+
source**
5+
6+
**<img src="http://skywalking.apache.org/assets/logo.svg" alt="SkyWalking logo" height="90px" align="right" />**
7+
8+
**SkyWalking**: an APM(application performance monitor) system, especially designed for microservices, cloud native and
9+
container-based (Docker, Kubernetes, Mesos) architectures.
10+
11+
[![GitHub stars](https://img.shields.io/github/stars/apache/skywalking.svg?style=for-the-badge&label=Stars&logo=github)](https://github.com/apache/skywalking)
12+
[![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=for-the-badge&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking)
13+
14+
This image hosts the SkyWalking Python agent package on top of official Python base images providing support from
15+
Python 3.5 - 3.9.
16+
17+
## How to use this image
18+
19+
The images are hosted at [Docker Hub](https://hub.docker.com/r/apache/skywalking-python) and available from the `skywalking.docker.scarf.sh` endpoint.
20+
21+
`skywalking.docker.scarf.sh/apache/skywalking-python`
22+
23+
### Build your Python application image on top of this image
24+
25+
Start by pulling the skywalking-python image as the base of your application image.
26+
Refer to [Docker Hub](https://hub.docker.com/r/apache/skywalking-python) for the list of tags available.
27+
28+
```dockerfile
29+
FROM apache/skywalking-python:0.7.0-grpc-py3.9
30+
31+
# ... build your Python application
32+
```
33+
34+
You could start your Python application with `CMD`. For example - `CMD ['gunicorn', 'app.wsgi']`
35+
36+
You don't need to care about enabling the SkyWalking Python agent manually,
37+
it should be adopted and bootstrapped automatically through the `sw-python` CLI.
38+
39+
[Environment variables](../docs/EnvVars.md) can be provided to customize the agent behavior.
40+
41+
### Build an image from the dockerfile
42+
43+
Provide the following arguments to build your own image from the dockerfile.
44+
45+
```text
46+
BASE_IMAGE # the Python base image to build upon
47+
SW_PYTHON_AGENT_VERSION # agent version to be pulled from PyPI
48+
SW_PYTHON_AGENT_PROTOCOL # agent protocol - grpc/ http/ kafka
49+
```
50+
51+
## License
52+
53+
[Apache 2.0 License.](/LICENSE)

docs/How-to-release-docker.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Apache SkyWalking Python Image Release Guide
2+
3+
This documentation shows the way to build and push the SkyWalking Python images to DockerHub.
4+
5+
## Prerequisites
6+
7+
Before building the latest release of images, make sure an official release is pushed to PyPI where the dockerfile will depend on.
8+
9+
# Images
10+
11+
This process wil generate a list of images covering most used Python versions and variations(grpc/http/kafka) of the Python agent.
12+
13+
The convenience images are published to Docker Hub and available from the `skywalking.docker.scarf.sh` endpoint.
14+
- `skywalking.docker.scarf.sh/apache/skywalking-python` ([Docker Hub](https://hub.docker.com/r/apache/skywalking-python))
15+
16+
# How to build
17+
18+
Issue the following commands to build relevant docker images for the Python agent.
19+
The `make` command will generate three images(grpc, http, kafka) for each Python version supported.
20+
21+
At the root folder -
22+
```shell
23+
export AGENT_VERSION=<version>
24+
25+
make build-image
26+
```
27+
28+
Or at the docker folder -
29+
```shell
30+
cd docker
31+
32+
export AGENT_VERSION=<version>
33+
34+
make
35+
```
36+
37+
# How to publish images
38+
39+
1. After a SkyWalking Apache release for the Python agent,
40+
please compose a new script named `<version>.sh` to `docker/v` folder.
41+
42+
43+
2. Build images from the project root:
44+
45+
```shell
46+
export AGENT_VERSION=<version>
47+
48+
make build-image
49+
```
50+
51+
52+
3. Verify the images built.
53+
54+
55+
4. Push built images to docker hub repos:
56+
57+
```shell
58+
make push-image
59+
```

docs/How-to-release.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,11 @@ Vote result should follow these:
210210
Release Notes : https://github.com/apache/skywalking-python/blob/v$VERSION/CHANGELOG.md
211211

212212
Website: http://skywalking.apache.org/
213-
213+
214214
SkyWalking Python Resources:
215-
- Issue: https://github.com/apache/skywalking/issues
216-
- Mailing list: [email protected]
217-
- Documents: https://github.com/apache/skywalking-python/blob/v$VERSION/README.md
215+
- Issue: https://github.com/apache/skywalking/issues
216+
- Mailing list: [email protected]
217+
- Documents: https://github.com/apache/skywalking-python/blob/v$VERSION/README.md
218218

219219
The Apache SkyWalking Team
220-
```
221-
222-
220+
```

0 commit comments

Comments
 (0)