如何在Heroku buildpack中设置CONFIG_PATH [英] How to set CONFIG_PATH in Heroku buildpack

查看:80
本文介绍了如何在Heroku buildpack中设置CONFIG_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在详细说明问题之前,我应该让您知道我已经在heroku的bash(heroku run bash)上成功安装了ffmpegthumbnailer.

我正在尝试使用我编写的自定义Heroku构建包构建ffmpegthumbnailer,但是当我运行./configure&&在bin/compile buildpack文件中进行安装,ffmpegthumbnailer告诉我找不到ffmpeg库(util,format,codec,scale),并建议我设置PKG_CONFIG_PATH.因此,我设置了PKG_CONFIG_PATH,但它似乎仍然找不到库.

我尝试过每种方式设置PKG_CONFIG_PATH.回显导出,导出,直接通过PKG_CONFIG_PATH =/app进行设置...我一直将其设置为.configure命令.我什至将PKG_CONFIG_PATH设置为heroku配置变量,并尝试通过传递到buildpack中的ENV_DIR变量作为第三个参数进行访问,但是我很快意识到我只是将变量PKG_CONFIG_PATH设置为名为PKG_CONFIG_PATH的文件的内容,即我正在设置PKG_CONFIG_PATH =/app/vendor ...,我已经完成了!这些都不起作用.另外,如您在编译文件和日志中所看到的,echo $ PKG_CONFIG_PATH打印正确的路径.

我还可以进行哪些调试?发生了什么事?

下面是我的bin/compile buildpack文件,以及将我的应用程序部署到heroku之后的日志.

 #!/bin/shindent(){sed -u's/^//'}回声"----->安装ffmpeg-thumbnailer"BUILD_DIR = $ 1VENDOR_DIR =供应商"DOWNLOAD_URL ="https://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-2.0.8.tar.gz"echo"DOWNLOAD_URL =" $ DOWNLOAD_URL |缩进cd $ BUILD_DIRmkdir -p $ VENDOR_DIRcd $ VENDOR_DIRcurl -L --silent $ DOWNLOAD_URL |焦油xzcd ffmpegthumbnailer-2.0.8/导出PKG_CONFIG_PATH ="$ PKG_CONFIG_PATH:/app/vendor/ffmpeg/lib/pkgconfig/"回声$ PKG_CONFIG_PATH./configure --prefix/app/vendor/ffmpegthumbnailer&&进行安装回显导出PATH和LIBRARY_PATH" |缩进PROFILE_PATH ="$ BUILD_DIR/.profile.d/ffmpeg-thumbnailer.sh"mkdir -p $(目录名$ PROFILE_PATH)echo'export PATH ="$ PATH:vendor/ffmpeg-thumbnailer/bin"'>>$ PROFILE_PATHecho'export LD_LIBRARY_PATH ="$ LD_LIBRARY_PATH:vendor/ffmpeg-thumbnailer/lib"'>>$ PROFILE_PATH 

还有我的heroku部署日志...

 获取存储库已完成.计数对象:5,完成.最多2个线程的增量压缩.压缩对象:100%(3/3),已完成.写入对象:100%(3/3),311个字节,已完成.总计3(增量2),重用0(增量0)----->正在获取自定义git buildpack ...已完成----->检测到Multipack应用=====>下载Buildpack:https://github.com/shunjikonishi/heroku-buildpack-ffmpeg=====>检测到的框架:ffmpeg----->安装ffmpegDOWNLOAD_URL = http://flect.github.io/heroku-binaries/libs/ffmpeg.tar.gz导出PATH和LIBRARY_PATH=====>下载Buildpack:https://github.com/johnklawlor/heroku-buildpack-ffmpeg-thumbnailer=====>检测到的框架:ffmpeg----->安装ffmpeg-thumbnailerPKG_CONFIG来了!/app/vendor/ffmpeg/lib/pkgconfigDOWNLOAD_URL = https://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-2.0.8.tar.gz/app/vendor/ffmpeg/lib/pkgconfig正在检查与BSD兼容的安装.../usr/bin/install -c检查构建环境是否正常...是检查线程安全的mkdir -p .../bin/mkdir -p正在检查gawk ...否正在检查ma ... w检查make set $(MAKE)...是正在检查g ++ ... g ++检查C ++编译器是否工作...是检查C ++编译器的默认输出文件名... a.out正在检查可执行文件的后缀...检查我们是否交叉编译...否检查目标文件的后缀... o检查我们是否正在使用GNU C ++编译器...是检查g ++是否接受-g ...是检查make所使用的include样式... GNU正在检查g ++的依赖项样式... gcc3正在检查构建系统类型... x86_64-unknown-linux-gnu检查主机系统类型... x86_64-unknown-linux-gnu检查如何打印字符串... printf正在检查gcc ... gcc检查我们是否正在使用GNU C编译器...是检查gcc是否接受-g ...是正在检查gcc选项以接受ISO C89 ...不需要检查gcc的依赖项样式... gcc3正在检查不会截断输出的sed .../bin/sed检查处理长行的grep和-e .../bin/grep正在检查egrep .../bin/grep -E正在检查fgrep .../bin/grep -F检查gcc使用的ld .../usr/bin/ld检查链接器(/usr/bin/ld)是否为GNU ld ...是正在检查与BSD或MS兼容的名称列表(nm).../usr/bin/nm -B检查名称列表器(/usr/bin/nm -B)接口... BSD nm检查ln -s是否有效...是正在检查命令行参数的最大长度... 1572864检查外壳是否理解某些XSI构造...是检查外壳是否理解"+ =" ...是检查如何将x86_64-unknown-linux-gnu文件名转换为x86_64-unknown-linux-gnu格式... func_convert_file_noop检查如何将x86_64-unknown-linux-gnu文件名转换为工具链格式... func_convert_file_noop检查/usr/bin/ld选项以重新加载目标文件... -r检查objdump ... objdump检查如何识别依赖库... pass_all正在检查dlltool ...否正在检查如何关联运行时和链接库... printf%s \ n检查ar ... ar正在检查存档程序@FILE支持... @检查带钢...带钢正在检查ranlib ... ranlib检查命令以解析/usr/bin/nm -B从gcc对象输出...确定正在检查sysroot ...否检查mt ... mt检查mt是否是清单工具...否检查如何运行C预处理程序... gcc -E检查ANSI C标头文件...是正在检查sys/types.h ...是正在检查sys/stat.h ...是正在检查stdlib.h ...是正在检查string.h ...是正在检查内存...是...正在检查strings.h ...是的正在检查inttypes.h ...是正在检查stdint.h ...是检查unistd.h ...是的正在检查dlfcn.h ...是正在检查objdir ... .libs检查gcc是否支持-fno-rtti -fno-exceptions ...否检查gcc选项以产生PIC ... -fPIC -DPIC检查gcc PIC标志-fPIC -DPIC是否工作...是检查gcc静态标志-static是否正常...是检查gcc是否支持-c -o file.o ...是检查gcc是否支持-c -o file.o ...(缓存)是检查gcc链接器(/usr/bin/ld -m elf_x86_64)是否支持共享库...是检查-lc是否应显式链接到...否检查动态链接器特征... GNU/Linux ld.so检查如何将库路径硬编码到程序中...立即检查是否可以剥离库...是检查libtool是否支持共享库...是检查是否建立共享库...是检查是否建立静态库...是检查如何运行C ++预处理程序... g ++ -E检查g ++使用的ld .../usr/bin/ld -m elf_x86_64检查链接器(/usr/bin/ld -m elf_x86_64)是否为GNU ld ...是检查g ++链接器(/usr/bin/ld -m elf_x86_64)是否支持共享库...是检查g ++选项以产生PIC ... -fPIC -DPIC检查g ++ PIC标志-fPIC -DPIC是否工作...是检查g ++静态标志-static是否正常...是检查g ++是否支持-c -o file.o ...是检查g ++是否支持-c -o file.o ...(缓存)是检查g ++链接器(/usr/bin/ld -m elf_x86_64)是否支持共享库...是检查动态链接器特征...(已缓存)GNU/Linux ld.so检查如何将库路径硬编码到程序中...立即检查大型文件所需的特殊C编译器选项...否正在检查大文件所需的_FILE_OFFSET_BITS值...否检查make是否支持嵌套变量...是检查ANSI C头文件...(缓存)是检查inttypes.h ...(缓存)是检查sys/stat.h ...(已缓存)是检查/usr/bin/ld -m elf_x86_64是否接受--as-needed ...是检查pkg-config .../usr/bin/pkg-config检查pkg-config至少是0.9.0版...是正在检查FFMPEG ...否配置:错误:不符合软件包要求(libavutil libavformat libavcodec> = 52.26.0 libswscale):找不到软件包"libavutil"找不到软件包"libavformat"找不到软件包"libavcodec"找不到软件包"libswscale"如果您考虑考虑调整PKG_CONFIG_PATH环境变量以非标准前缀安装的软件.或者,您可以设置环境变量FFMPEG_CFLAGS和FFMPEG_LIBS避免需要调用pkg-config.有关更多详细信息,请参见pkg-config手册页.导出PATH和LIBRARY_PATH=====>下载Buildpack:https://github.com/heroku/heroku-buildpack-ruby 

解决方案

问题是您将 PKG_CONFIG_PATH 设置为不存在的目录.请注意, https://github.com/shunjikonishi/heroku-buildpack-ffmpeg 创建了构建dyno上的目录 $ BUILD_DIR/vendor/ffmpeg ,而不是/app/vendor/ffmpeg ,而 $ BUILD_DIR 类似于/tmp/build_< hash> .

如果您将变量分配更改为

  export PKG_CONFIG_PATH ="$ BUILD_DIR/vendor/ffmpeg/lib/pkgconfig" 

然后 configure 将找到这些库.

但是,还有一点.为此,有必要知道构建后 $ BUILD_DIR 中的内容是您的应用程序代码,并将在生产dynos上的/app 中.因此,在构建过程中, ffmpeg 的路径为 $ BUILD_DIR/vendor/ffmpeg ,而在生产过程中为/app/vendor/ffmpeg .

当前,

  ./configure --prefix/app/vendor/ffmpegthumbnailer&&进行安装 

您正在将 ffmpegthumbnailer 安装到应用程序插件之外的/app/vendor/ffmpegthumbnailer 中.但是,它确实是生产期间所需的位置,但这意味着它必须在构建结束时位于 $ BUILD_DIR/vendor/ffmpegthumbnailer 中.

实现此目的的一种方法是将您的东西配置并安装到/app ,然后将完成的安装目录复制到 $ BUILD_DIR .因此,您可以

  ./configure --prefix/app/vendor/ffmpegthumbnailer&&进行安装mkdir -p"$ BUILD_DIR"/供应商/ffmpegthumbnailercp -R/app/vendor/ffmpegthumbnailer/"$ BUILD_DIR"/vendor/ffmpegthumbnailer 

通过这种方式,用于 ./configure --prefix 的路径是在运行时有效的路径(否则在运行时出现问题), 我们的应用程序包中包含安装.

然后像您一样在运行时

设置 PATH LD_LIBRARY_PATH :

  echo'export PATH ="$ PATH:/app/vendor/ffmpegthumbnailer/bin"'>>"$ PROFILE_PATH"echo'export LD_LIBRARY_PATH ="$ LD_LIBRARY_PATH:/app/vendor/ffmpegthumbnailer/lib"'>>"$ PROFILE_PATH" 

因为这些是在运行时有效的路径.

实际上,所有这些都归结为等式 $ BUILD_DIR (build)== /app (production)

Before I elaborate on the problem, I should let you know that I've successfully installed ffmpegthumbnailer on heroku's bash (heroku run bash).

I'm trying to build ffmpegthumbnailer using a custom Heroku buildpack I've written, but when I run ./configure && make install in the bin/compile buildpack file, ffmpegthumbnailer tells me that it can't find the ffmpeg libs (util, format, codec, scale) and suggest that I set the PKG_CONFIG_PATH. So I set the PKG_CONFIG_PATH and it still can't seem to find the libraries.

I've tried setting the PKG_CONFIG_PATH every which way. echo export, export, directly set it via PKG_CONFIG_PATH=/app... I've always set it inline with the .configure command. I even set PKG_CONFIG_PATH as a heroku config var, and tried to acces it via the ENV_DIR variable that's passed into the buildpack as the third parameter, but I soon realized that I was simply setting a variable PKG_CONFIG_PATH to the contents of the file called PKG_CONFIG_PATH, i.e. I was setting PKG_CONFIG_PATH=/app/vendor..., which I've already done!! None of these have worked. Also, as you can see in the compile file and the log, echo $PKG_CONFIG_PATH prints the correct path.

What more debugging can i do? What is going on?

Below is my bin/compile buildpack file, and the log after I deploy my app to heroku.

#!/bin/sh

indent() {
  sed -u 's/^/       /'
}

echo "-----> Install ffmpeg-thumbnailer"
BUILD_DIR=$1
VENDOR_DIR="vendor"
DOWNLOAD_URL="https://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-2.0.8.tar.gz"

echo "DOWNLOAD_URL = " $DOWNLOAD_URL | indent

cd $BUILD_DIR
mkdir -p $VENDOR_DIR
cd $VENDOR_DIR
curl -L --silent $DOWNLOAD_URL | tar xz
cd ffmpegthumbnailer-2.0.8/
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/app/vendor/ffmpeg/lib/pkgconfig/"
echo $PKG_CONFIG_PATH
./configure --prefix /app/vendor/ffmpegthumbnailer && make install

echo "exporting PATH and LIBRARY_PATH" | indent
PROFILE_PATH="$BUILD_DIR/.profile.d/ffmpeg-thumbnailer.sh"
mkdir -p $(dirname $PROFILE_PATH)
echo 'export PATH="$PATH:vendor/ffmpeg-thumbnailer/bin"' >> $PROFILE_PATH
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:vendor/ffmpeg-thumbnailer/lib"' >> $PROFILE_PATH

And my heroku deployment log...

Fetching repository, done.
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 311 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
=====> Detected Framework: ffmpeg
-----> Install ffmpeg
       DOWNLOAD_URL =  http://flect.github.io/heroku-binaries/libs/ffmpeg.tar.gz
       exporting PATH and LIBRARY_PATH
=====> Downloading Buildpack: https://github.com/johnklawlor/heroku-buildpack-ffmpeg-thumbnailer
=====> Detected Framework: ffmpeg
-----> Install ffmpeg-thumbnailer
HERE COMES PKG_CONFIG!
/app/vendor/ffmpeg/lib/pkgconfig
       DOWNLOAD_URL =  https://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-2.0.8.tar.gz
/app/vendor/ffmpeg/lib/pkgconfig
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether make supports nested variables... yes
checking for ANSI C header files... (cached) yes
checking for inttypes.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking whether /usr/bin/ld -m elf_x86_64 accepts --as-needed... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for FFMPEG... no
configure: error: Package requirements (libavutil libavformat libavcodec >= 52.26.0 libswscale) were not met:

No package 'libavutil' found
No package 'libavformat' found
No package 'libavcodec' found
No package 'libswscale' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables FFMPEG_CFLAGS
and FFMPEG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
       exporting PATH and LIBRARY_PATH
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-ruby

解决方案

The problem is that you set PKG_CONFIG_PATH to a non-existing directory. Note that https://github.com/shunjikonishi/heroku-buildpack-ffmpeg creates the directory $BUILD_DIR/vendor/ffmpeg on the build dyno, and not /app/vendor/ffmpeg, and $BUILD_DIR is something like /tmp/build_<hash>.

If you change your variable assignment to

export PKG_CONFIG_PATH="$BUILD_DIR/vendor/ffmpeg/lib/pkgconfig"

then configure will find the libraries.

However, there's another point. For this, it's necessary to know that what's in $BUILD_DIR after the build is your application slug and will be in /app on the production dynos. Thus, the path to ffmpeg is $BUILD_DIR/vendor/ffmpeg during the build, but /app/vendor/ffmpeg during production.

Currently, with

./configure --prefix /app/vendor/ffmpegthumbnailer && make install

you are installing ffmpegthumbnailer to /app/vendor/ffmpegthumbnailer which is outside of your application slug. It is however indeed the location you want it during production, but this means that it must be in $BUILD_DIR/vendor/ffmpegthumbnailer at the end of the build.

One way to achieve this is to configure and install your things to /app and then copy the finished installation directory to $BUILD_DIR. Thus, you can do

./configure --prefix /app/vendor/ffmpegthumbnailer && make install
mkdir -p "$BUILD_DIR"/vendor/ffmpegthumbnailer
cp -R /app/vendor/ffmpegthumbnailer/ "$BUILD_DIR"/vendor/ffmpegthumbnailer

In this way, the path used for ./configure --prefix is the path valid at runtime (otherwise problems at runtime), and we have the installation included in our application slug.

Setting PATH and LD_LIBRARY_PATH at runtime is then done as you did:

echo 'export PATH="$PATH:/app/vendor/ffmpegthumbnailer/bin"' >>"$PROFILE_PATH"
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/vendor/ffmpegthumbnailer/lib"' >>"$PROFILE_PATH"

because these are the paths valid at runtime.

It in fact all boils down to the equation $BUILD_DIR (build) == /app (production)

这篇关于如何在Heroku buildpack中设置CONFIG_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆