1+ FROM ruby:3.0.3-slim
2+ WORKDIR /app
3+ RUN apt-get update -qq \
4+ && apt-get install -y --no-install-recommends build-essential curl git vim libpq-dev \
5+ && curl -sSL https://deb.nodesource.com/setup_14.x | bash - \
6+ && curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
7+ && echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list \
8+ && apt-get update && apt-get install -y --no-install-recommends nodejs yarn postgresql-client \
9+ && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
10+ && apt-get clean \
11+ && useradd --create-home forecasts \
12+ && chown forecasts:forecasts -R /app
13+
14+ COPY entrypoint.sh /usr/bin/
15+ RUN chmod +x /usr/bin/entrypoint.sh
16+
17+ USER forecasts
18+ ENV BUNDLER_VERSION 2.2.32
19+ COPY --chown=forecasts:forecasts Gemfile Gemfile.lock ./
20+
21+ RUN bundle config set --local deployment 'true' \
22+ && bundle config set --local without 'development test' \
23+ && bundle install \
24+ && rm -rf vendor/bundle/ruby/3.0.0/cache/*.gem \
25+ && find vendor/bundle/ruby/3.0.0/gems/ -name "*.c" -delete \
26+ && find vendor/bundle/ruby/3.0.0/gems/ -name "*.o" -delete
27+
28+ COPY --chown=forecasts:forecasts package.json yarn.lock ./
29+ RUN yarn install --frozen-lockfile --non-interactive --production
30+
31+ COPY --chown=forecasts:forecasts . .
32+ RUN rm entrypoint.sh
33+
34+ ENV PATH="${PATH}:/app/bin"
35+
36+ ENTRYPOINT ["entrypoint.sh" ]
37+ EXPOSE 3000
38+
39+ # precompile production app
40+ RUN RAILS_ENV=production SECRET_KEY_BASE=`rails secret` rails assets:precompile --trace \
41+ && yarn cache clean \
42+ && rm -rf tmp/cache vendor/assets test spec node_modules
43+
44+ # Configure the main process to run when running the image
45+ CMD ["rails" , "server" , "-b" , "0.0.0.0" ]
0 commit comments