diff --git a/Dockerfile b/Dockerfile index b94b998..581f9a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,10 @@ ENV HTTP_BASIC_PASSWORD=gibberish ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=1 ENV EXTRA_PKGS='' +RUN id RUN gem install --no-user-install --no-document --source https://rubygems.org geminabox mini_portile2 gem-compiler -COPY ./gemcompiler.sh /usr/local/bin/gemcompiler +COPY ./gem-compiler.sh /usr/local/bin/gem-compiler COPY ./bootstrap.sh /usr/local/bin/bootstrap RUN install -dm 2750 -o builder -g builder /srv/gems @@ -21,4 +22,4 @@ VOLUME /srv/gems RUN apk add --no-cache su-exec file-dev libssh2-dev libc6-compat libstdc++ -ENTRYPOINT /usr/local/bin/bootstrap +ENTRYPOINT /bin/sh diff --git a/bootstrap.sh b/bootstrap.sh index a3b9014..30e8434 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,7 +1,6 @@ #!/bin/sh set -e -set -x test -n "${EXTRA_PKGS}" && apk add --no-cache ${EXTRA_PKGS} -su-exec builder /usr/local/bin/gemcompiler +su-exec builder /usr/local/bin/gem-compiler diff --git a/gem-compiler.sh b/gem-compiler.sh new file mode 100755 index 0000000..de98aee --- /dev/null +++ b/gem-compiler.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +test -n "${GEM_NAME}" +test -n "${GEM_VERSION}" +test -n "${HTTP_BASIC_USER}" +test -n "${HTTP_BASIC_PASSWORD}" +test -n "${SUTTY}" +test -n "${PLATFORM}" + +# TODO: Support multiple Alpine/Ruby versions +gem fetch --source=https://gems.${SUTTY} --platform=ruby --version ${VERSION} ${GEM} +gem compile -V --prune --strip "strip --strip-unneeded" "${GEM}-${VERSION}.gem" +gem inabox -o "${GEM}-${VERSION}-${PLATFORM}.gem" --host https://${HTTP_BASIC_USER}:${HTTP_BASIC_PASSWORD}@gems.${SUTTY} diff --git a/gemcompiler.sh b/gemcompiler.sh deleted file mode 100755 index b753769..0000000 --- a/gemcompiler.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -set -e - -# CCache -export PATH=/usr/lib/ccache/bin:$PATH - -source /etc/os-release -alpine_version="${VERSION_ID%.*}" -platform="`ruby -e "puts RbConfig::CONFIG['arch']"`" -gems_dir="${GEMS_DIR:-/srv/gems}" -cache_dir="${gems_dir}/cache" -release_dir="${RELEASE_DIR:-${gems_dir}/${alpine_version}}" - -mkdir -p "${cache_dir}" "${release_dir}" - -gem="${GEM}-${VERSION}.gem" -release="${GEM}-${VERSION}-${platform}.gem" - -if ! test -f "${cache_dir}/${gem}" ; then - cd "${cache_dir}" - gem fetch --source=https://gems.${SUTTY} --platform=ruby --version ${VERSION} ${GEM} -fi - -if ! test -f "${release_dir}/${release}"; then - cd "${release_dir}" - gem compile -V --prune --strip "strip --strip-unneeded" "${cache_dir}/${gem}" -fi - -test -f "${release_dir}/${release}" \ - && gem inabox -o "${release_dir}/${release}" --host https://${HTTP_BASIC_USER}:${HTTP_BASIC_PASSWORD}@gems.${SUTTY}