Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .docker/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.6.3 AS cartafact_base
FROM ruby:3.2.5 AS cartafact_base


ENV HOME /cartafact
Expand All @@ -21,7 +21,7 @@ ARG BUNDLER_VERSION

RUN apt-get update && \
apt-get -yq dist-upgrade && \
apt-get install -y tzdata build-essential vim && \
apt-get install -y tzdata build-essential vim libjemalloc2 && \
apt-get autoremove -y && \
gem update --system && \
gem install bundler:$BUNDLER_VERSION
Expand All @@ -32,5 +32,4 @@ COPY . $HOME
ENV RAILS_ENV='development'
ENV NODE_ENV='development'

RUN bundle config set deployment 'true' && \
bundle install
RUN bundle install
4 changes: 2 additions & 2 deletions .docker/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
### app config ###
########################

FROM ruby:2.6.3 AS app
FROM ruby:3.2.5 AS app

ENV HOME /cartafact

Expand All @@ -25,7 +25,7 @@ ENV BUNDLER_VERSION=$BUNDLER_VERSION
RUN echo "\n\nbundler version: "$BUNDLER_VERSION
RUN apt-get update && \
apt-get -yq dist-upgrade && \
apt-get install -y tzdata build-essential vim && \
apt-get install -y tzdata build-essential vim libjemalloc2 && \
apt-get autoremove -y && \
gem update --system && \
gem install bundler:$BUNDLER_VERSION
Expand Down
142 changes: 142 additions & 0 deletions .docker/production/Dockerfile.gha
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
############################################
### Base image ###
############################################

# Taken from .ruby-version
ARG RUBY_VERSION=3.2.5
FROM ruby:$RUBY_VERSION-slim-bookworm AS base
LABEL author="DCHBX"

ARG DEBIAN_FRONTEND=noninteractive

# Taken from Gemfile.lock
ARG BUNDLER_VERSION=2.4.19
ENV BUNDLER_VERSION=$BUNDLER_VERSION

ARG NODE_MAJOR=20
ENV NODE_MAJOR=$NODE_MAJOR

RUN apt-get update -qq && \
apt-get install -yq --no-install-recommends \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log

# Add NodeJS to sources list
RUN curl -fsSL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash -

# Basic packages needed because we're using the slim image
RUN apt-get update \
&& apt-get -yq dist-upgrade \
&& apt-get install -y \
fontconfig \
libcurl4-openssl-dev \
libffi-dev \
libsodium23 \
libxext6 \
libxrender1 \
libyaml-cpp-dev \
nodejs \
default-jre \
openssl \
sshpass \
unzip \
zip \
zlib1g \
libjemalloc2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log

# Configure bundler and PATH, install bundler version
ENV GEM_HOME=/usr/local/bundle
ENV BUNDLE_PATH=$GEM_HOME
ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH
ENV BUNDLE_BIN=/usr/local/bin
ENV BUNDLE_JOBS=4
ENV BUNDLE_RETRY=3

ENV LANG=C.UTF-8

ENV HOME=/cartafact

ENV PATH=$HOME/bin:$BUNDLE_BIN:$GEM_HOME/gems/bin:$PATH

# rubygems-update > 3.4.22 requires ruby >= 3.0.0
RUN gem update --system 3.4.22\
&& rm -f /usr/local/bin/ruby/gems/*/specifications/default/bundler-*.gemspec \
&& gem install bundler -v $BUNDLER_VERSION

RUN groupadd --gid 1001 nonroot \
&& useradd --uid 1001 --gid nonroot --shell /bin/bash --create-home nonroot

RUN mkdir $HOME \
&& chown -R nonroot:nonroot $HOME

# Configure app home directory
WORKDIR $HOME


###############################################################################
### Builder. Adds node and Yarn. Not necessary in production. ###
###############################################################################

FROM base AS builder

ARG DEBIAN_FRONTEND=noninteractive

# Add Yarn to the sources list
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# Install Nodejs & Yarn
RUN apt-get update -qq \
&& apt-get install -yq --no-install-recommends \
build-essential \
git \
libpq-dev \
yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log


########################################################
### Node and Bundle for production ###
########################################################

FROM builder AS prod_gems_and_assets

ENV RAILS_ENV=production

ARG HOSTNAME=localhost

COPY --chown=nonroot:nonroot ./Gemfile $HOME/Gemfile
COPY --chown=nonroot:nonroot ./Gemfile.lock $HOME/Gemfile.lock

RUN bundle config set --local without 'development test' \
&& bundle install

COPY --chown=nonroot:nonroot . $HOME

# https://github.com/rubygems/rubygems/issues/3225
RUN rm -rf $GEM_HOME/bundle/ruby/*/cache

################################################################
### Deployable image ###
################################################################

FROM base AS deploy

# Copy prebuilt gems
COPY --chown=nonroot:nonroot --from=prod_gems_and_assets $BUNDLE_PATH $BUNDLE_PATH

# Copy all app code again (sans gems, node_modules, assets)
COPY --chown=nonroot:nonroot . $HOME

USER nonroot

ENV RAILS_ENV=production

ENTRYPOINT ["bin/docker-entrypoint"]
23 changes: 23 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Release notes template (https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes)

changelog:
categories:
- title: Breaking Changes 🚧
labels:
# Semver-Major
- breaking change
- title: New Features ✨
labels:
# Semver-Minor
- enhancement
- title: Bug Fixes 🐛
labels:
# Semver-Patch
- bugfix
- title: Other Changes 📦
labels:
- "*"
exclude:
labels:
- chore
- version bump
Loading
Loading