Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Use multi-stage build for Docker images (#4184)
Browse files Browse the repository at this point in the history
* Use multi-stage build for Docker images

* Fixed building pulsar-all image

* docker args should go after FROM

* Fixed pulsar-standalone Dockerfile

* Install procps for pkill in test image
  • Loading branch information
merlimat authored May 18, 2019
1 parent 840b210 commit c509f86
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
11 changes: 7 additions & 4 deletions docker/pulsar-all/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
# under the License.
#

FROM apachepulsar/pulsar:latest
FROM busybox as pulsar-all

ARG PULSAR_IO_DIR
ARG PULSAR_OFFLOADER_TARBALL

ADD ${PULSAR_IO_DIR} /pulsar/connectors

ADD ${PULSAR_IO_DIR} /connectors
ADD ${PULSAR_OFFLOADER_TARBALL} /
RUN mv /apache-pulsar-offloaders-*/offloaders /pulsar/offloaders
RUN mv /apache-pulsar-offloaders-*/offloaders /offloaders

FROM apachepulsar/pulsar:latest
COPY --from=pulsar-all /connectors /pulsar/connectors
COPY --from=pulsar-all /offloaders /pulsar/offloaders
11 changes: 8 additions & 3 deletions docker/pulsar-standalone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
# under the License.
#

FROM apachepulsar/pulsar-all:latest
FROM apachepulsar/pulsar-all:latest as pulsar

# Restart from
FROM openjdk:8-jdk

COPY --from=pulsar /pulsar /pulsar

RUN apt-get update
RUN apt-get -y install postgresql-9.6 sudo nginx supervisor
RUN apt-get -y install python2.7 python-pip postgresql-9.6 sudo nginx supervisor

# Python dependencies
RUN pip -qq install uwsgi 'Django<2.0' 'psycopg2==2.7.7' pytz requests
RUN pip2 -qq install uwsgi 'Django<2.0' 'psycopg2==2.7.7' pytz requests

# Postgres configuration
COPY conf/postgresql.conf /etc/postgresql/9.6/main/
Expand Down
25 changes: 21 additions & 4 deletions docker/pulsar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
# under the License.
#

FROM openjdk:8-jdk

# Install some utilities
RUN apt-get update && apt-get install -y netcat dnsutils python-kazoo python-yaml python-pip python3 python3-kazoo python3-yaml python3-pip
# First create a stage with just the Pulsar tarball and scripts
FROM busybox as pulsar

ARG PULSAR_TARBALL

Expand All @@ -36,6 +34,25 @@ COPY scripts/set_python_version.sh /pulsar/bin
COPY scripts/install-pulsar-client-27.sh /pulsar/bin
COPY scripts/install-pulsar-client-35.sh /pulsar/bin


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

FROM openjdk:8-jdk-slim
COPY --from=pulsar /pulsar /pulsar

# Install some utilities
RUN apt-get update \
&& apt-get install -y netcat dnsutils \
python2.7 python-setuptools \
python3 python3-setuptools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN easy_install pip
RUN pip install kazoo pyyaml
RUN easy_install3 pip

ADD target/python-client/ /pulsar/pulsar-client
RUN /pulsar/bin/install-pulsar-client-27.sh
RUN /pulsar/bin/install-pulsar-client-35.sh
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-images/latest-version-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

FROM apachepulsar/pulsar-all:latest

RUN apt-get update && apt-get install -y supervisor vim
RUN apt-get update && apt-get install -y supervisor vim procps

RUN mkdir -p /var/log/pulsar && mkdir -p /var/run/supervisor/ && mkdir -p /pulsar/ssl

Expand Down

0 comments on commit c509f86

Please sign in to comment.