Skip to content
Permalink
Browse files
Build PyFlink image with compatible Python version (#28)
The underlying base image is now debian bullseye which ships with
Python 3.9 and this version of Python is not compatible with PyFlink.
Thus build and add Python 3.7 to image.
  • Loading branch information
fredthomsen committed May 9, 2022
1 parent 19ffc0e commit 22f1ba831cde6cafd43108ea46c66306b8a67902
Showing 1 changed file with 17 additions and 9 deletions.
@@ -23,20 +23,28 @@
FROM apache/flink:1.13.1-scala_2.12-java8
ARG FLINK_VERSION=1.13.1

# Install pyflink
# Install python3.7 and pyflink
# Pyflink does not yet function with python3.9, and this image is build on
# debian bullseye which ships with that version, so build python3.7 here.
RUN set -ex; \
apt-get update; \
apt-get -y install python3; \
apt-get -y install python3-pip; \
apt-get -y install python3-dev; \
ln -s /usr/bin/python3 /usr/bin/python; \
ln -s /usr/bin/pip3 /usr/bin/pip; \
apt-get update; \
apt-get update && \
apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libffi-dev && \
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz && \
tar -xvf Python-3.7.9.tgz && \
cd Python-3.7.9 && \
./configure --without-tests --enable-shared && \
make -j4 && \
make install && \
ldconfig /usr/local/lib && \
cd .. && rm -f Python-3.7.9.tgz && rm -rf Python-3.7.9 && \
ln -s /usr/local/bin/python3 /usr/local/bin/python && \
ln -s /usr/local/bin/pip3 /usr/local/bin/pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
python -m pip install --upgrade pip; \
pip install apache-flink==1.13.1; \
pip install kafka-python;


# Download connector libraries
RUN wget -P /opt/flink/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-json/${FLINK_VERSION}/flink-json-${FLINK_VERSION}.jar; \
wget -P /opt/flink/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-kafka_2.12/${FLINK_VERSION}/flink-sql-connector-kafka_2.12-${FLINK_VERSION}.jar; \

0 comments on commit 22f1ba8

Please sign in to comment.