Skip to content

Commit

Permalink
Upgrade Ruby and Rails versions
Browse files Browse the repository at this point in the history
Update clamav to 1.3
Upgrade Jbuilder and Rspec
Update ruby.yml
  • Loading branch information
matthewford committed May 2, 2024
1 parent a965b04 commit 0d027d5
Show file tree
Hide file tree
Showing 34 changed files with 581 additions and 335 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Ruby on Rails CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: vigilion_scanner_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.7' # Adjust the Ruby version to match your project's version

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev clamav clamav-daemon
gem install bundler
bundle install --jobs 4 --retry 3
- name: Start ClamAV daemon
run: |
sudo systemctl start clamav-daemon
- name: Setup Database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
run: |
bin/rails db:create
bin/rails db:schema:load
- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
run: bundle exec rspec
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.7
3.0.7
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 2.7.7
ruby 3.0.7
31 changes: 21 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@ RUN set -eux; \
valgrind \
pkg-config \
libmilter-dev \
gcc \
make \
python3 \
python3-pip \
python3-pytest \
curl \
; \
rm -rf /var/lib/apt/lists/*; \
\
curl -L -o clamav.tar.gz https://www.clamav.net/downloads/production/clamav-1.2.0.tar.gz; \
# Install Rust and Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
. $HOME/.cargo/env; \
\
curl -L -o clamav.tar.gz https://www.clamav.net/downloads/production/clamav-1.3.1.tar.gz; \
tar xzf clamav.tar.gz; \
cd clamav-1.2.0; \
cd clamav-1.3.1; \
mkdir build && cd build; \
cmake .. \
-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_INSTALL_PREFIX=/usr \
-D APP_CONFIG_DIRECTORY=/etc/clamav \
-D DATABASE_DIRECTORY=/var/lib/clamav \
# update after upgrading json-c:
-D ENABLE_JSON_SHARED=ON \
-D CMAKE_INSTALL_LIBDIR=/usr/lib \
-D ENABLE_CLAMONACC=OFF \
Expand All @@ -42,7 +51,7 @@ RUN set -eux; \
-D ENABLE_STATIC_LIB=OFF \
; \
make DESTDIR="/clamav" --quiet -j$(($(nproc) - 1)) install; \
cd ../../ && rm -r clamav.tar.gz clamav-1.2.0; \
cd ../../ && rm -r clamav.tar.gz clamav-1.3.1; \
rm -rf "/clamav/usr/include" \
"/clamav/usr/lib/pkgconfig/" \
"/clamav/usr/share/doc" ; \
Expand All @@ -65,9 +74,9 @@ RUN set -eux; \
} >> /usr/local/etc/gemrc

ENV LANG C.UTF-8
ENV RUBY_MAJOR 2.7
ENV RUBY_VERSION 2.7.7
ENV RUBY_DOWNLOAD_SHA256 b38dff2e1f8ce6e5b7d433f8758752987a6b2adfd9bc7571dbc42ea5d04e3e4c
ENV RUBY_MAJOR 3.0
ENV RUBY_VERSION 3.0.7
ENV RUBY_DOWNLOAD_SHA256 1748338373c4fad80129921080d904aca326e41bd9589b498aa5ee09fd575bab

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
Expand Down Expand Up @@ -168,12 +177,14 @@ RUN freshclam -v && freshclam --version > /usr/src/app/CLAM_VERSION

##
# refresh virus definitions each 1 hour. ClamAV recommends not update in times multiple of 10
RUN echo "15 * * * * root /usr/bin/freshclam --quiet >/dev/null 2>&1 \n" >> /etc/cron.d/freshclam-cron
RUN echo "30 * * * * root /usr/bin/freshclam --version > /usr/src/app/CLAM_VERSION\n" >> /etc/cron.d/freshclam-version-cron
RUN echo "15 * * * * root /usr/bin/freshclam --quiet >/dev/null 2>&1" > /etc/cron.d/freshclam-cron && \
echo "30 * * * * root /usr/bin/freshclam --version > /usr/src/app/CLAM_VERSION" >> /etc/cron.d/freshclam-version-cron && \
chmod 644 /etc/cron.d/freshclam-cron && \
service cron restart

COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/
RUN gem install bundler:2.1.4
RUN gem install bundler:2.2.33

RUN set -eux; \
\
Expand Down
18 changes: 7 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
source 'https://rubygems.org'

gem 'rails', '~> 5.2', '>= 5.2.6.2'
gem 'rake', '~> 12.3'
gem 'pg', '~> 0.21.0'
gem 'jbuilder', '~> 2.6.0'
gem 'rails', '~> 6.0'
gem 'pg', '~> 1.0'
gem 'jbuilder', '~> 2.12'
gem 'typhoeus', '~> 1.1'
gem 'dotenv-rails', '~> 2.1'
gem 'puma', '~> 5.6'
gem 'sentry-raven', '~> 1.2'
gem 'puma', '< 7'
gem 'addressable', '~> 2.8'
gem 'ruby-filemagic', '~> 0.7'
gem 'thwait', '~> 0.2.0'

gem 'sidekiq', '~> 5.2'
gem 'sidekiq-scheduler', '~> 2.0'
gem 'sidekiq', '~> 6.5'
gem 'sidekiq-scheduler', '~> 4.0.3'
gem 'lograge', '~> 0.5'
gem 'logstash-event', '~> 1.2'
gem 'rack-cors', '~> 1.0.5', require: 'rack/cors'

group :development, :test do
gem 'byebug'
%w[rails core expectations mocks support].each do |name|
gem "rspec-#{name}", "~> 3.5.0"
end
gem 'rspec-rails', '~> 6.1.0'
gem 'factory_girl_rails'
gem 'timecop'
gem 'simplecov', require: false
Expand Down
Loading

0 comments on commit 0d027d5

Please sign in to comment.