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

Ruby alpine #60

Merged
merged 2 commits into from Jan 29, 2016
Merged

Ruby alpine #60

merged 2 commits into from Jan 29, 2016

Conversation

ncopa
Copy link
Contributor

@ncopa ncopa commented Jan 6, 2016

No description provided.

@soullivaneuh
Copy link

Closes #62. Didn't see this PR.

👍

Could be possible to have alpine-slim variant too?

@ncopa
Copy link
Contributor Author

ncopa commented Jan 15, 2016

The one I provided corresponds to the slim variant.

I don't know if we want a non-slim variant for alpine? We don't have any buildpack-deps alpine variant (yet). Do we want that?

@soullivaneuh
Copy link

The one I provided corresponds to the slim variant.

That's what I need. But this could make used confused IMO.

Let's repo owners decide for this. 👍

@soullivaneuh
Copy link

I'm surprised of the size: https://travis-ci.org/docker-library/ruby/jobs/100615032#L1949

I made a Genghis Docker image based on Alpine with ruby base installed and this get less than 30 MB.

@ncopa
Copy link
Contributor Author

ncopa commented Jan 17, 2016

I made a Genghis Docker image based on Alpine with ruby base installed and this get less than 30 MB.

Yes, you used the alpine ruby package, which strips documentation, split out development headers, irb, static libraries and similar. The ruby:*-alpine docker images are closer to what upstream does and it also includes some build time dependencies similar to what debian based image does. (I suppose for building native extensions?)

ruby                2.3-alpine              b239b06f434c      11 days ago       121.2 MB
ruby                2.3-slim                a557ba5674a0      2 weeks ago       278.7 MB

@soullivaneuh
Copy link

you used the alpine ruby package, which strips documentation, split out development headers, irb, static libraries and similar.

This is what slim variant is made for, isn't it?

I suppose for building native extensions?

In my case, it's for a "ready to use" Ruby app that should no be extended on other Dockerfile, so I just need the minimal.

@yosifkit
Copy link
Member

diff --git a/2.3/slim/Dockerfile b/2.3/alpine/Dockerfile
index 4abb8ce..bcfd8ec 100644
--- a/2.3/slim/Dockerfile
+++ b/2.3/alpine/Dockerfile
@@ -1,17 +1,4 @@
-FROM debian:jessie
-
-RUN apt-get update \
-   && apt-get install -y --no-install-recommends \
-       bzip2 \
-       ca-certificates \
-       curl \
-       libffi-dev \
-       libgdbm3 \
-       libssl-dev \
-       libyaml-dev \
-       procps \
-       zlib1g-dev \
-   && rm -rf /var/lib/apt/lists/*
+FROM alpine:3.3

 ENV RUBY_MAJOR 2.3
 ENV RUBY_VERSION 2.3.0
@@ -19,41 +6,64 @@ ENV RUBY_DOWNLOAD_SHA256 ba5ba60e5f1aa21b4ef8e9bf35b9ddb57286cb546aac4b5a28c71f4
 ENV RUBYGEMS_VERSION 2.5.1

 # skip installing gem documentation
-RUN echo 'install: --no-document\nupdate: --no-document' >> "$HOME/.gemrc"
+RUN echo -e 'install: --no-document\nupdate: --no-document' >> "$HOME/.gemrc"

-# some of ruby's build scripts are written in ruby
-# we purge this later to make sure our final image uses what we just built
-RUN buildDeps=' \
+RUN set -x \
+   && apk add --no-cache --virtual .ruby-builddeps \
        autoconf \
        bison \
+       bzip2 \
+       bzip2-dev \
+       ca-certificates \
+       coreutils \
+       curl \
        gcc \
-       libbz2-dev \
-       libgdbm-dev \
-       libglib2.0-dev \
-       libncurses-dev \
-       libreadline-dev \
+       gdbm-dev \
+       glib-dev \
+       libc-dev \
+       libedit-dev \
+       libffi-dev \
        libxml2-dev \
        libxslt-dev \
+       linux-headers \
        make \
+       ncurses-dev \
+       openssl-dev \
+       procps \
        ruby \
-   ' \
-   && set -x \
-   && apt-get update \
-   && apt-get install -y --no-install-recommends $buildDeps \
-   && rm -rf /var/lib/apt/lists/* \
-   && mkdir -p /usr/src/ruby \
+       yaml-dev \
+       zlib-dev \
    && curl -fSL -o ruby.tar.gz "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" \
    && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \
-   && tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \
+   && mkdir -p /usr/src \
+   && tar -xzf ruby.tar.gz -C /usr/src \
+   && mv "/usr/src/ruby-$RUBY_VERSION" /usr/src/ruby \
    && rm ruby.tar.gz \
    && cd /usr/src/ruby \
    && autoconf \
-   && ./configure --disable-install-doc \
+   # the configure script does not detect isnan/isinf as macros
+   && ac_cv_func_isnan=yes ac_cv_func_isinf=yes ./configure --disable-install-doc \
    && make -j"$(nproc)" \
    && make install \
    && gem update --system $RUBYGEMS_VERSION \
-   && rm -r /usr/src/ruby \
-   && apt-get purge -y --auto-remove $buildDeps
+   && runDeps="$( \
+       scanelf --needed --nobanner --recursive /usr/local \
+           | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
+           | sort -u \
+           | xargs -r apk info --installed \
+           | sort -u \
+   )" \
+   && apk add --virtual .ruby-rundeps $runDeps \
+       bzip2 \
+       ca-certificates \
+       curl \
+       libffi-dev \
+       openssl-dev \
+       yaml-dev \
+       procps \
+       zlib-dev \
+   && apk del .ruby-builddeps \
+   && rm -r /usr/src/ruby

 # install things globally, for great justice
 ENV GEM_HOME /usr/local/bundle

@tianon
Copy link
Member

tianon commented Jan 29, 2016

LGTM

tianon added a commit that referenced this pull request Jan 29, 2016
@tianon tianon merged commit ae7dcbf into docker-library:master Jan 29, 2016
@tianon tianon mentioned this pull request Jan 29, 2016
tianon added a commit to infosiftr/stackbrew that referenced this pull request Jan 29, 2016
- `mariadb`: 10.1.11+maria-1~jessie, fix `pwgen` (MariaDB/mariadb-docker#40)
- `percona`: fix `pwgen` (docker-library/percona#13)
- `redis`: 3.0.7
- `ruby`: add new `alpine` variants (docker-library/ruby#60, docker-library/ruby#65)
RichardScothern pushed a commit to RichardScothern/official-images that referenced this pull request Jun 14, 2016
- `mariadb`: 10.1.11+maria-1~jessie, fix `pwgen` (MariaDB/mariadb-docker#40)
- `percona`: fix `pwgen` (docker-library/percona#13)
- `redis`: 3.0.7
- `ruby`: add new `alpine` variants (docker-library/ruby#60, docker-library/ruby#65)
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

Successfully merging this pull request may close these issues.

None yet

4 participants