Skip to content

Commit

Permalink
solid queue and postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn committed Aug 17, 2024
1 parent f3f013e commit f17156a
Show file tree
Hide file tree
Showing 20 changed files with 422 additions and 172 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/yamllint.json": "file:///home/baldarn/Projects/open-GAS/config/deploy.yml"
}
}
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ ENV RAILS_ENV="production" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"


# Throw-away build stage to reduce size of final image
FROM --platform=$TARGETPLATFORM base as build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libvips pkg-config nodejs
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config nodejs

# Install application gems
COPY Gemfile Gemfile.lock .ruby-version ./
Expand All @@ -32,13 +31,12 @@ COPY . .
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libsqlite3-0 libvips redis nodejs && \
apt-get install --no-install-recommends -y curl libjemalloc2 libpq-dev libvips nodejs && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
Expand All @@ -62,4 +60,4 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["bin/boot"]
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
45 changes: 45 additions & 0 deletions Dockerfile.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax = docker/dockerfile:1

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

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_ENV="development" \
BUNDLE_PATH="/usr/local/bundle"

# Throw-away build stage to reduce size of final image
FROM --platform=$TARGETPLATFORM base as build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libvips libpq-dev pkg-config nodejs

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

# Copy application code
COPY . .

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

# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libpq-dev libvips nodejs && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

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

# Entrypoint prepares the application.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
7 changes: 2 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ ruby file: '.ruby-version'
gem 'rails', '~> 7.2.0'

# Drivers
gem 'redis', '>= 4.0.1'
gem 'sqlite3', '~> 1.4'
gem 'pg', '~> 1.5.7'

# Deployment
gem 'puma', '>= 5.0'

# Jobs
gem 'resque', '~> 2.6.0'
gem 'resque-pool', '~> 0.7.1'
gem 'solid_queue', '~> 0.4.1'

# Front-end
gem 'bootstrap', '~> 5.1'
Expand Down Expand Up @@ -43,7 +41,6 @@ gem 'rouge', '~> 4.2'
gem 'rqrcode'
gem 'sassc-rails'
gem 'sprockets-rails'
gem 'thruster'
gem 'useragent', github: 'basecamp/useragent'

group :development, :test do
Expand Down
59 changes: 15 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ GEM
drb (2.2.1)
ed25519 (1.3.0)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
execjs (2.9.1)
faker (3.4.1)
i18n (>= 1.8.11, < 2)
Expand All @@ -139,6 +141,9 @@ GEM
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
front_matter_parser (1.0.1)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
htmlbeautifier (1.4.3)
Expand Down Expand Up @@ -200,10 +205,6 @@ GEM
mini_magick (4.13.0)
mini_mime (1.1.5)
minitest (5.24.1)
mono_logger (1.1.2)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
net-imap (0.4.14)
date
net-protocol
Expand Down Expand Up @@ -236,17 +237,16 @@ GEM
parser (3.3.3.0)
ast (~> 2.4.1)
racc
pg (1.5.7)
popper_js (2.11.8)
psych (5.1.2)
stringio
public_suffix (5.0.5)
puma (6.4.2)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.1)
rack (3.1.7)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -291,26 +291,12 @@ GEM
rdoc (6.7.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
resque (2.6.0)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.6)
sinatra (>= 0.9.2)
resque-pool (0.7.1)
rake (>= 10.0, < 14.0)
resque (>= 1.22, < 3)
rexml (3.3.4)
strscan
rouge (4.3.0)
Expand Down Expand Up @@ -341,7 +327,6 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
Expand All @@ -362,25 +347,19 @@ GEM
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
solid_queue (0.4.1)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.1)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3-aarch64-linux)
sqlite3 (1.7.3-arm-linux)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86-linux)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
sshkit (1.23.0)
base64
net-scp (>= 1.1.2)
Expand All @@ -391,11 +370,6 @@ GEM
stringio (3.1.1)
strscan (3.1.0)
thor (1.3.1)
thruster (0.1.4)
thruster (0.1.4-aarch64-linux)
thruster (0.1.4-arm64-darwin)
thruster (0.1.4-x86_64-darwin)
thruster (0.1.4-x86_64-linux)
tilt (2.3.0)
timeout (0.4.1)
turbo-rails (2.0.5)
Expand Down Expand Up @@ -447,13 +421,11 @@ DEPENDENCIES
kamal
kaminari
kaminari-i18n
pg (~> 1.5.7)
puma (>= 5.0)
rails (~> 7.2.0)
rails-i18n (~> 7.0.0)
redcarpet (~> 3.6)
redis (>= 4.0.1)
resque (~> 2.6.0)
resque-pool (~> 0.7.1)
rouge (~> 4.2)
rqrcode
rubocop-capybara
Expand All @@ -462,10 +434,9 @@ DEPENDENCIES
selenium-webdriver
simple_calendar
simple_form (~> 5.3)
solid_queue (~> 0.4.1)
sprockets-rails
sqlite3 (~> 1.4)
stimulus-rails
thruster
turbo-rails
useragent!
web-console
Expand Down
54 changes: 0 additions & 54 deletions bin/boot

This file was deleted.

5 changes: 0 additions & 5 deletions bin/start-app

This file was deleted.

18 changes: 11 additions & 7 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 10 } %>
retries: 100
default_transaction_mode: immediate
adapter: postgresql
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 10 } %>
host: <%= ENV.fetch('PG_HOST', 'localhost') %>
port: <%= ENV.fetch('PG_PORT', '5432') %>
username: <%= ENV.fetch('PG_USER', 'opengas') %>
password: <%= ENV.fetch('PG_PASSWORD', 'opengas') %>
database: <%= ENV.fetch('PG_DATABASE', "opengas_#{Rails.env}") %>
encoding: unicode

development:
primary:
<<: *default
database: storage/db/development.sqlite3

test:
primary:
<<: *default
database: storage/db/test.sqlite3
database: <%= ENV.fetch('PG_DATABASE', 'opengas_test') %>

production:
primary:
<<: *default
database: storage/db/production.sqlite3
password: <%= ENV.fetch('PG_PRODUCTION_PASSWORD', 'opengas') %>

4 changes: 2 additions & 2 deletions config/deploy.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ image: baldarn/open-gas
servers:
web:
hosts:
- open-gas-dev.farnararo.it
- staging.opengas.eu
labels:
traefik.http.routers.open_gas.entrypoints: websecure
traefik.http.routers.open_gas.rule: Host(`open-gas-dev.farnararo.it`)
traefik.http.routers.open_gas.rule: Host(`staging.opengas.eu`)
traefik.http.routers.open_gas.tls.certresolver: letsencrypt

registry:
Expand Down
Loading

0 comments on commit f17156a

Please sign in to comment.