Skip to content

Commit

Permalink
1. Use ubuntu:20.04 base image for Pulsar docker images
Browse files Browse the repository at this point in the history
2. Build python client by Python3.8

cherry-pick:
1. apache#11026
2. apache#11623
3. apache#11862
  • Loading branch information
gaoran10 committed Sep 10, 2021
1 parent cd7c179 commit ebc2b97
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
13 changes: 9 additions & 4 deletions docker/pulsar-standalone/Dockerfile
Expand Up @@ -24,16 +24,21 @@ FROM apachepulsar/pulsar-all:latest as pulsar
FROM apachepulsar/pulsar-dashboard:latest as dashboard

# Restart from
FROM openjdk:8-jdk
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get -y install wget gnupg && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN bash -c "echo deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main >> /etc/apt/sources.list.d/pgdg.list"

# 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 python3.7 python3.7-dev python3-pip postgresql sudo nginx supervisor libpq-dev
&& apt-get -y install openjdk-11-jdk-headless python3 python3-dev python3-pip postgresql-11 sudo nginx supervisor libpq-dev

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
RUN update-ca-certificates
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
Expand Down Expand Up @@ -73,7 +78,7 @@ RUN pip install -r /pulsar/django/requirements.txt
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\
Expand Down
24 changes: 15 additions & 9 deletions docker/pulsar/Dockerfile
Expand Up @@ -32,13 +32,15 @@ COPY scripts/generate-zookeeper-config.sh /pulsar/bin
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-37.sh /pulsar/bin
COPY scripts/install-pulsar-client.sh /pulsar/bin


### Create 2nd stage from OpenJDK image
### and add Python dependencies (for Pulsar functions)
### Create 2nd stage from Ubuntu image
### and add OpenJDK and Python dependencies (for Pulsar functions)

FROM openjdk:8-jdk-slim
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

# Install software-properties-common
RUN apt update \
Expand All @@ -47,21 +49,25 @@ RUN apt update \

# Install some utilities
RUN apt-get update \
&& apt-get install -y netcat dnsutils less procps iputils-ping \
python3.7 python3.7-dev python3-setuptools python3-yaml python3-kazoo \
&& apt-get -y dist-upgrade \
&& apt-get -y install openjdk-11-jdk-headless netcat dnsutils less procps iputils-ping \
python3 python3-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 \
&& apt-get -y --purge autoremove \
&& apt-get autoclean \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3.7 get-pip.py
RUN python3 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
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
RUN echo networkaddress.cache.ttl=1 >> /usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security
RUN apt-get update \
&& apt install -y /pulsar/cpp-client/*.deb \
&& apt-get clean \
Expand All @@ -75,4 +81,4 @@ ENV PULSAR_ROOT_LOGGER=INFO,CONSOLE
COPY --from=pulsar /pulsar /pulsar
WORKDIR /pulsar

RUN /pulsar/bin/install-pulsar-client-37.sh
RUN /pulsar/bin/install-pulsar-client.sh
4 changes: 2 additions & 2 deletions docker/pulsar/pom.xml
Expand Up @@ -63,8 +63,8 @@
<workingDirectory>${project.basedir}/target</workingDirectory>
<executable>${project.basedir}/../../pulsar-client-cpp/docker/build-wheels.sh</executable>
<arguments>
<!-- build python 3.7 -->
<argument>3.7 cp37-cp37m</argument>
<!-- build python 3.8 -->
<argument>3.8 cp38-cp38</argument>
</arguments>
</configuration>
</execution>
Expand Down
25 changes: 25 additions & 0 deletions docker/pulsar/scripts/install-pulsar-client.sh
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -x

PYTHON_MAJOR_MINOR=$(python3 -V | sed -E 's/.* ([[:digit:]]+)\.([[:digit:]]+).*/\1\2/')
WHEEL_FILE=$(ls /pulsar/pulsar-client | grep "cp${PYTHON_MAJOR_MINOR}")
pip3 install /pulsar/pulsar-client/${WHEEL_FILE}[all]

0 comments on commit ebc2b97

Please sign in to comment.