Skip to content

Commit

Permalink
[fix] Fix issues with Pulsar Alpine docker image stability: remove gl…
Browse files Browse the repository at this point in the history
…ibc-compat (#23762)

(cherry picked from commit 906d10e)
  • Loading branch information
lhotari committed Dec 21, 2024
1 parent f961e75 commit d3d8e50
Show file tree
Hide file tree
Showing 19 changed files with 469 additions and 243 deletions.
80 changes: 0 additions & 80 deletions docker/glibc-package/Dockerfile

This file was deleted.

53 changes: 0 additions & 53 deletions docker/glibc-package/scripts/APKBUILD

This file was deleted.

21 changes: 0 additions & 21 deletions docker/glibc-package/scripts/glibc-bin.trigger

This file was deleted.

23 changes: 0 additions & 23 deletions docker/glibc-package/scripts/ld.so.conf

This file was deleted.

90 changes: 90 additions & 0 deletions docker/kinesis-producer-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
# 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.
#

ARG ALPINE_VERSION=3.20

# Builds an Alpine image with kinesis_producer compiled for Alpine Linux / musl

# Build stage
FROM alpine:$ALPINE_VERSION AS kinesis-producer-build
ENV KINESIS_PRODUCER_LIB_VERSION=0.15.12

# Install build dependencies
RUN apk update && apk add --no-cache \
git \
binutils \
coreutils \
alpine-sdk \
util-linux \
cmake \
autoconf \
automake \
libtool \
curl \
bash \
tar \
libuuid \
linux-headers \
zlib \
zlib-dev \
perl \
wget \
boost-dev \
openssl-dev \
curl-dev \
build-base \
util-linux-dev \
g++ \
make \
upx

ENV LANG=C.UTF-8

RUN mkdir /build
COPY kinesis_producer_alpine.patch /build/

# Clone KPL and copy build script
RUN cd /build && \
git clone --depth 1 --single-branch --branch v${KINESIS_PRODUCER_LIB_VERSION} https://github.com/awslabs/amazon-kinesis-producer && \
cd amazon-kinesis-producer && \
git apply ../kinesis_producer_alpine.patch

# Copy and execute build script
COPY build-alpine.sh /build/
RUN chmod +x /build/build-alpine.sh
RUN /build/build-alpine.sh

# Final stage
FROM alpine:$ALPINE_VERSION
COPY --from=kinesis-producer-build /opt/amazon-kinesis-producer /opt/amazon-kinesis-producer
RUN apk update && apk add --no-cache \
brotli-libs \
c-ares \
libcrypto3 \
libcurl \
libgcc \
libidn2 \
libpsl \
libssl3 \
libunistring \
nghttp2-libs \
zlib \
zstd-libs \
libuuid
WORKDIR /opt/amazon-kinesis-producer/bin
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
-->

# GLibc compatibility package
# Alpine image with kinesis_producer compiled for Alpine Linux / musl

This directory includes the Docker scripts to build an image with GLibc compiled for Alpine Linux.
This directory includes the Docker scripts to build an image with `kinesis_producer` for Alpine Linux.
`kinesis_producer` is a native executable that is required by [Amazon Kinesis Producer library (KPL)](https://github.com/awslabs/amazon-kinesis-producer) which is used by the Pulsar IO Kinesis Sink connector. The default `kinesis_producer` binary is compiled for glibc, and it does not work on Alpine Linux which uses musl.

This is used to ensure plugins that are going to be used in the Pulsar image and that are depeding on GLibc, will
still be working correctly in the Alpine Image. (eg: Netty Tc-Native and Kinesis Producer Library).

This image only needs to be re-created when we want to upgrade to a newer version of GLibc.
This image only needs to be re-created when we want to upgrade to a newer version of `kinesis_producer`.

# Steps

1. Change the version in the Dockerfile for this directory.
2. Rebuild the image and push it to Docker Hub:
```
docker buildx build --platform=linux/amd64,linux/arm64 -t apachepulsar/glibc-base:2.38 . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t apachepulsar/pulsar-io-kinesis-sink-kinesis_producer:0.15.12 . --push
```

The image tag is then used in `docker/pulsar/Dockerfile`.
The image tag is then used in `docker/pulsar-all/Dockerfile`. The `kinesis_producer` binary is copied from the image to the `pulsar-all` image that is used by Pulsar Functions to run the Pulsar IO Kinesis Sink connector. The environment variable `PULSAR_IO_KINESIS_KPL_PATH` is set to `/opt/amazon-kinesis-producer/bin/kinesis_producer` and this is how the Kinesis Sink connector knows where to find the `kinesis_producer` binary.
Loading

0 comments on commit d3d8e50

Please sign in to comment.