|
| 1 | +# |
| 2 | +# Copyright 2019 Confluent Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | + |
| 17 | +############################################################################# |
| 18 | +# Alpine-based docker container with: |
| 19 | +# * Python3 |
| 20 | +# * librdkafka (fully featured) |
| 21 | +# * kafkacat (withouth schema-registry/Avro support) |
| 22 | +# * confluent-kafka-python |
| 23 | +# |
| 24 | +# How to build (from confluent-kafka-python top-level directory): |
| 25 | +# $ docker build -f examples/docker/Dockerfile.alpine . |
| 26 | +# |
| 27 | +############################################################################# |
| 28 | + |
| 29 | +FROM alpine:3.12 |
| 30 | + |
| 31 | +COPY . /usr/src/confluent-kafka-python |
| 32 | + |
| 33 | +ENV LIBRDKAFKA_VERSION v1.4.2 |
| 34 | +ENV KAFKACAT_VERSION master |
| 35 | + |
| 36 | + |
| 37 | +ENV BUILD_DEPS git make gcc g++ curl pkgconfig bsd-compat-headers zlib-dev openssl-dev cyrus-sasl-dev curl-dev zstd-dev yajl-dev python3-dev |
| 38 | + |
| 39 | +ENV RUN_DEPS bash libcurl cyrus-sasl-gssapiv2 ca-certificates libsasl heimdal-libs krb5 zstd-libs zstd-static yajl python3 py3-pip |
| 40 | + |
| 41 | +RUN \ |
| 42 | + apk update && \ |
| 43 | + apk add --no-cache --virtual .dev_pkgs $BUILD_DEPS $BUILD_DEPS_EXTRA && \ |
| 44 | + apk add --no-cache $RUN_DEPS $RUN_DEPS_EXTRA |
| 45 | + |
| 46 | +RUN \ |
| 47 | + echo Installing librdkafka && \ |
| 48 | + mkdir -p /usr/src/librdkafka && \ |
| 49 | + cd /usr/src/librdkafka && \ |
| 50 | + curl -LfsS https://github.com/edenhill/librdkafka/archive/${LIBRDKAFKA_VERSION}.tar.gz | \ |
| 51 | + tar xvzf - --strip-components=1 && \ |
| 52 | + ./configure --prefix=/usr --disable-lz4-ext && \ |
| 53 | + make -j && \ |
| 54 | + make install && \ |
| 55 | + cd / && \ |
| 56 | + rm -rf /usr/src/librdkafka |
| 57 | + |
| 58 | +RUN \ |
| 59 | + echo Installing kafkacat && \ |
| 60 | + mkdir -p /usr/src/kafkacat && \ |
| 61 | + cd /usr/src/kafkacat && \ |
| 62 | + curl -LfsS https://github.com/edenhill/kafkacat/archive/${KAFKACAT_VERSION}.tar.gz | \ |
| 63 | + tar xvzf - --strip-components=1 && \ |
| 64 | + ./configure --prefix=/usr && \ |
| 65 | + make -j && \ |
| 66 | + make install && \ |
| 67 | + cd / && \ |
| 68 | + rm -rf /usr/src/kafkacat && \ |
| 69 | + kafkacat -V |
| 70 | + |
| 71 | +RUN \ |
| 72 | + echo Installing confluent-kafka-python && \ |
| 73 | + mkdir -p /usr/src/confluent-kafka-python && \ |
| 74 | + cd /usr/src/confluent-kafka-python && \ |
| 75 | + rm -rf build && \ |
| 76 | + python3 setup.py clean -a && \ |
| 77 | + python3 setup.py build && \ |
| 78 | + python3 setup.py install && \ |
| 79 | + cd / && \ |
| 80 | + rm -rf /usr/src/confluent-kafka-python |
| 81 | + |
| 82 | +RUN \ |
| 83 | + apk del .dev_pkgs |
| 84 | + |
| 85 | +RUN \ |
| 86 | + python3 -c 'import confluent_kafka as cf ; print(cf.version(), "librdkafka", cf.libversion())' |
| 87 | + |
0 commit comments