Skip to content

Commit a1e0c3b

Browse files
torosentxinchen10
authored andcommitted
Added Docker instructions and fixed Dockerfile (Azure#18)
* Removed Dockerfile from the main folder and fixed Dockerfile example * Added build and run Dockerfile documentation * Update Readme * Removed rm qpid-proton folder * Removed /usr/share copy
1 parent 9aeee03 commit a1e0c3b

File tree

3 files changed

+66
-11
lines changed

3 files changed

+66
-11
lines changed

Dockerfile

-11
This file was deleted.

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ On Python 3.5 and above, it also includes,
66
* an event processor host module that manages the distribution of partition readers.
77

88
# Build and Install
9+
10+
### Local
911
The core library requires Apache Proton-C and its Python binding.
1012
* build Proton-C: https://github.com/apache/qpid-proton/blob/master/INSTALL.md
1113

@@ -15,12 +17,31 @@ For eventprocessorhost, you will also need (list for Fedora 26, adjust for other
1517

1618
*On Windows a private patch to proton-c code is required for the library to work.*
1719

20+
### Docker
21+
22+
The following Dockerfile at `./examples/Dockerfile` creates a Docker image with Apache Proton and the Azure Event Hubs SDK.
23+
24+
The base image is Python `3.6-slim-stretch` and Proton `0.18.1` but you can set the `PYTHON_IMAGE_VERSION` `PROTON_VERSION` `PYTHON_DIR_VERSION` when building the image.
25+
26+
```
27+
docker build -t azure-eventhubs-sdk --build-arg PYTHON_IMAGE_VERSION=3.6-slim-stretch --build-arg PROTON_VERSION=0.18.1 --build-arg PYTHON_DIR_VERSION=3.6 .
28+
```
29+
30+
After the image is built you can run the samples with
31+
```
32+
docker run -it azure-eventhubs-sdk python examples/send.py
33+
```
34+
35+
##### Note that you have fill the Event Hub connection parameters in the example py files.
36+
1837
# Examples
1938
* ./examples/send.py - use sender to publish events
2039
* ./examples/recv.py - use receiver to read events
2140
* ./examples/send_async.py - async/await support of a sender
2241
* ./examples/recv_async.py - async/await support of a receiver
2342
* ./examples/eph.py - event processor host
43+
* ./examples/Dockerfile - create a Docker image with Apache Proton and Azure Event Hubs SDK
44+
2445
* ./tests/send.py - how to perform parallel send operations to achieve high throughput
2546
* ./tests/recv.py - how to write an event pump to read events from multiple partitions
2647

examples/Dockerfile

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# -----------------------------------------------------------------------------------
5+
6+
ARG PYTHON_IMAGE_VERSION=3.6-slim-stretch
7+
8+
FROM python:${PYTHON_IMAGE_VERSION} AS build
9+
10+
ARG PROTON_VERSION=0.18.1
11+
12+
# Required dependencies
13+
RUN apt-get update && apt-get install -y git gcc cmake cmake-curses-gui uuid-dev libssl-dev libsasl2-2 \
14+
libsasl2-dev swig python-epydoc
15+
16+
# Build qpid proton
17+
RUN git clone https://github.com/apache/qpid-proton.git && \
18+
cd qpid-proton && git checkout tags/${PROTON_VERSION} && mkdir build && cd build && \
19+
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_PHP=OFF -DBUILD_PERL=OFF -DBUILD_RUBY=OFF -DSYSINSTALL_BINDINGS=ON && \
20+
make install
21+
22+
# Proton runtime
23+
FROM python:${PYTHON_IMAGE_VERSION}
24+
25+
ARG PYTHON_DIR_VERSION=3.6
26+
27+
RUN apt-get update && apt-get install -y git libsasl2-2 swig && \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
# Proton runtime and dependencies
31+
COPY --from=build /usr/include/proton/ /usr/include/proton/
32+
COPY --from=build /usr/lib/libqpid* /usr/lib/
33+
COPY --from=build /usr/local/lib/python${PYTHON_DIR_VERSION}/ /usr/local/lib/python${PYTHON_DIR_VERSION}/
34+
COPY --from=build /usr/lib/cmake/Proton/ /usr/lib/cmake/Proton/
35+
COPY --from=build /usr/lib/pkgconfig/libqpid* /usr/lib/pkgconfig/
36+
37+
# Install azure deps
38+
RUN pip3 install lxml beautifulsoup4 azure-storage
39+
40+
# Clone azure-event-hubs-python
41+
RUN git clone https://github.com/Azure/azure-event-hubs-python.git
42+
WORKDIR /azure-event-hubs-python
43+
44+
# Install event hub module
45+
RUN python3 setup.py install && pip3 install -e .

0 commit comments

Comments
 (0)