Skip to content

Dockerfile improvements #342

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine:%%PLACEHOLDER%%

SHELL ["/usr/bin/env", "sh", "-eux", "-c"]

RUN apk add --no-cache \
gmp-dev

Expand All @@ -20,9 +22,7 @@ ENV RUBYGEMS_VERSION %%RUBYGEMS%%
# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
# readline-dev vs libedit-dev: https://bugs.ruby-lang.org/issues/11869 and https://github.com/docker-library/ruby/issues/75
RUN set -eux; \
\
apk add --no-cache --virtual .ruby-builddeps \
RUN apk add --no-cache --virtual .ruby-builddeps \
autoconf \
bison \
bzip2 \
Expand Down Expand Up @@ -111,12 +111,13 @@ RUN set -eux; \
rm -r /usr/src/ruby; \
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
gem update --system "$RUBYGEMS_VERSION"; \
rm -fr /root/.gem/; \
# verify we have no "ruby" packages installed
! apk --no-network list --installed \
if apk --no-network list --installed \
| grep -v '^[.]ruby-rundeps' \
| grep -i ruby \
; \
; then false; fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
Expand All @@ -129,6 +130,6 @@ ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
RUN mkdir -p "$GEM_HOME"; chmod 777 "$GEM_HOME"

CMD [ "irb" ]
17 changes: 9 additions & 8 deletions Dockerfile-debian.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM buildpack-deps:%%PLACEHOLDER%%

SHELL ["/bin/bash", "-eux", "-c"]

# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
RUN mkdir -p /usr/local/etc; \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
Expand All @@ -16,9 +17,7 @@ ENV RUBYGEMS_VERSION %%RUBYGEMS%%

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
RUN savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
Expand Down Expand Up @@ -61,6 +60,7 @@ RUN set -eux; \
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| grep -vF '/usr/local/lib' \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
Expand All @@ -72,9 +72,10 @@ RUN set -eux; \
rm -r /usr/src/ruby; \
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
gem update --system "$RUBYGEMS_VERSION"; \
rm -fr /root/.gem/; \
# verify we have no "ruby" packages installed
! dpkg -l | grep -i ruby; \
if dpkg -l | grep -i 'ruby'; then false; fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
Expand All @@ -87,6 +88,6 @@ ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
RUN mkdir -p "$GEM_HOME"; chmod 777 "$GEM_HOME"

CMD [ "irb" ]
20 changes: 10 additions & 10 deletions Dockerfile-slim.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM debian:%%PLACEHOLDER%%

RUN set -eux; \
apt-get update; \
SHELL ["/bin/bash", "-eux", "-c"]

RUN apt-get update; \
apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
Expand All @@ -15,8 +16,7 @@ RUN set -eux; \
rm -rf /var/lib/apt/lists/*

# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
RUN mkdir -p /usr/local/etc; \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
Expand All @@ -30,9 +30,7 @@ ENV RUBYGEMS_VERSION %%RUBYGEMS%%

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
RUN savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
autoconf \
Expand Down Expand Up @@ -87,6 +85,7 @@ RUN set -eux; \
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| grep -vF '/usr/local/lib' \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
Expand All @@ -98,9 +97,10 @@ RUN set -eux; \
rm -r /usr/src/ruby; \
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
gem update --system "$RUBYGEMS_VERSION"; \
rm -r /root/.gem/; \
# verify we have no "ruby" packages installed
! dpkg -l | grep -i ruby; \
if dpkg -l | grep -i 'ruby'; then false; fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
Expand All @@ -113,6 +113,6 @@ ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
RUN mkdir -p "$GEM_HOME"; chmod 777 "$GEM_HOME"

CMD [ "irb" ]