|
1 | | -FROM registry.access.redhat.com/ubi8/ruby-31 |
| 1 | +FROM ruby:3.3-slim AS base |
2 | 2 | USER root |
3 | 3 |
|
4 | 4 | # Configure users and groups |
5 | 5 | RUN groupadd -g 40054 alma && \ |
6 | 6 | useradd -r -s /sbin/nologin -M -u 40054 -g alma alma && \ |
| 7 | + useradd -u 40061 bfs && \ |
7 | 8 | groupadd -g 40061 bfs && \ |
8 | 9 | usermod -u 40061 -g bfs -G alma -l bfs default && \ |
9 | 10 | find / -user 1001 -exec chown -h bfs {} \; || true && \ |
10 | 11 | mkdir -p /opt/app && \ |
11 | 12 | chown -R bfs:bfs /opt/app |
12 | 13 |
|
| 14 | +# Get list of available packages |
| 15 | +RUN apt-get -y update -qq |
| 16 | + |
| 17 | +COPY --chown=bfs . /opt/app |
| 18 | + |
| 19 | +ENTRYPOINT ["/opt/app/bin/bfs"] |
| 20 | +CMD ["help"] |
| 21 | + |
| 22 | +# =============================================== |
| 23 | +# Target: development |
| 24 | +# =============================================== |
| 25 | + |
| 26 | +FROM base AS development |
| 27 | + |
| 28 | +USER root |
| 29 | + |
| 30 | +RUN apt-get -y --no-install-recommends install \ |
| 31 | + build-essential \ |
| 32 | + make |
| 33 | + |
| 34 | +USER bfs |
| 35 | + |
| 36 | +# Base image ships with an older version of bundler |
| 37 | +RUN gem install bundler --version 2.5.22 |
| 38 | + |
13 | 39 | WORKDIR /opt/app |
14 | 40 | COPY --chown=bfs Gemfile* .ruby-version ./ |
15 | 41 | RUN bundle config set force_ruby_platform true |
16 | 42 | RUN bundle config set system 'true' |
17 | 43 | RUN bundle install |
18 | | -COPY --chown=bfs . . |
19 | 44 |
|
20 | | -USER bfs |
21 | | -ENTRYPOINT ["/opt/app/bin/bfs"] |
22 | | -CMD ["help"] |
| 45 | +# COPY --chown=bfs:bfs . . |
| 46 | + |
| 47 | +# ================================= |
| 48 | +# Target: production |
| 49 | +# ================================= |
| 50 | +FROM base AS production |
| 51 | + |
| 52 | +# Copy the built codebase from the dev stage |
| 53 | +# COPY --from=development --chown=bfs /opt/app /opt/app |
| 54 | +COPY --from=development --chown=bfs /usr/local/bundle /usr/local/bundle |
| 55 | + |
| 56 | +WORKDIR /opt/app |
| 57 | +RUN bundle config set frozen 'true' |
| 58 | +RUN bundle install --local |
0 commit comments