高山卡夫卡 "OpenSSL not available at build time"

Alpine Kafka "OpenSSL not available at build time"

我基于 alpine linux 构建了一个 docker 容器。我尝试使用 symfony messenger 向外部 kafka 代理发送消息。

这是我的 Messenger 配置:

    messenger:
        transports:
            de_fadi_criminal_charges_public_criminal_charge_created:
                dsn: '%env(KAFKA_DSN)%'
                serializer: App\Serializer\Avro\CriminalChargeCreatedSerializer
                options:
                    flushTimeout: 10000
                    flushRetries: 5
                    topic:
                        name: 'de.fadi.criminal_charges.public.criminal_charge_created'
                    kafka_conf:
                        security.protocol: 'sasl_ssl'
                        ssl.ca.location: '%kernel.project_dir%/config/kafka/ca.pem'
                        sasl.username: '%env(KAFKA_SASL_USERNAME)%'
                        sasl.password: '%env(KAFKA_SASL_PASSWORD)%'
                        sasl.mechanism: 'PLAIN'

这些是我的 Docker 文件中的相关行:


ARG LIBRDKAFKA_GIT_SHA1=1f7417d4796e036b8c19f17373f8290ff5c7561f
RUN apk add --update --no-cache alpine-sdk bash python autoconf openssl \
  && git clone -o ${LIBRDKAFKA_GIT_SHA1} https://github.com/edenhill/librdkafka.git /tmp/librdkafka \
  && cd /tmp/librdkafka/  \
  && ./configure \
  && make  \
  && make install

当我在构建后检查 Open SSL 是否可用时,我得到了这个:

$ openssl version
OpenSSL 1.1.1l  24 Aug 2021

当我尝试向配置的服务器发送消息时,我收到此错误消息:

Unsupported value "sasl_ssl" for configuration property "security.protocol": OpenSSL not available at build time

我找到的所有答案都指向一个事实,即您首先必须安装 openssl,然后再构建 rdkafka,我也这样做了。我错过了什么?

@dave_thompson_085 指出,如果您要使用它来构建软件,仅包含 openssl 库是不够的

用 openssl-dev 替换 openssl 成功了:

RUN apk add --update --no-cache alpine-sdk bash python autoconf openssl-dev \
  && git clone -o ${LIBRDKAFKA_GIT_SHA1} https://github.com/edenhill/librdkafka.git /tmp/librdkafka \
  && cd /tmp/librdkafka/  \
  && ./configure \
  && make  \
  && make install