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

Bump rails 8 test2 #515

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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
58 changes: 58 additions & 0 deletions .annotaterb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
:position: before
:position_in_additional_file_patterns: before
:position_in_class: before
:position_in_factory: before
:position_in_fixture: before
:position_in_routes: before
:position_in_serializer: before
:position_in_test: before
:classified_sort: true
:exclude_controllers: true
:exclude_factories: false
:exclude_fixtures: false
:exclude_helpers: true
:exclude_scaffolds: true
:exclude_serializers: false
:exclude_sti_subclasses: false
:exclude_tests: false
:force: false
:format_markdown: false
:format_rdoc: false
:format_yard: false
:frozen: false
:ignore_model_sub_dir: false
:ignore_unknown_models: false
:include_version: false
:show_check_constraints: false
:show_complete_foreign_keys: false
:show_foreign_keys: false
:show_indexes: false
:simple_indexes: false
:sort: false
:timestamp: false
:trace: false
:with_comment: true
:with_column_comments: true
:with_table_comments: true
:active_admin: false
:command:
:debug: false
:hide_default_column_types: ''
:hide_limit_column_types: ''
:ignore_columns:
:ignore_routes:
:models: true
:routes: false
:skip_on_db_migrate: false
:target_action: :do_annotations
:wrapper:
:wrapper_close:
:wrapper_open:
:classes_default_to_s: []
:additional_file_patterns: []
:model_dir:
- app/models
:require: []
:root_dir:
- ''
60 changes: 52 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
.env
.env.test
.erb-lint.yml
.git/
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/
/.gitignore
.gitattributes
.github/
.gitignore
.gitlab-ci.yml

# Ignore bundler config.
/.bundle

# Ignore all environment files.
/.env*

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep

# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets

# Ignore CI service files.
/.github
.gitlab/
.gitlab-ci.yml
chart/

# Ignore development files
/.devcontainer

# Ignore Docker-related files
/.dockerignore
/Dockerfile*


.erb-lint.yml
.rubocop.yml
.ruby-lsp
.vscode/
chart/
Procfile
Procfile.debug
Procfile.dev
10 changes: 5 additions & 5 deletions .gitlab/auto-deploy-values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
timeout: 120
service:
externalPort: 3000
internalPort: 3000
externalPort: 5000
internalPort: 5000
image:
secrets:
- name: skdigital-bonet-registry
application.migrateCommand: ["bundle", "exec", "rails", "db:migrate"]
application.migrateCommand: ["bin/rails", "db:migrate"]
ingress:
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 256m
Expand All @@ -29,15 +29,15 @@ persistence:
volumes:
- name: govbox-pro-storage
mount:
path: /app/storage
path: /rails/storage
claim:
accessMode: ReadWriteMany
size: 10Gi
storageClass: nfs-client
workers:
worker:
replicaCount: "1"
command: ["bundle", "exec", "good_job", "start"]
command: ["bundle", "exec", "good_job", "start", "--probe-port=5000"]
startupProbe:
probeType: "httpGet"
path: "/status/started"
Expand Down
12 changes: 6 additions & 6 deletions .gitlab/prod-auto-deploy-values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
timeout: 120
service:
externalPort: 3000
internalPort: 3000
externalPort: 5000
internalPort: 5000
image:
secrets:
- name: skdigital-bonet-registry
application.migrateCommand: ["bundle", "exec", "rails", "db:migrate"]
application.migrateCommand: ["bin/rails", "db:migrate"]
ingress:
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 256m
Expand All @@ -14,7 +14,7 @@ livenessProbe:
timeoutSeconds: 5
probeType: "httpGet"
path: "/health"
eadinessProbe:
readinessProbe:
initialDelaySeconds: 5
timeoutSeconds: 10
probeType: "httpGet"
Expand All @@ -29,15 +29,15 @@ persistence:
volumes:
- name: govbox-pro-storage
mount:
path: /app/storage
path: /rails/storage
claim:
accessMode: ReadWriteMany
size: 10Gi
storageClass: nfs-client
workers:
worker:
replicaCount: "1"
command: ["bundle", "exec", "good_job", "start"]
command: ["bundle", "exec", "good_job", "start", "--probe-port=5000"]
startupProbe:
probeType: "httpGet"
path: "/status/started"
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.6
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.3.0
ruby 3.3.6
nodejs 20.10.0
102 changes: 85 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,99 @@
FROM ruby:3.3.0
# syntax=docker/dockerfile:1
# check=error=true

# Install packages
RUN apt-get update && apt-get install -y build-essential nodejs libpq-dev npm fop=1:2.* libsaxon-java libsaxonb-java chromium \
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t govbox-pro .
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name govbox-pro govbox-pro

# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.6
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# > CUSTOM
# Install FOP and other packages
RUN apt-get update && apt-get install -y fop=1:2.* libsaxon-java libsaxonb-java chromium \
&& apt-get -y install libx11-xcb1 libxcomposite1 libasound2 libatk1.0-0 libatk-bridge2.0-0 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6

# Setup FOP to use saxon xslt parser
RUN sed -i '/find_jars/i \
find_jars saxon saxonb' /usr/bin/fop
RUN sed -i 's/^run_java /run_java -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl /' /usr/bin/fop
# < CUSTOM

# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
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 and node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev node-gyp pkg-config python-is-python3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Set working directory
RUN mkdir /app
WORKDIR /app
# Install JavaScript dependencies
ARG NODE_VERSION=22.11.0
ARG YARN_VERSION=1.22.22
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

RUN npm i -g yarn
RUN npm i npx
# 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

# Bundle and cache Ruby gems
COPY Gemfile* ./
RUN bundle config set deployment true
RUN bundle config set without development:test
RUN bundle install
# Install node modules
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Cache everything
# Copy application code
COPY . .

RUN SECRET_KEY_BASE=NONE RAILS_ENV=production bundle exec rails assets:precompile
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails tailwindcss:build
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


RUN rm -rf node_modules


# Final stage for app image
FROM base

# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp
USER 1000:1000

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Run application by default
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 5000
ENV HTTP_PORT=5000
CMD ["./bin/thrust", "./bin/rails", "server"]
19 changes: 11 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
source 'https://rubygems.org'

ruby '3.3.0'
ruby '3.3.6'

gem 'rails', '~> 7.1'
gem 'rails', '~> 8.0'
gem 'rails-i18n'

gem 'pg', '~> 1.5'
gem 'pg'
gem 'with_advisory_lock'

gem 'puma', '~> 6.4'
gem 'puma'

# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
gem "thruster", require: false

gem 'turbo-rails'

# Styles
gem 'sprockets-rails'
gem 'importmap-rails'
gem 'sprockets-rails'
gem 'tailwindcss-rails'
gem 'view_component'

# Schedulers
gem 'clockwork'

# Workers
gem 'good_job'
gem 'good_job', '3.99' # intermediate version to avoid breaking changes

# Auth
gem 'omniauth-google-oauth2'
gem 'omniauth-saml', '~> 2.2.1'
gem 'omniauth-saml'
gem 'omniauth-rails_csrf_protection'
gem 'pundit'

Expand Down Expand Up @@ -59,7 +62,7 @@ group :development, :test do
end

group :development do
gem 'annotate'
gem 'annotaterb'
gem 'listen'
gem 'web-console'
gem 'solargraph'
Expand Down
Loading