|
| 1 | +ARG BASE_IMAGE=docker.io/library/ruby:3.2-alpine |
| 2 | + |
| 3 | +FROM $BASE_IMAGE AS builder |
| 4 | + |
| 5 | +# Gems have to be ARG and ENV because they are used as reference in the Gemfile |
| 6 | +ARG RUBYGEM_BUNDLER |
| 7 | +ARG RUBYGEM_OPENBOLT |
| 8 | + |
| 9 | +ENV RUBYGEM_BUNDLER=${RUBYGEM_BUNDLER:-2.7.2} |
| 10 | +ENV RUBYGEM_OPENBOLT=${RUBYGEM_OPENBOLT:-5.2.0} |
| 11 | + |
| 12 | +COPY openbolt/Gemfile / |
| 13 | + |
| 14 | +RUN apk update \ |
| 15 | + && apk upgrade \ |
| 16 | + && apk add --no-cache --update alpine-sdk yaml-dev \ |
| 17 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/bundler-* \ |
| 18 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/bundler-*.gemspec \ |
| 19 | + && gem install bundler -v ${RUBYGEM_BUNDLER} \ |
| 20 | + && bundle config set path.system true \ |
| 21 | + && bundle config set jobs $(nproc) \ |
| 22 | + && bundle install --gemfile=/Gemfile \ |
| 23 | + && bundle clean --force \ |
| 24 | + && rm -rf /usr/local/lib/ruby/gems/*/cache/* \ |
| 25 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/cgi-* \ |
| 26 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/cgi-*.gemspec \ |
| 27 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/stringio-* \ |
| 28 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/stringio-*.gemspec \ |
| 29 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/rdoc-* \ |
| 30 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/rdoc-*.gemspec \ |
| 31 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/rexml-* \ |
| 32 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/rexml-*.gemspec \ |
| 33 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/racc-* \ |
| 34 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/racc-*.gemspec \ |
| 35 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/drb-* \ |
| 36 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/drb-*.gemspec \ |
| 37 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/csv-* \ |
| 38 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/default/csv-*.gemspec \ |
| 39 | + && rm -rf /usr/local/lib/ruby/gems/*/gems/minitest-* \ |
| 40 | + && rm -rf /usr/local/lib/ruby/gems/*/specifications/minitest-*.gemspec |
| 41 | + |
| 42 | +############################################################################### |
| 43 | + |
| 44 | +FROM $BASE_IMAGE AS final |
| 45 | + |
| 46 | +LABEL org.label-schema.maintainer="Voxpupuli Team <voxpupuli@groups.io>" \ |
| 47 | + org.label-schema.vendor="Voxpupuli" \ |
| 48 | + org.label-schema.url="https://github.com/openvoxproject/container-openbolt^" \ |
| 49 | + org.label-schema.name="Vox Pupuli OpenBolt" \ |
| 50 | + org.label-schema.license="AGPL-3.0-or-later" \ |
| 51 | + org.label-schema.vcs-url="https://github.com/openvoxproject/container-openbolt" \ |
| 52 | + org.label-schema.schema-version="1.0" \ |
| 53 | + org.label-schema.dockerfile="/Containerfile" |
| 54 | + |
| 55 | +RUN apk update \ |
| 56 | + && apk upgrade \ |
| 57 | + && rm -rf /usr/local/lib/ruby/gems \ |
| 58 | + && addgroup -g 1001 -S openbolt \ |
| 59 | + && adduser -u 1001 -S -G openbolt openbolt \ |
| 60 | + && rm -rf /usr/local/lib/ruby/gems \ |
| 61 | + && mkdir /data \ |
| 62 | + && chown openbolt:openbolt /data |
| 63 | + |
| 64 | +COPY --from=builder /usr/local/lib/ruby/gems /usr/local/lib/ruby/gems |
| 65 | +COPY --from=builder /usr/local/bundle /usr/local/bundle |
| 66 | +COPY --from=builder /Gemfile.lock /Gemfile.lock |
| 67 | +COPY Containerfile / |
| 68 | +COPY openbolt/Gemfile / |
| 69 | + |
| 70 | +WORKDIR /data |
| 71 | +USER openbolt |
| 72 | + |
| 73 | +ENTRYPOINT [ "bolt" ] |
| 74 | +CMD [ "-h" ] |
0 commit comments