5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 17:31:42 +00:00

migrar a postgresql

This commit is contained in:
f 2019-09-24 14:56:04 -03:00
parent ef416174f7
commit c3440de7ae
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
7 changed files with 41 additions and 3 deletions

View file

@ -60,7 +60,7 @@ ENV RAILS_ENV production
# Instalar las dependencias, separamos la librería de base de datos para
# poder reutilizar este primer paso desde otros contenedores
RUN apk add --no-cache libxslt libxml2 tzdata ruby ruby-bundler ruby-json ruby-bigdecimal ruby-rake
RUN apk add --no-cache sqlite-libs
RUN apk add --no-cache sqlite-libs postgresql-libs
# Necesitamos yarn para que Jekyll pueda generar los sitios
# XXX: Eliminarlo cuando extraigamos la generación de sitios del proceso
# principal

View file

@ -56,6 +56,7 @@ gem 'inline_svg'
gem 'jekyll'
gem 'mini_magick'
gem 'mobility'
gem 'pg'
gem 'pundit'
gem 'rails-i18n'
gem 'rails_warden'
@ -67,6 +68,7 @@ gem 'rugged'
gem 'sucker_punch'
gem 'terminal-table'
gem 'validates_hostname'
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
gem 'webpacker'
group :development, :test do

View file

@ -5,6 +5,14 @@ GIT
reverse_markdown (1.2.0)
nokogiri
GIT
remote: https://0xacab.org/sutty/yaml_db.git
revision: 40e44c29ce4290dfe4013ff4fce1be5a936fedf4
specs:
yaml_db (0.7.0)
rails (>= 3.0)
rake (>= 0.8.7)
GEM
remote: https://gems.sutty.nl/
specs:
@ -242,6 +250,7 @@ GEM
ast (~> 2.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
pg (1.1.4)
popper_js (1.14.5)
pry (0.12.2)
coderay (~> 1.1.0)
@ -450,6 +459,7 @@ DEPENDENCIES
listen (>= 3.0.5, < 3.2)
mini_magick
mobility
pg
pry
puma (~> 3.7)
pundit
@ -475,6 +485,7 @@ DEPENDENCIES
validates_hostname
web-console (>= 3.3.0)
webpacker
yaml_db!
BUNDLED WITH
2.0.2

View file

@ -1,2 +1,2 @@
migrate: if test -f data/production.sqlite3; then bundle exec rake db:migrate db:seed ; else bundle exec rake db:setup ; fi
migrate: bundle exec rake db:prepare db:seed
sutty: bundle exec puma -d config.ru

18
bin/migrate_database Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -e
cd /srv/http
test -f data/production.sqlite3.migrated && exit 0
bundle exec rake db:data:dump_dir dir=data
cat config/database.yml.pg > config/database.yml
bundle exec rake db:schema:load
rm db/data/ar_internal_metadata.yml
mv db/data/active_storage_attachments.yml db/data/zz_active_storage_attachments.yml
bundle exec rake db:load dir=data truncate=false
mv data/production.sqlite3 data/production.sqlite3.migrated

7
config/database.yml.pg Normal file
View file

@ -0,0 +1,7 @@
production:
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: sutty
user: sutty
host: postgresql
encoding: unicode

View file

@ -1,5 +1,5 @@
check process sutty with pidfile /srv/http/tmp/puma.pid
start program = "/bin/sh -c 'cd /srv/http && foreman start migrate && foreman start sutty'" as uid app
start program = "/bin/sh -c 'cd /srv/http && ./bin/migrate_database && foreman start migrate && foreman start sutty'" as uid app
stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'"
check program sync_assets