Skip to content
Snippets Groups Projects
Commit 334670d7 authored by John Harris's avatar John Harris
Browse files

Merge branch 'feature/script_refactoring' into 'master'

Refactor rails runtime base image for stage 2 reuse

See merge request rails-base-image-builder!6
parents 34edf1f0 d043851d
No related branches found
Tags v1.1.0
1 merge request!6Refactor rails runtime base image for stage 2 reuse
Pipeline #26843 failed
FROM ruby:2.7.5-slim-bullseye FROM ruby:2.7.5-slim-bullseye
RUN apt-get update \ # Bootstrap scripts will also be used by stage 2 (rails-runtime-base-image).
&& DEBIAN_FRONTEND=noninteractive apt-get \ COPY /app/bootstrap*sh /app/
-o Dpkg::Options::="--force-confnew" --allow-remove-essential --allow-change-held-packages -fuy \ RUN chmod +x /app/bootstrap*sh
upgrade \
&& apt-get install -y --no-install-recommends \
cmake \
pkg-config \
default-libmysqlclient-dev \
nodejs \
curl \
git \
ruby-dev \
telnet \
nano \
build-essential \
libpq-dev \
shared-mime-info \
&& apt-get autoremove \
&& apt-get autoclean \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& adduser nexus --system --group -u 1000 && mkdir -p /app && chown -R nexus:nexus /app
USER nexus # Install OS packages required for the gem build environment.
RUN /app/bootstrap-apt-upgrade.sh && \
apt-get install -y --no-install-recommends \
build-essential \
cmake \
curl \
default-libmysqlclient-dev \
git \
libpq-dev \
nano \
nodejs \
pkg-config \
ruby-dev \
shared-mime-info \
telnet && \
/app/bootstrap-apt-clean.sh
# Prepare bundle for the gem build environment.
RUN /app/bootstrap-app-dir.sh
USER nexus
WORKDIR /app WORKDIR /app
COPY --chown=nexus:nexus Gemfile Gemfile.lock ./ COPY --chown=nexus:nexus Gemfile Gemfile.lock ./
RUN bundle config --local build.sassc --disable-march-tune-native && gem install bundler -v 2.1 && bundle install --jobs 20 --retry 5 RUN /app/bootstrap-app-bundle.sh
...@@ -79,7 +79,7 @@ GEM ...@@ -79,7 +79,7 @@ GEM
autoprefixer-rails (10.4.7.0) autoprefixer-rails (10.4.7.0)
execjs (~> 2) execjs (~> 2)
aws-eventstream (1.2.0) aws-eventstream (1.2.0)
aws-partitions (1.586.0) aws-partitions (1.587.0)
aws-sdk-core (3.130.2) aws-sdk-core (3.130.2)
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0) aws-partitions (~> 1, >= 1.525.0)
...@@ -169,7 +169,7 @@ GEM ...@@ -169,7 +169,7 @@ GEM
listen (3.7.1) listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.17.0) loofah (2.18.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
...@@ -212,7 +212,7 @@ GEM ...@@ -212,7 +212,7 @@ GEM
activesupport activesupport
bunny bunny
nio4r (2.5.8) nio4r (2.5.8)
nokogiri (1.13.5) nokogiri (1.13.6)
mini_portile2 (~> 2.8.0) mini_portile2 (~> 2.8.0)
racc (~> 1.4) racc (~> 1.4)
pg (1.3.5) pg (1.3.5)
...@@ -345,7 +345,7 @@ GEM ...@@ -345,7 +345,7 @@ GEM
activesupport (>= 5.2) activesupport (>= 5.2)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
strings-case (0.3.0) strings-case (0.3.0)
strscan (3.0.1) strscan (3.0.3)
thor (1.2.1) thor (1.2.1)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.10) tilt (2.0.10)
......
# Rails Base Image Builder # Rails Base Image Builder
This repository is the base image for all base image that is used in the `builder` stage of all of our rails apps. This repository is the 'stage 1' base image used in the `builder` stage on all of our rails applications.
* Stage 1 (rails-base-image-builder): Install packages to compile gems, and compile those gems.
* Stage 2 (rails-runtime-base-image): Install packages and configure OS for runtime environment.
## Update gems ## Update gems
To update the gems in this core image, great care must be taken. Once the gemfile has been update, the lock file can be updated with To update the gems in this core image, great care must be taken. Once the gemfile has been update, the lock file can be
a simple helper script. There are many ways of achieving this, but the recommended way is: updated with a simple helper script. There are many ways of achieving this, but the recommended way is:
``` ```
docker run -it -v "$(pwd)":/app -v /usr/local/bundle:/usr/local/bundle ruby:2.7.5 sh -c "apt-get update; apt-get install -y cmake build-essential; cd /app; gem install bundler:2.1; bundle update; bundle install;" ./gem-update.sh
``` ```
Once both the `Gemfile` and `Gemfile.lock` files are both updated, a commit can be created to force a new update. Once both the `Gemfile` and `Gemfile.lock` files are both updated, a commit can be created to force a new update.
#!/bin/sh
set -ex
bundle config --local build.sassc --disable-march-tune-native
gem install bundler -v 2.1
bundle install --jobs 20 --retry 5
#!/bin/sh
set -ex
# Common bootstrap for a nexus application in a container.
adduser nexus --system --group -u 1000
chown -R nexus:nexus /app
#!/bin/sh
set -ex
apt-get autoremove
apt-get autoclean
apt-get clean
rm -rf /var/lib/apt/lists/*
#!/bin/sh
set -ex
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get \
-o Dpkg::Options::="--force-confnew" --allow-remove-essential --allow-change-held-packages -fuy \
upgrade
#!/bin/bash
cd "$(dirname "$0")"
set -ex
docker run -it -v "$(pwd)":/app \
-v /usr/local/bundle:/usr/local/bundle ruby:2.7.5 sh \
-c "apt-get update; \
apt-get install -y cmake build-essential; \
cd /app; \
gem install bundler:2.1; \
bundle update; \
bundle install;"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment