2

我不确定这是否是问这个问题的正确地方。我会尽力。如果不符合要求,请关闭。

我在 dockerizing octopress 以在 github.io 上发布内容时遇到问题,特别是使用 Alpine Linux。

这是我的 Dockerfile:

FROM alpine:edge
MAINTAINER Emanuele Ianni <dierre@gmail.com>

ENV BUILD_PACKAGES bash curl-dev build-base git
ENV RUBY_PACKAGES ruby ruby-dev ruby-io-console ruby-bundler
ENV EXECJS_DEPENDENCY nodejs
ENV GIT_URL https://github.com/invasionofsmallcubes/invasionofsmallcubes.github.io.git

# Update and install all of the required packages.
# At the end, remove the apk cache
RUN apk update && \
    apk upgrade && \
    apk add $BUILD_PACKAGES && \
    apk add $RUBY_PACKAGES && \
    apk add $EXECJS_DEPENDENCY && \
    rm -rf /var/cache/apk/*

# RUN gem install --no-rdoc --no-ri posix-spawn -v 0.3.11
RUN gem install --no-rdoc --no-ri execjs

# cloning existing octopress repo
WORKDIR ~
RUN git clone $GIT_URL octopress
WORKDIR octopress
RUN gem install --no-rdoc --no-ri bundler

它在这里中断,这是第 12 步的一部分RUN bundle install

    Installing posix-spawn 0.3.6 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20150914-5-1oxh9qm.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling posix-spawn.c
In file included from /usr/include/ruby-2.2.0/ruby/ruby.h:24:0,
                 from /usr/include/ruby-2.2.0/ruby.h:33,
                 from posix-spawn.c:14:
/usr/include/ruby-2.2.0/x86_64-linux-musl/ruby/config.h:17:0: warning: "_GNU_SOURCE" redefined
 #define _GNU_SOURCE 1
 ^
posix-spawn.c:3:0: note: this is the location of the previous definition
 #define _GNU_SOURCE
 ^
posix-spawn.c: In function 'rb_posixspawn_pspawn':
posix-spawn.c:403:11: error: 'POSIX_SPAWN_USEVFORK' undeclared (first use in this function)
  flags |= POSIX_SPAWN_USEVFORK;
           ^
posix-spawn.c:403:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:237: recipe for target 'posix-spawn.o' failed
make: *** [posix-spawn.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/lib/ruby/gems/2.2.0/gems/posix-spawn-0.3.6 for inspection.
Results logged to /usr/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/posix-spawn-0.3.6/gem_make.out
An error occurred while installing posix-spawn (0.3.6), and Bundler cannot
continue.
Make sure that `gem install posix-spawn -v '0.3.6'` succeeds before bundling.
The command '/bin/sh -c bundle install' returned a non-zero code: 5

我在安装更高版本的 posix-spawn 时没有问题,但这是捆绑安装所需的。

如果我使用 Ubuntu 运行该文件,则不会出现此错误:

Installing syntax 1.0.0
Installing maruku 0.6.1
Installing posix-spawn 0.3.6 with native extensions
Installing yajl-ruby 1.1.0 with native extensions

我已经安装了 ruby​​-dev 所以我认为这就足够了。你知道我还有什么可以检查的吗?

4

1 回答 1

3

Alpine Linux 使用 musl libc 而不是 glibc,这有时会导致边缘情况出现问题。请参阅rtomayko/posix-spawn 的问题 #54

如果您坚持使用 Alpine,我可以想到几种可能的解决方案。首先是查看Alpine 上 posix-spawn 的这个实验包。当然,您必须在http://dl-4.alpinelinux.org/alpine/edge/testing/x86_64/添加 edge/testing 存储库

或者,您可以为 Alpine 安装一个实验性的 glibc 包。这是一个用于安装 Java 8 JDK 以帮助您入门的示例:https ://github.com/sillelien/base-java/blob/master/Dockerfile (特别是第 10-16 行)。

当然,debian:jessie如果你不能让其他任何东西工作,你总是可以使用(或 Ubuntu)而不是 Alpine。那不会是世界末日,但作为 Alpine 的粉丝,如果您想继续尝试变通办法让 Octopress 在 Alpine 上工作,我会理解。

希望这可以帮助!

于 2015-09-14T09:49:54.027 回答