Skip to content
Snippets Groups Projects
Unverified Commit 1375cfcf authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Build assets in the base stage since they don’t change often

parent fdc0beb1
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -36,6 +36,9 @@ frontend-base: ...@@ -36,6 +36,9 @@ frontend-base:
only: only:
changes: changes:
- Dockerfile.frontend-base - Dockerfile.frontend-base
- src/api/app/assets
- src/api/public
- src/api/vendor
- src/api/Gemfile - src/api/Gemfile
- src/api/Gemfile.lock - src/api/Gemfile.lock
variables: variables:
......
...@@ -10,7 +10,14 @@ ARG INSTALLDIR=/obs ...@@ -10,7 +10,14 @@ ARG INSTALLDIR=/obs
ADD src/api/ $INSTALLDIR/src/api/ ADD src/api/ $INSTALLDIR/src/api/
COPY --from=base $INSTALLDIR/src/api/Gemfile $INSTALLDIR/src/api/Gemfile.lock $INSTALLDIR/src/api/ COPY --from=base $INSTALLDIR/src/api/Gemfile.lock $INSTALLDIR/src/api/
RUN sed -e "/gem 'puma'/d" Gemfile > Gemfile.new; \
echo "gem 'puma'" >> Gemfile.new; \
diff -u Gemfile Gemfile.new; \
mv Gemfile.new Gemfile
COPY --from=base $INSTALLDIR/src/api/public/assets $INSTALLDIR/src/api/public/assets
WORKDIR $INSTALLDIR/src/api WORKDIR $INSTALLDIR/src/api
...@@ -19,21 +26,11 @@ RUN install -D -t public/css /usr/share/javascript/bootstrap/css/bootstrap.min.c ...@@ -19,21 +26,11 @@ RUN install -D -t public/css /usr/share/javascript/bootstrap/css/bootstrap.min.c
RUN ls -la RUN ls -la
ARG BUNDLE_BUILD__SASSC=--disable-march-tune-native
ARG NOKOGIRI_USE_SYSTEM_LIBRARIES=1 ARG NOKOGIRI_USE_SYSTEM_LIBRARIES=1
RUN bundle install --jobs=$(nproc) --retry=3 \ RUN bundle install --jobs=$(nproc) --retry=3 \
&& rm -rf /var/lib/gems/*/cache && rm -rf /var/lib/gems/*/cache
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true
RUN echo nonce > config/secret.key \
&& DATABASE_URL=mysql2://localhost/noncedb bundle exec rake assets:precompile RAILS_GROUPS=assets \
&& rm config/secret.key
RUN bundle config --local without test:assets:development
RUN sed -i 's|^#!/usr/bin/ruby.ruby.*$|#!/usr/bin/ruby|' bin/* script/* RUN sed -i 's|^#!/usr/bin/ruby.ruby.*$|#!/usr/bin/ruby|' bin/* script/*
RUN sed -i -e /mailcatcher:/d -e /web:/d Procfile RUN sed -i -e /mailcatcher:/d -e /web:/d Procfile
......
FROM debian:bookworm-slim as frontend-base ARG INSTALLDIR=/obs
ARG DEBIAN_RELEASE=bookworm
FROM debian:$DEBIAN_RELEASE-slim as base
ENV LC_ALL=C.UTF-8 ENV LC_ALL=C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ARG INSTALLDIR=/obs ARG INSTALLDIR
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y \ && apt-get install -y \
...@@ -39,29 +42,47 @@ RUN apt-get update \ ...@@ -39,29 +42,47 @@ RUN apt-get update \
libxslt1-dev \ libxslt1-dev \
zlib1g-dev zlib1g-dev
RUN gem install --no-format-executable brakeman --version 5.0.2 --no-doc
RUN gem install sassc --version 2.0.1 --no-doc
ADD src/api/Gemfile src/api/Gemfile.lock $INSTALLDIR/src/api/ ADD src/api/Gemfile src/api/Gemfile.lock $INSTALLDIR/src/api/
WORKDIR $INSTALLDIR/src/api/ WORKDIR $INSTALLDIR/src/api/
RUN sed -e "/gem 'puma'/d" Gemfile > Gemfile.new; \
echo "gem 'puma'" >> Gemfile.new; \
diff -u Gemfile Gemfile.new; \
mv Gemfile.new Gemfile
RUN sed -e '/BUNDLED WITH/,+1 d' Gemfile.lock > Gemfile.lock.new; \ RUN sed -e '/BUNDLED WITH/,+1 d' Gemfile.lock > Gemfile.lock.new; \
diff -u Gemfile.lock Gemfile.lock.new; \ diff -u Gemfile.lock Gemfile.lock.new; \
mv Gemfile.lock.new Gemfile.lock mv Gemfile.lock.new Gemfile.lock
ARG BUNDLE_BUILD__SASSC=--disable-march-tune-native
ARG NOKOGIRI_USE_SYSTEM_LIBRARIES=1 ARG NOKOGIRI_USE_SYSTEM_LIBRARIES=1
RUN bundle config --global without development:test RUN bundle config --global without assets:development:test
RUN bundle install --jobs=$(nproc) --retry=3 \ RUN bundle install --jobs=$(nproc) --retry=3 \
&& rm -rf \ && rm -rf \
/var/lib/gems/*/cache/ \ /var/lib/gems/*/cache/ \
/var/lib/gems/*/test/ \ /var/lib/gems/*/test/ \
/var/lib/gems/*/extensions/*/*/*/gem_make.out \ /var/lib/gems/*/extensions/*/*/*/gem_make.out \
/var/lib/gems/*/extensions/*/*/*/*.log \ /var/lib/gems/*/extensions/*/*/*/*.log
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true
FROM base as asset-builder
ARG INSTALLDIR
ADD src/api/ $INSTALLDIR/src/api/
COPY --from=base $INSTALLDIR/src/api/Gemfile $INSTALLDIR/src/api/Gemfile.lock $INSTALLDIR/src/api/
ARG BUNDLE_BUILD__SASSC=--disable-march-tune-native
ARG NOKOGIRI_USE_SYSTEM_LIBRARIES=1
RUN gem install --no-format-executable brakeman --version 5.0.2 --no-doc
RUN gem install sassc --version 2.0.1 --no-doc
RUN bundle config --local without development:test
RUN bundle install --jobs=$(nproc) --retry=3
RUN echo nonce > config/secret.key \
&& DATABASE_URL=mysql2://localhost/noncedb bundle exec rake assets:precompile RAILS_GROUPS=assets
FROM base
ARG INSTALLDIR
COPY --from=asset-builder $INSTALLDIR/src/api/public/assets $INSTALLDIR/src/api/public/assets
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment