11# system dependency image
2- FROM ruby:2.7.8-bullseye AS essi-sys-deps
2+ FROM buildpack-deps:bookworm AS ruby-278-bookworm
3+
4+ # skip installing gem documentation with `gem install`/`gem update`
5+ RUN set -eux; \
6+ mkdir -p /usr/local/etc; \
7+ echo 'gem: --no-document' >> /usr/local/etc/gemrc
8+
9+ ENV LANG=C.UTF-8
10+
11+ # Ruby 2.7.8 (note: this version is EOL)
12+ ENV RUBY_VERSION=2.7.8 \
13+ RUBY_DOWNLOAD_URL=https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.8.tar.xz \
14+ RUBY_DOWNLOAD_SHA256=f22f662da504d49ce2080e446e4bea7008cee11d5ec4858fc69000d0e5b1d7fb
15+
16+ # OpenSSL 1.1.1 compatibility version for Ruby 2.7.8
17+ ENV OPENSSL_VERSION=1.1.1w \
18+ OPENSSL_DOWNLOAD_URL=https://www.openssl.org/source/openssl-1.1.1w.tar.gz \
19+ OPENSSL_DOWNLOAD_SHA256=cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
20+
21+ RUN set -eux; \
22+ # Compile OpenSSL 1.1.1 from source
23+ wget -O openssl.tar.gz "$OPENSSL_DOWNLOAD_URL" ; \
24+ echo "$OPENSSL_DOWNLOAD_SHA256 *openssl.tar.gz" | sha256sum --check --strict; \
25+ mkdir -p /usr/src/openssl; \
26+ tar -xzf openssl.tar.gz -C /usr/src/openssl --strip-components=1; \
27+ rm openssl.tar.gz; \
28+ cd /usr/src/openssl; \
29+ ./config --prefix=/usr/local/openssl-1.1.1 shared zlib; \
30+ make -j "$(nproc)" ; \
31+ make install_sw; \
32+ cd /; \
33+ \
34+ # Download Ruby
35+ wget -O ruby.tar.xz "$RUBY_DOWNLOAD_URL" ; \
36+ echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
37+ \
38+ mkdir -p /usr/src/ruby; \
39+ tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
40+ rm ruby.tar.xz; \
41+ \
42+ cd /usr/src/ruby; \
43+ \
44+ # Export environment variables for build
45+ export rb_cv_wide_so_suffix=yes; \
46+ export rb_cv_binary_compile_options=yes; \
47+ \
48+ autoconf; \
49+ gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ; \
50+ ./configure \
51+ --build="$gnuArch" \
52+ --disable-install-doc \
53+ --enable-shared \
54+ --with-openssl-dir=/usr/local/openssl-1.1.1 \
55+ ; \
56+ \
57+ make -j "$(nproc)" ; \
58+ make install; \
59+ \
60+ # Create symlinks for OpenSSL libraries to ensure Ruby can find them at runtime
61+ ln -sf /usr/local/openssl-1.1.1/lib/libssl.so.1.1 /usr/lib/; \
62+ ln -sf /usr/local/openssl-1.1.1/lib/libcrypto.so.1.1 /usr/lib/; \
63+ \
64+ rm -rf /var/lib/apt/lists/*; \
65+ \
66+ cd /; \
67+ rm -r /usr/src/ruby; \
68+ rm -r /usr/src/openssl; \
69+ # verify we have no "ruby" packages installed
70+ [ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
71+ # rough smoke test
72+ ruby --version; \
73+ gem --version; \
74+ bundle --version
75+
76+ # don't create ".bundle" in all our apps
77+ ENV GEM_HOME=/usr/local/bundle
78+ ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
79+ BUNDLE_APP_CONFIG="$GEM_HOME" \
80+ PATH=$GEM_HOME/bin:$PATH \
81+ LD_LIBRARY_PATH=/usr/local/openssl-1.1.1/lib:$LD_LIBRARY_PATH
82+
83+ RUN set -eux; \
84+ mkdir -p "$GEM_HOME" ; \
85+ # adjust permissions of GEM_HOME for running "gem install" as an arbitrary user
86+ chmod 1777 "$GEM_HOME"
87+
88+ CMD [ "irb" ]
89+
90+
91+ FROM ruby-278-bookworm AS essi-sys-deps
392
493ARG USER_ID=1000
594ARG GROUP_ID=1000
695
796RUN groupadd -g ${GROUP_ID} essi && \
897 useradd -m -l -g essi -u ${USER_ID} essi && \
9- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
10- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
11- curl -sL https://deb.nodesource.com/setup_16 .x | bash - && \
98+ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn-archive-keyring.gpg > /dev/null && \
99+ echo "deb [signed-by=/etc/apt/keyrings/yarn-archive-keyring.gpg] https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
100+ curl -sL https://deb.nodesource.com/setup_24 .x | bash - && \
12101 apt-get update -qq && \
13102 apt-get install -y --no-install-recommends build-essential default-jre-headless libpq-dev nodejs \
14103 libreoffice-writer libreoffice-impress poppler-utils unzip ghostscript \
15- libtesseract-dev libleptonica-dev liblept5 tesseract-ocr \
104+ libtesseract-dev libleptonica-dev tesseract-ocr \
105+ libpng-dev libtiff-dev librsvg2-dev libpango1.0-dev \
16106 yarn libopenjp2-tools libjemalloc2 && \
17107 apt-get clean all && rm -rf /var/lib/apt/lists/* && \
18108 ln -s /usr/lib/*-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so.2
@@ -24,14 +114,14 @@ RUN mkdir -p /opt/fits && \
24114 cd /opt/fits && unzip fits-1.5.5.zip && rm fits-1.5.5.zip && chmod +X fits.sh && \
25115 sed -i 's/\( <tool.*TikaTool.*>\) /<!--\1 -->/ ; s/\( <tool.*FFIdent.*>\) /<!--\1 -->/' /opt/fits/xml/fits.xml && \
26116 sed -i "s/exiftool\/ ImageWidth\[ last()\] /substring-before(exiftool\/ ImageSize, 'x')/ ; s/exiftool\/ ImageHeight\[ last()\] /substring-after(exiftool\/ ImageSize, 'x')/" /opt/fits/xml/exiftool/exiftool_image_to_fits.xslt
27- ENV PATH /opt/fits:$PATH
28- ENV RUBY_THREAD_MACHINE_STACK_SIZE 16777216
29- ENV RUBY_THREAD_VM_STACK_SIZE 16777216
30- ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so.2
117+ ENV PATH=/opt/fits:$PATH \
118+ RUBY_THREAD_MACHINE_STACK_SIZE=16777216 \
119+ RUBY_THREAD_VM_STACK_SIZE=16777216 \
120+ LD_PRELOAD=/usr/local/lib/libjemalloc.so.2 \
121+ NODE_OPTIONS=--openssl-legacy-provider
31122
32123# Installs specific version of ImageMagick to work with iiif_print
33- RUN wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-57.tar.gz && \
34- tar xf 7.1.0-57.tar.gz && apt-get install -y libpng-dev libtiff-dev librsvg2-dev && \
124+ RUN curl -s -L https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.2-27.tar.gz | tar xvz && \
35125 cd ImageMagick* && ./configure && make install && cd $OLDPWD && rm -rf ImageMagick* && \
36126 sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf' && ldconfig
37127
@@ -51,13 +141,13 @@ COPY --chown=essi:essi Gemfile Gemfile.lock ./
51141# hold back from bundler 2.5 onwards until ruby is updated
52142# RUN gem update bundler
53143RUN gem install bundler -v "~> 2.4.22"
54- RUN bundle install -j 2 - -retry=3
144+ RUN bundle install --retry=3
55145
56146COPY --chown=essi:essi . .
57147
58148RUN mkdir /app/tmp/cache
59149
60- ENV RAILS_LOG_TO_STDOUT true
150+ ENV RAILS_LOG_TO_STDOUT= true
61151
62152# ##
63153# ruby dependencies image
@@ -77,30 +167,30 @@ COPY --chown=essi:essi Gemfile Gemfile.lock ./
77167# hold back from bundler 2.5 onwards until ruby is updated
78168# RUN gem update bundler && \
79169RUN gem install bundler -v "~> 2.4.22" && \
80- bundle install -j 2 - -retry=3 --deployment --without development
170+ bundle install --retry=3 --deployment --without development
81171
82172COPY --chown=essi:essi . .
83173
84- ENV RAILS_LOG_TO_STDOUT true
85- ENV RAILS_ENV production
86- ENV SKIP_IIIF_PRINT_BULKRAX_VERSION_REQUIREMENT true
174+ ENV RAILS_LOG_TO_STDOUT= true \
175+ RAILS_ENV= production \
176+ SKIP_IIIF_PRINT_BULKRAX_VERSION_REQUIREMENT= true
87177
88178ENTRYPOINT ["bundle" , "exec" ]
89179
90180# ##
91181# sidekiq image
92- FROM essi-deps as essi-sidekiq
182+ FROM essi-deps AS essi-sidekiq
93183USER essi:essi
94184ARG SOURCE_COMMIT
95- ENV SOURCE_COMMIT $SOURCE_COMMIT
185+ ENV SOURCE_COMMIT= $SOURCE_COMMIT
96186CMD sidekiq
97187
98188# ##
99189# webserver image
100- FROM essi-deps as essi-web
190+ FROM essi-deps AS essi-web
101191USER essi:essi
102192RUN bundle exec rake assets:precompile
103193EXPOSE 3000
104194ARG SOURCE_COMMIT
105- ENV SOURCE_COMMIT $SOURCE_COMMIT
195+ ENV SOURCE_COMMIT= $SOURCE_COMMIT
106196CMD puma -b tcp://0.0.0.0:3000
0 commit comments