3

我有一个带有这个 Dockerfile 的工作 UBUNTU 映像:

FROM perl:5.14

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y libgd-dev

RUN perl -MCPAN -e 'install (Try::Tiny)'
RUN perl -MCPAN -e 'install (Kafka::Connection)'
RUN perl -MCPAN -e 'install (YAML)'
RUN perl -MCPAN -e 'install (GD::Simple)'
RUN perl -MCPAN -e 'install (GD::Graph)'
RUN perl -MCPAN -e 'install (JSON)'
RUN perl -MCPAN -e 'install (JSON::MaybeXS)'
RUN perl -MCPAN -e 'install (HTTP::Request)'
RUN perl -MCPAN -e 'install (HTTP::Response)'
RUN perl -MCPAN -e 'install (HTTP::Daemon)'

COPY run.sh /run.sh

RUN chmod +x "/run.sh"

RUN mkdir -p /code_path

WORKDIR /code_path

CMD ["/run.sh"]

我试图得到一个像这样更苗条的高山版本:

FROM alpine:3.10.3

## alpine curl and wget aren't fully compatible, so we install them
## here. gnupg is needed for Module::Signature.
RUN apk update && apk upgrade
RUN apk add curl tar make gcc build-base wget gnupg

RUN mkdir -p /usr/src/perl

WORKDIR /usr/src/perl

## from perl; `true make test_harness` because 3 tests fail
## some flags from http://git.alpinelinux.org/cgit/aports/tree/main/perl/APKBUILD?id=19b23f225d6e4f25330e13144c7bf6c01e624656
RUN curl -SLO https://www.cpan.org/src/5.0/perl-5.30.0.tar.gz \
    && echo 'aa5620fb5a4ca125257ae3f8a7e5d05269388856 *perl-5.30.0.tar.gz' | sha1sum -c - \
    && tar --strip-components=1 -xzf perl-5.30.0.tar.gz -C /usr/src/perl \
    && rm perl-5.30.0.tar.gz \
    && ./Configure -des \
    -Duse64bitall \
    -Dcccdlflags='-fPIC' \
    -Dcccdlflags='-fPIC' \
    -Dccdlflags='-rdynamic' \
    -Dlocincpth=' ' \
    -Duselargefiles \
    -Dusethreads \
    -Duseshrplib \
    -Dd_semctl_semun \
    -Dusenm \
    && make libperl.so \
    && make -j$(nproc) \
    && true TEST_JOBS=$(nproc) make test_harness \
    && make install \
    && curl -LO https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm \
    && chmod +x cpanm \
    && ./cpanm App::cpanminus \
    && rm -fr ./cpanm /root/.cpanm /usr/src/perl




## from tianon/perl
ENV PERL_CPANM_OPT --verbose --mirror https://cpan.metacpan.org --mirror-only
RUN cpanm Digest::SHA Module::Signature && rm -rf ~/.cpanm
ENV PERL_CPANM_OPT $PERL_CPANM_OPT --verify

RUN perl -MCPAN -e 'install (Try::Tiny)'
RUN perl -MCPAN -e 'install (Kafka::Connection)'
RUN perl -MCPAN -e 'install (YAML)'
RUN perl -MCPAN -e 'install (GD::Simple)'
RUN perl -MCPAN -e 'install (GD::Graph)'
RUN perl -MCPAN -e 'install (JSON)'
RUN perl -MCPAN -e 'install (JSON::MaybeXS)'
RUN perl -MCPAN -e 'install (HTTP::Request)'
RUN perl -MCPAN -e 'install (HTTP::Response)'
RUN perl -MCPAN -e 'install (HTTP::Daemon)'

COPY run.sh /run.sh

RUN chmod +x "/run.sh"

RUN mkdir -p /code_path

WORKDIR /code_path

CMD ["/run.sh"]

我不断收到此错误

OS.c:18:10: fatal error: obstack.h: No such file or directory
 #include <obstack.h>    /* glibc's handy obstacks */

如何获取图像上 Kafka 的所有依赖项?

4

3 回答 3

2

Alpine 不提供 glibc,obstack.h也不是musl-dev的一部分。

尝试alpine-pkg-glibc

于 2019-12-01T18:38:56.260 回答
2

您可以尝试obstack.h通过安装存储库的新可用musl-obstack-dev包来获取 Alpine edge/testing

apk add musl-obstack-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

请注意,edge/testing软件包是最先进的并且被认为是实验性的(与主要稳定软件包相反)。

虽然 Alpine (musl libc) 通常与 glibc 不兼容,但它确实在方便的头文件和库方面提供了轻量级的 glibc 兼容性,特别是通过libc6-compat包和上述包。

提示:使用 Alpine 出色的包搜索来查找丢失的文件。Alpine 活泼好动,经常看到新的包裹。大多数时候,您会发现丢失的文件在 apk 包中可用。obstack.h包内容搜索结果:
https ://pkgs.alpinelinux.org/contents?file=obstack.h&path=&name=&branch=edge

于 2019-12-01T22:30:37.130 回答
1

我最终搜索了 Github 以找到一个更新的 alpine perl 图像,并且在valino 的回答中得到了极大的帮助,从而获得了这个 Dockerfile:

FROM alpine:3.10.3

## alpine curl and wget aren't fully compatible, so we install them
## here. gnupg is needed for Module::Signature.
RUN apk update && apk upgrade
RUN apk add --no-cache curl tar make gcc build-base wget gnupg ca-certificates g++ git gd-dev
RUN apk add --no-cache zlib zlib-dev
RUN apk add --no-cache perl perl-dev

RUN curl -L <check the link above "newer alpine perl image" for this line it was rejected> > /bin/cpanm && chmod +x /bin/cpanm
RUN cpanm App::cpm

WORKDIR /usr

RUN cpm install Try::Tiny
RUN cpm install YAML
RUN cpm install JSON
RUN cpm install JSON::MaybeXS
RUN cpm install HTTP::Request
RUN cpm install HTTP::Response
RUN cpm install HTTP::Daemon

RUN cpm install GD::Simple
RUN cpm install GD::Graph
RUN cpm install Data::HexDump::Range
RUN cpm install Proc::Daemon
RUN cpm install Test::Block
RUN cpm install Text::Colorizer
RUN cpm install Gzip::Faster

ENV PERL5LIB=/usr/local/lib/perl5
ENV PATH=/usr/local/bin:$PATH

RUN apk add --no-cache musl-obstack-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing

RUN cpm install Proc::ProcessTable
RUN cpm install Kafka::Connection

COPY run.sh /run.sh

RUN chmod +x "/run.sh"

RUN mkdir -p /code_path

WORKDIR /code_path

CMD ["/run.sh"]
于 2019-12-02T08:30:21.650 回答