Skip to content
Rick Zhang edited this page Aug 11, 2020 · 1 revision
  1 FROM ruby:2.5.6-slim-stretch                                                          
  2 WORKDIR /tmp
  3 
  4 RUN apt update \
  5  && apt install -y dirmngr gnupg apt-transport-https \
  6  && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2    F7 \ 
  7  && echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sourc    es.list \
  8  && echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger stretch main"     >> /etc/apt/sources.list.d/passenger.list \
  9  && apt update \
 10  && apt install -y \
 11                    nodejs \
 12                    libpq-dev \ 
 13                    build-essential \
 14                    apache2-dev \
 15                    libapache2-mod-passenger \
 16                    certbot python-certbot-apache \
 17                    cron \
 18  && apt -t stretch-backports install -y libapache2-mod-shib
 19 
 20 COPY Gemfile* ./
 21 RUN bundle check || bundle install --jobs 4 --without development test
 22 
 23 COPY . /application
 24 WORKDIR /application
 25 RUN bundle exec rake assets:clean \
 26  && bundle exec rake assets:precompile
 27 
 28 CMD ["bash", "entrypoint.sh"]

1: "import" the base layer, which is a Debian Linux image that has Ruby 2.5.6 pre-installed.
2: cd to a temporary folder, /tmp.
4-18: install a bunch of dependencies.
20: copy over the Gemfile and Gemfile.lock from the host machine to the image.
21: run bundle install, which installs the project's gem dependencies.
23: copy everything in the host machine's project directory to /application on the image.
24: cd to /application.
25-26: clean, then compile the JS/CSS assets.
28: configure "entrypoint.sh" to be the startup script. This does NOT run the script just yet. The script is run when we decide to run the image, which creates a container.

Clone this wiki locally