Remove python2 from the pulsar images build (#7936)
The pulsar docker and pulsar standalone docker image build failed by:
```
Processing ./pulsar-client/pulsar_client-2.6.0-cp27-cp27mu-manylinux1_x86_64.whl
2020-08-25T02:23:28.9567844Z [INFO] Collecting fastavro
2020-08-25T02:23:29.0080316Z [INFO] Downloading fastavro-1.0.0.tar.gz (658 kB)
2020-08-25T02:23:29.3108074Z [INFO] ERROR: Command errored out with exit status 1:
2020-08-25T02:23:29.3109489Z [INFO] command: /usr/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jvZueR/fastavro/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jvZueR/fastavro/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-iH1mMy
2020-08-25T02:23:29.3110061Z [INFO] cwd: /tmp/pip-install-jvZueR/fastavro/
2020-08-25T02:23:29.3110303Z [INFO] Complete output (5 lines):
2020-08-25T02:23:29.3110520Z [INFO] Traceback (most recent call last):
2020-08-25T02:23:29.3110741Z [INFO] File "<string>", line 1, in <module>
2020-08-25T02:23:29.3111190Z [INFO] File "/tmp/pip-install-jvZueR/fastavro/setup.py", line 58, in <module>
2020-08-25T02:23:29.3111437Z [INFO] if sys.implementation.name != "pypy":
2020-08-25T02:23:29.3111886Z [INFO] AttributeError: 'module' object has no attribute 'implementation'
```
I remove the python2.7 and using the python3 to build images.
* Remove python2 in images
* Remove python2 stuff
* Update the default python version
diff --git a/docker/pulsar-standalone/Dockerfile b/docker/pulsar-standalone/Dockerfile
index 93a9876..8555af0 100644
--- a/docker/pulsar-standalone/Dockerfile
+++ b/docker/pulsar-standalone/Dockerfile
@@ -29,7 +29,10 @@
# Note that the libpq-dev package is needed here in order to install
# the required python psycopg2 package (for postgresql) later
RUN apt-get update \
- && apt-get -y install python2.7 python2.7-dev python-pip postgresql sudo nginx supervisor libpq-dev
+ && apt-get -y install python3.7 python3.7-dev python3-pip postgresql sudo nginx supervisor libpq-dev
+
+RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
+RUN ln -s /usr/bin/pip3 /usr/bin/pip
# Postgres configuration
COPY --from=dashboard /etc/postgresql/11/main/postgresql.conf /etc/postgresql/11/main/postgresql.conf
@@ -59,15 +62,17 @@
COPY --from=dashboard /pulsar/requirements.txt /pulsar/django
COPY --from=dashboard /pulsar/conf/* /pulsar/conf/
+RUN pip -V
+
# Python dependencies
-RUN pip2 install -r /pulsar/django/requirements.txt
+RUN pip install -r /pulsar/django/requirements.txt
# Copy web-app sources
# Setup database and create tables
COPY --from=dashboard /pulsar/init-postgres.sh /pulsar/django/init-postgres.sh
RUN mkdir /data
RUN /pulsar/django/init-postgres.sh
-RUN sudo -u postgres /etc/init.d/postgresql stop
+RUN sudo -u postgres /etc/init.d/postgresql stop
# Add postgresql to supervisord. Redirect logs to stdout
RUN echo "\n[program:postgresql]\n\
command = /etc/init.d/postgresql start\n\
@@ -78,9 +83,10 @@
# Collect all static files needed by Django in a
# single place. Needed to run the app outside the
# Django test web server
-RUN cd /pulsar/django && ./manage.py collectstatic --no-input
+RUN cd /pulsar/django && python manage.py collectstatic --no-input
ENV SERVICE_URL http://127.0.0.1:8080
EXPOSE 80 8080 6650
CMD ["supervisord", "-n"]
+
diff --git a/docker/pulsar/Dockerfile b/docker/pulsar/Dockerfile
index 95466b0..715ca6f 100644
--- a/docker/pulsar/Dockerfile
+++ b/docker/pulsar/Dockerfile
@@ -31,7 +31,6 @@
COPY scripts/pulsar-zookeeper-ruok.sh /pulsar/bin
COPY scripts/watch-znode.py /pulsar/bin
COPY scripts/set_python_version.sh /pulsar/bin
-COPY scripts/install-pulsar-client-27.sh /pulsar/bin
COPY scripts/install-pulsar-client-37.sh /pulsar/bin
@@ -43,7 +42,6 @@
# Install some utilities
RUN apt-get update \
&& apt-get install -y netcat dnsutils less procps iputils-ping \
- python2.7 python2.7-dev python-setuptools python-yaml python-kazoo \
python3.7 python3.7-dev python3-setuptools python3-yaml python3-kazoo \
libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev \
curl \
@@ -51,9 +49,10 @@
&& rm -rf /var/lib/apt/lists/*
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
-RUN python2.7 get-pip.py
RUN python3.7 get-pip.py
+RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
+
ADD target/python-client/ /pulsar/pulsar-client
ADD target/cpp-client/ /pulsar/cpp-client
RUN echo networkaddress.cache.ttl=1 >> $JAVA_HOME/jre/lib/security/java.security
@@ -70,6 +69,5 @@
COPY --from=pulsar /pulsar /pulsar
WORKDIR /pulsar
-RUN /pulsar/bin/install-pulsar-client-27.sh
RUN /pulsar/bin/install-pulsar-client-37.sh
diff --git a/docker/pulsar/pom.xml b/docker/pulsar/pom.xml
index 5c4df90..3270bc0 100644
--- a/docker/pulsar/pom.xml
+++ b/docker/pulsar/pom.xml
@@ -53,22 +53,6 @@
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
- <id>build-pulsar-clients-python-27</id>
- <phase>compile</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <skip>${skipBuildPythonClient}</skip>
- <workingDirectory>${project.basedir}/target</workingDirectory>
- <executable>${project.basedir}/../../pulsar-client-cpp/docker/build-wheels.sh</executable>
- <arguments>
- <!-- build python 2.7 -->
- <argument>2.7 cp27-cp27mu</argument>
- </arguments>
- </configuration>
- </execution>
- <execution>
<id>build-pulsar-clients-python-35</id>
<phase>compile</phase>
<goals>