-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.prod
42 lines (31 loc) · 1.24 KB
/
Dockerfile.prod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM ruby:2.6 AS webapp
ARG UNAME=app
ARG UID=1000
ARG GID=1000
RUN curl https://deb.nodesource.com/setup_18.x | bash
RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends nodejs yarn
RUN gem install bundler
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -d /usr/src/app -u $UID -g $GID -o -s /bin/bash $UNAME
RUN mkdir -p /gems && chown $UID:$GID /gems
COPY --chown=$UID:$GID Gemfile* /usr/src/app/
ENV RAILS_RELATIVE_URL_ROOT /m/middle-english-dictionary
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_ENV production
ENV BUNDLE_PATH /gems
# This can be anything but must be set.
ENV SECRET_KEY_BASE 121222bccca
WORKDIR /usr/src/app
RUN bundle install --without development test
COPY --chown=$UID:$GID . /usr/src/app
RUN RAILS_ENV=production bin/rails assets:precompile
RUN chown -R $UID:$GID /usr/src/app
USER $UNAME
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
FROM nginx:mainline AS assets
ENV NGINX_PORT=80
ENV NGINX_PREFIX=/
COPY --from=webapp /usr/src/app/nginx/assets.nginx /etc/nginx/templates/default.conf.template
COPY --from=webapp /usr/src/app/public /usr/share/nginx/html/