Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve example since packages installed in build image not available in build phase #791

Open
garry-t opened this issue Nov 27, 2024 · 1 comment

Comments

@garry-t
Copy link

garry-t commented Nov 27, 2024

On Page: Create a build base image

I follow this docs, packages installed in build image in some reason not available during build phase.

# build image docker
FROM ubuntu:jammy

COPY ./bin/yj-linux /usr/local/bin/yj

# Workaround for docker <= 20.10.9
RUN sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' /etc/apt/apt.conf.d/docker-clean

# Install packages that we want to make available at both build and run time
RUN apt-get update && apt-get install -y xz-utils ca-certificates libyaml-0-2 git cmake libutfcpp-dev\
    libjemalloc2 \
    apt-transport-https \
    build-essential \
    ca-certificates \
    curl \
    file \
    ffmpeg\
    git-core \
    gnupg \
    imagemagick \
    libcurl4-openssl-dev \
    libffi-dev \
    libfontconfig \
    libmagickcore-dev \
    libpq-dev \
    libreadline-dev \
    libssl-dev \
    libxext6 \
    libxml2-dev \
    libxrender-dev \
    libxslt1-dev \
    libyaml-dev \
    mediainfo \
    python3-pip \
    python3-setuptools \
    zlib1g-dev &&\
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    python3 -m pip install mutagen



RUN git clone https://github.com/taglib/taglib.git /tmp/taglib && \
    cd /tmp/taglib && \
    git checkout 50b89ad19a3097a626b834c0265b2f4b62d2f274 && \
    mkdir build && cd build && \
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release .. && \
    make -j$(nproc) && make install && \
    rm -rf /tmp/taglib

# Set required CNB user information
ARG cnb_uid=1000
ARG cnb_gid=1000
ENV CNB_USER_ID=${cnb_uid}
ENV CNB_GROUP_ID=${cnb_gid}

# Create user and group
RUN groupadd cnb --gid ${CNB_GROUP_ID} && \
  useradd --uid ${CNB_USER_ID} --gid ${CNB_GROUP_ID} -m -s /bin/bash cnb

# Set user and group
USER ${CNB_USER_ID}:${CNB_GROUP_ID}

# Set required CNB target information
LABEL io.buildpacks.base.distro.name="ubuntu"
LABEL io.buildpacks.base.distro.version="22.04"
[[io.buildpacks.group]]
id = "heroku/ruby"

This build fails to find openssl-dev, libpq-dev and probably other packages.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
[builder]       
[builder]       current directory:
[builder]       /layers/heroku_ruby/gems/ruby/3.2.0/gems/openssl-3.0.0/ext/openssl
[builder]       /layers/heroku_ruby/ruby/bin/ruby extconf.rb
[builder]       checking for rb_io_maybe_wait()... yes
[builder]       checking for t_open() in -lnsl... no
[builder]       checking for socket() in -lsocket... no
[builder]       checking for openssl/ssl.h... no
[builder]       *** extconf.rb failed ***
[builder]       Could not create Makefile due to some reason, probably lack of necessary
[builder]       libraries and/or headers.  Check the mkmf.log file for more details.  You may
[builder]       need configuration options.

[builder]           openssl
[builder]       
[builder]       
[builder]       Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
[builder]       
[builder]           current directory: /layers/heroku_ruby/gems/ruby/3.2.0/gems/pg-1.5.8/ext
[builder]       /layers/heroku_ruby/ruby/bin/ruby extconf.rb
[builder]       Calling libpq with GVL unlocked
[builder]       checking for pg_config... no
[builder]       checking for libpq per pkg-config... no
[builder]       Using libpq from 
[builder]       checking for libpq-fe.h... no
[builder]       Can't find the 'libpq-fe.h header
[builder]       *****************************************************************************
[builder]       
[builder]       Unable to find PostgreSQL client library.
[builder]       
[builder]       Please install libpq or postgresql client package like so:
[builder]         sudo apt install libpq-dev
[builder]         sudo yum install postgresql-devel
[builder]         sudo zypper in postgresql-devel
[builder]         sudo pacman -S postgresql-libs

@AidanDelaney
Copy link
Member

Thanks for this. I'll double-check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants