Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap #382

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.2.2
41 changes: 27 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# syntax=docker/dockerfile:1
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.0
ARG RUBY_VERSION=3.2.2
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_JOBS="4" \
BUNDLE_WITHOUT="development:test" \
BUNDLE_PATH="/usr/local/bundle"
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems
# NOTE: This example project intentionally does not require or install node.js

# Install packages needed to build gems and node modules
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=tmpfs,target=/var/log \
Expand All @@ -28,19 +26,33 @@ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update -qq \
&& apt-get install -yq --no-install-recommends \
build-essential \
gnupg2 \
less \
curl \
git \
libpq-dev \
libvips \
pkg-config
node-gyp \
pkg-config \
python-is-python3

# Install JavaScript dependencies
ARG NODE_VERSION=20.11.0
ARG YARN_VERSION=1.22.21
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
npm install -g yarn@$YARN_VERSION && \
rm -rf /tmp/node-build-master

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile

# Install node modules
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Copy application code
COPY . .

Expand All @@ -61,10 +73,11 @@ RUN --mount=type=cache,target=/var/cache/apt \
rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
apt-get update -qq \
&& apt-get install -yq --no-install-recommends \
&& apt-get install --no-install-recommends -y \
curl \
postgresql-client \
libvips
libvips \
postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
Expand Down
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.3.0"
ruby "3.2.2"

# Bundle edge Rails instead:
# gem "rails", github: "rails/rails", branch: "main"
Expand All @@ -27,6 +27,9 @@ gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ GEM
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
cssbundling-rails (1.4.0)
railties (>= 6.0.0)
date (3.3.4)
debug (1.9.1)
irb (~> 1.10)
Expand Down Expand Up @@ -331,6 +333,7 @@ DEPENDENCIES
brakeman
bundler-audit
capybara
cssbundling-rails
debug
image_processing (~> 1.2)
importmap-rails
Expand All @@ -352,7 +355,7 @@ DEPENDENCIES
web-console

RUBY VERSION
ruby 3.3.0p0
ruby 3.2.2p53

BUNDLED WITH
2.5.5
4 changes: 2 additions & 2 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bin/rails server -p 3000
css: bin/rails dartsass:watch
web: env RUBY_DEBUG_OPEN=true bin/rails server
css: yarn watch:css
Empty file added app/assets/builds/.keep
Empty file.
Loading