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

refactor: Allow stage 1 steps to be reused

parent 34edf1f0
No related branches found
No related tags found
No related merge requests found
FROM ruby:2.7.5-slim-bullseye
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get \
-o Dpkg::Options::="--force-confnew" --allow-remove-essential --allow-change-held-packages -fuy \
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
# Bootstrap scripts will also be used by stage 2 (rails-runtime-base-image).
ADD /app/bootstrap*sh /app/
RUN chmod +x /app/bootstrap*sh
USER nexus
# Install OS packages required for the gem build environment.
RUN /app/bootstrap-apt-upgrade.sh
RUN 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
RUN /app/bootstrap-apt-clean.sh
# Prepare bundle for the gem build environment.
RUN /app/bootstrap-app-dir.sh
USER nexus
WORKDIR /app
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
# 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
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
a simple helper script. There are many ways of achieving this, but the recommended way is:
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 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;"
......
#!/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
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