12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

alpineベースでrubyをdocker buildしてみた

Posted at

TL;DR

  • aplineをベースにしてrubyをdocker buildをしてみた
  • rubyはpackageからではなく独自compileしてbuild

Dockerfile

FROM alpine

ENV HOME     /root

WORKDIR /tmp

# SETUP: package install
RUN apk add --no-cache --virtual .ruby-builddeps \
    autoconf \
    bison \
    bzip2 \
    bzip2-dev \
    ca-certificates \
    coreutils \
    curl \
    gcc \
    g++ \
    make \
    gdbm-dev \
    glib-dev \
    libc-dev \
    libedit-dev \
    libffi-dev \
    libxml2-dev \
    libxslt-dev \
    linux-headers \
    cyrus-sasl-dev \
    ncurses-dev \
    openssl-dev \
    procps \
    tcl-dev \
    yaml-dev \
    zlib-dev \
    tar \
    perl \
    python \
    py-pip \
    libmemcached-libs \
    mariadb mariadb-client mariadb-libs mariadb-dev

# SETUP: ruby & bundler
ENV RUBY_MAJOUR_VER  2.3
ENV RUBY_VERSION     2.3.0

RUN wget -q "http://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOUR_VER}/ruby-${RUBY_VERSION}.tar.gz" -O ruby-${RUBY_VERSION}.tar.gz && \
    tar zxf ruby-${RUBY_VERSION}.tar.gz && \
    cd ruby-${RUBY_VERSION} && \
    ./configure --disable-install-doc --disable-install-rdoc && make && make install && \
    cd .. && \
    rm -rf /tmp/* && \
    echo "install: --no-document" > $HOME/.gemrc && \
    echo "update: --no-document" >> $HOME/.gemrc && \
    gem install bundler
  • VIRTUAL SIZE : 773.3 MB

package

  • https://pkgs.alpinelinux.org/packages で検索できる
    • 部分一致で検索するには % のwildcard文字が必要
  • CentOS,Ubuntuとは微妙にpackage名が異なるので注意
    • xxx-dev などになっている
  • それなりに新しめversionのpackageになっている

独自compileしない場合

FROM alpine
RUN apk add --no-cache ruby ruby-bundler

感想

  • 軽量なalpinelinuxをベースにしても、諸々組み込んでいくと、それなりのサイズのimageになってしまう
  • もちろん不要なpackageを取り除いていけば小さくなる
12
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?