|
1 | 1 | FROM ruby:2.4
|
2 | 2 |
|
3 | 3 |
|
4 |
| -# Install apt based dependencies required to run Rails as |
5 |
| -# well as RubyGems. As the Ruby image itself is based on a |
6 |
| -# Debian image, we use apt-get to install those. |
7 |
| -RUN apt-get update && apt-get install -y \ |
8 |
| - build-essential \ |
9 |
| - nodejs |
| 4 | +# Download all the dependencies including node and yarn. Also, set localtime |
| 5 | +# TODO: do this also in staging and production |
| 6 | +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ |
| 7 | + && curl -sL https://deb.nodesource.com/setup_9.x | bash - \ |
| 8 | + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ |
| 9 | + && apt-get update \ |
| 10 | + && apt-get install -qq -y --no-install-recommends build-essential nodejs yarn \ |
| 11 | + && rm -rf /var/lib/apt/lists/* \ |
| 12 | + && cp /usr/share/zoneinfo/Europe/Rome /etc/localtime |
10 | 13 |
|
11 | 14 | # Configure the main working directory. This is the base
|
12 | 15 | # directory used in any further RUN, COPY, and ENTRYPOINT
|
13 | 16 | # commands.
|
14 | 17 | RUN mkdir -p /app
|
15 | 18 | WORKDIR /app
|
16 | 19 |
|
| 20 | +ENV BUNDLE_PATH=/bundle \ |
| 21 | + BUNDLE_BIN=/bundle/bin \ |
| 22 | + GEM_HOME=/bundle |
| 23 | +ENV PATH="${BUNDLE_BIN}:${PATH}" |
| 24 | +# Bundle installs with binstubs to our custom /bundle/bin volume path. Let system use those stubs. |
| 25 | + |
17 | 26 | # Copy the Gemfile as well as the Gemfile.lock and install
|
18 | 27 | # the RubyGems. This is a separate step so the dependencies
|
19 | 28 | # will be cached unless changes to one of those two files
|
20 | 29 | # are made.
|
21 | 30 | COPY Gemfile Gemfile.lock ./
|
22 |
| -RUN gem install bundler && bundle install --jobs 20 --retry 5 |
| 31 | +RUN gem install bundler \ |
| 32 | + && bundle install --jobs 20 --retry 5 |
23 | 33 |
|
24 | 34 | # Copy the main application.
|
25 | 35 | COPY . ./
|
26 | 36 |
|
| 37 | +RUN bin/yarn |
| 38 | + |
27 | 39 | # Expose port 3000 to the Docker host, so we can access it
|
28 | 40 | # from the outside.
|
29 | 41 | EXPOSE 3000
|
30 | 42 |
|
31 |
| -# Configure an entry point, so we don't need to specify |
32 |
| -# "bundle exec" for each of our commands. |
33 |
| -ENTRYPOINT ["bundle", "exec"] |
| 43 | +# Entrypoint |
| 44 | +COPY ./docker-entrypoint.sh / |
| 45 | +RUN chmod +x /docker-entrypoint.sh |
| 46 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
34 | 47 |
|
35 |
| -# The main command to run when the container starts. Also |
36 |
| -# tell the Rails dev server to bind to all interfaces by |
37 |
| -# default. |
38 |
| -CMD ["rails", "server", "-b", "0.0.0.0"] |
| 48 | +CMD bundle exec puma |
0 commit comments