Last active
December 21, 2017 09:58
-
-
Save tonkla/b1513f93c7e6600420179b331c133bf0 to your computer and use it in GitHub Desktop.
Dockerfile of Ubuntu 16.04 + Ruby 2.3 + PostgreSQL 10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:16.04 | |
# Install required libraries | |
RUN apt-get update &&\ | |
apt-get upgrade -y &&\ | |
apt-get install -y --no-install-recommends \ | |
build-essential python-software-properties wget autoconf git-core curl \ | |
zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev \ | |
libcurl4-openssl-dev libffi-dev | |
# Install Ruby | |
ENV RUBY_MAJOR="2.3" \ | |
RUBY_VERSION="2.3.6" \ | |
RUBY_DOWNLOAD_SHA256="8322513279f9edfa612d445bc111a87894fac1128eaa539301cebfc0dd51571e" \ | |
RUBYGEMS_VERSION="2.7.3" \ | |
BUNDLER_VERSION="1.16.0" \ | |
GEM_HOME="/usr/local/bundle" | |
ENV BUNDLE_PATH="$GEM_HOME" \ | |
BUNDLE_BIN="$GEM_HOME/bin" \ | |
BUNDLE_SILENCE_ROOT_WARNING=1 \ | |
BUNDLE_APP_CONFIG="$GEM_HOME" | |
RUN mkdir -p /usr/local/etc \ | |
&& echo "gem: --no-document" > /usr/local/etc/gemrc \ | |
&& apt-get install -y --no-install-recommends bison libgdbm-dev ruby \ | |
&& wget "https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" -O /tmp/ruby.tar.gz \ | |
&& echo "$RUBY_DOWNLOAD_SHA256 /tmp/ruby.tar.gz" | sha256sum -c - \ | |
&& mkdir -p /usr/src/ruby \ | |
&& tar -xzf /tmp/ruby.tar.gz -C /usr/src/ruby --strip-components=1 \ | |
&& cd /usr/src/ruby \ | |
&& { \ | |
echo '#define ENABLE_PATH_CHECK 0'; \ | |
echo; \ | |
cat file.c; \ | |
} > file.c.new \ | |
&& mv file.c.new file.c \ | |
&& autoconf \ | |
&& ./configure --disable-install-doc \ | |
&& make -j"$(nproc)" \ | |
&& make install \ | |
&& apt-get purge -y --auto-remove bison libgdbm-dev ruby \ | |
&& cd / \ | |
&& rm -r /usr/src/ruby \ | |
&& gem update --system "$RUBYGEMS_VERSION" \ | |
&& gem install bundler --version "$BUNDLER_VERSION" \ | |
&& mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \ | |
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN" | |
# Install ImageMagick | |
RUN apt-get install -y imagemagick | |
# Install PostgreSQL v10 | |
# Note: Ubuntu-16.04 main repository provides only postgresql-9.5 | |
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list | |
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | |
RUN apt-get update | |
RUN apt-get install -y libpq-dev postgresql-10 | |
# Clean | |
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&\ | |
apt-get clean | |
# Run the rest of the commands as the `postgres` user | |
USER postgres | |
# Create a PostgreSQL role named `docker` with `docker` as the password | |
# and then create a database `docker` owned by the ``docker` role. | |
RUN /etc/init.d/postgresql start &&\ | |
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker_password';" &&\ | |
createdb -O docker docker | |
CMD [ "irb" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment