Compare commits

...

14 commits

Author SHA1 Message Date
Maki 752569c8a7 Merge branch 'hotfix-yarn-lock' into 'rails'
Soportar sitios sin yarn.lock

See merge request sutty/sutty!53
2021-08-09 14:39:30 +00:00
f 9f84c14a69 Soportar sitios sin yarn.lock
Como el chequeo devuelve nil, un sitio sin yarn.lock nunca se
compilaría.
2021-08-07 15:55:00 -03:00
fauno 312df05a84 Merge branch 'readme' into 'rails'
Mejorar el entorno de desarrollo

Closes #732 and #1190

See merge request sutty/sutty!47
2021-08-02 17:18:04 +00:00
Nulo 4c84389b35 Apply 3 suggestion(s) to 1 file(s) 2021-08-02 16:17:30 +00:00
fauno 35ca1ee91c Merge branch 'timeout-deploys' into 'rails'
Cancelar la tarea pendiente si tomó mas de 10 minutos

See merge request sutty/sutty!51
2021-08-01 05:15:07 +00:00
fauno d42bab9f1c Merge branch 'actualizacion-de-cuidados' into 'rails'
actualización de cuidados

See merge request sutty/sutty!43
2021-08-01 05:14:08 +00:00
f d456feac8e Cancelar la tarea pendiente si tomó mas de 10 minutos
Si la tarea se reintentó durante 10 minutos, lo más probable es que haya
quedado trabada en algún lado.  Este cambio permite volver a compilar
sitios al cambiar el estado a espera y cancelarse a sí misma.
2021-07-29 14:46:29 -03:00
Nulo 6448a881ac Merge branch 'request-uri' into 'rails'
agregar request_uri a los logs

See merge request sutty/sutty!49
2021-07-22 22:18:30 +00:00
f d474b819ad agregar request_uri a los logs sutty/containers/nginx!1 2021-07-22 16:19:25 -03:00
f 8f88023d52 El espacio es importante 2021-07-22 16:16:10 -03:00
f 68bd68a2ee actualización de cuidados, resuelve un cve en addressable 2021-07-13 17:22:05 -03:00
f b71eea505c Merge branch 'rails' into actualizacion-de-cuidados 2021-07-13 17:20:44 -03:00
f 2ceeeff86c Mejorar el entorno de desarrollo
fixes #1190

fixes #732
2021-07-10 20:13:03 -03:00
f a2669e0aa4 actualización de cuidados 2021-06-15 17:07:52 -03:00
7 changed files with 253 additions and 211 deletions

View file

@ -1,3 +1,5 @@
DELEGATE=athshe.sutty.nl
HAINISH=../haini.sh/haini.sh
DATABASE=
RAILS_ENV=
IMAP_SERVER=

View file

@ -18,66 +18,66 @@ GIT
GEM
remote: https://gems.sutty.nl/
specs:
actioncable (6.1.3.2)
actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
actioncable (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.3.2)
actionpack (= 6.1.3.2)
activejob (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
actionmailbox (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
mail (>= 2.7.1)
actionmailer (6.1.3.2)
actionpack (= 6.1.3.2)
actionview (= 6.1.3.2)
activejob (= 6.1.3.2)
activesupport (= 6.1.3.2)
actionmailer (6.1.4)
actionpack (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activesupport (= 6.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.3.2)
actionview (= 6.1.3.2)
activesupport (= 6.1.3.2)
actionpack (6.1.4)
actionview (= 6.1.4)
activesupport (= 6.1.4)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.3.2)
actionpack (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
actiontext (6.1.4)
actionpack (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
nokogiri (>= 1.8.5)
actionview (6.1.3.2)
activesupport (= 6.1.3.2)
actionview (6.1.4)
activesupport (= 6.1.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.3.2)
activesupport (= 6.1.3.2)
activejob (6.1.4)
activesupport (= 6.1.4)
globalid (>= 0.3.6)
activemodel (6.1.3.2)
activesupport (= 6.1.3.2)
activerecord (6.1.3.2)
activemodel (= 6.1.3.2)
activesupport (= 6.1.3.2)
activestorage (6.1.3.2)
actionpack (= 6.1.3.2)
activejob (= 6.1.3.2)
activerecord (= 6.1.3.2)
activesupport (= 6.1.3.2)
activemodel (6.1.4)
activesupport (= 6.1.4)
activerecord (6.1.4)
activemodel (= 6.1.4)
activesupport (= 6.1.4)
activestorage (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activesupport (= 6.1.4)
marcel (~> 1.0.0)
mini_mime (~> 1.0.2)
activesupport (6.1.3.2)
mini_mime (>= 1.1.0)
activesupport (6.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
adhesiones-jekyll-theme (0.2.1)
jekyll (~> 4.0)
@ -89,11 +89,11 @@ GEM
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
ast (2.4.2)
autoprefixer-rails (10.2.5.0)
execjs (< 2.8.0)
autoprefixer-rails (10.2.5.1)
execjs (> 0)
bcrypt (3.1.16-x86_64-linux-musl)
bcrypt_pbkdf (1.1.0-x86_64-linux-musl)
benchmark-ips (2.8.4)
benchmark-ips (2.9.1)
bindex (0.8.1-x86_64-linux-musl)
blazer (2.4.2)
activerecord (>= 5)
@ -104,7 +104,7 @@ GEM
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
brakeman (5.0.1)
brakeman (5.0.4)
builder (3.2.4)
capybara (2.18.0)
addressable
@ -113,15 +113,15 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
chartkick (4.0.4)
chartkick (4.0.5)
childprocess (3.0.0)
coderay (1.1.3)
colorator (1.1.0)
commonmarker (0.21.2-x86_64-linux-musl)
ruby-enum (~> 0.5)
concurrent-ruby (1.1.8)
concurrent-ruby-ext (1.1.8-x86_64-linux-musl)
concurrent-ruby (= 1.1.8)
concurrent-ruby (1.1.9)
concurrent-ruby-ext (1.1.9-x86_64-linux-musl)
concurrent-ruby (= 1.1.9)
crass (1.0.6)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
@ -130,7 +130,7 @@ GEM
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
dead_end (1.1.7)
derailed_benchmarks (2.1.0)
derailed_benchmarks (2.1.1)
benchmark-ips (~> 2)
dead_end
get_process_mem (~> 0)
@ -148,8 +148,8 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-i18n (1.9.4)
devise (>= 4.7.1)
devise-i18n (1.10.0)
devise (>= 4.8.0)
devise_invitable (2.0.5)
actionmailer (>= 5.0)
devise (>= 4.6)
@ -157,7 +157,7 @@ GEM
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
down (5.2.1)
down (5.2.2)
addressable (~> 2.5)
ed25519 (1.2.4-x86_64-linux-musl)
editorial-autogestiva-jekyll-theme (0.3.4)
@ -188,7 +188,7 @@ GEM
exception_notification (4.4.3)
actionmailer (>= 4.0, < 7)
activesupport (>= 4.0, < 7)
execjs (2.7.0)
execjs (2.8.1)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
@ -196,7 +196,7 @@ GEM
railties (>= 5.0.0)
fast_blank (1.0.0-x86_64-linux-musl)
fast_jsonparser (0.5.0-x86_64-linux-musl)
ffi (1.15.0-x86_64-linux-musl)
ffi (1.15.3-x86_64-linux-musl)
flamegraph (0.9.5)
forwardable-extended (2.6.0)
friendly_id (5.4.2)
@ -214,7 +214,7 @@ GEM
tilt
haml-lint (0.999.999)
haml_lint
haml_lint (0.37.0)
haml_lint (0.37.1)
haml (>= 4.0, < 5.3)
parallel (~> 1.10)
rainbow
@ -264,8 +264,8 @@ GEM
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (~> 2.0)
jekyll-commonmark (1.3.1)
commonmarker (~> 0.14)
jekyll-commonmark (1.3.2)
commonmarker (~> 0.14, < 0.22)
jekyll (>= 3.7, < 5.0)
jekyll-data (1.1.2)
jekyll (>= 3.3, < 5.0.0)
@ -284,13 +284,11 @@ GEM
ruby-vips (~> 2)
jekyll-include-cache (0.2.1)
jekyll (>= 3.7, < 5.0)
jekyll-linked-posts (0.2.0)
jekyll-linked-posts (0.4.0)
jekyll (~> 4)
jekyll-locales (0.1.12)
jekyll-lunr (0.2.0)
jekyll-lunr (0.3.0)
loofah (~> 2.4)
jekyll-node-modules (0.1.0)
jekyll (~> 4)
jekyll-order (0.1.4)
jekyll-relative-urls (0.0.6)
jekyll (~> 4)
@ -298,7 +296,7 @@ GEM
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.7.1)
jekyll (>= 3.8, < 5.0)
jekyll-spree-client (0.1.14)
jekyll-spree-client (0.1.15)
fast_blank (~> 1)
spree-api-client (~> 0.2)
jekyll-turbolinks (0.0.5)
@ -326,13 +324,13 @@ GEM
ruby_dep (~> 1.2)
loaf (0.10.0)
railties (>= 3.2)
lockbox (0.6.4)
lockbox (0.6.5)
lograge (0.11.2)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.9.1)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
@ -343,11 +341,10 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mime-types-data (3.2021.0704)
mini_histogram (0.3.1)
mini_magick (4.11.0)
mini_mime (1.0.3)
mini_portile2 (2.5.1)
mini_mime (1.1.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
@ -360,12 +357,11 @@ GEM
net-ssh (6.1.0)
netaddr (2.0.4)
nio4r (2.5.7-x86_64-linux-musl)
nokogiri (1.11.5-x86_64-linux-musl)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.20.1)
parser (3.0.1.1)
parser (3.0.2.0)
ast (~> 2.4.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
@ -374,13 +370,13 @@ GEM
activerecord (>= 5.2)
activesupport (>= 5.2)
popper_js (1.16.0)
prometheus_exporter (0.7.0)
prometheus_exporter (0.8.0)
webrick
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
puma (5.3.1-x86_64-linux-musl)
puma (5.3.2-x86_64-linux-musl)
nio4r (~> 2.0)
pundit (2.1.0)
activesupport (>= 3.0.0)
@ -390,11 +386,11 @@ GEM
rack (>= 2.0.0)
rack-mini-profiler (2.3.2)
rack (>= 1.2.0)
rack-proxy (0.6.5)
rack-proxy (0.7.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
radios-comunitarias-jekyll-theme (0.1.4)
radios-comunitarias-jekyll-theme (0.1.5)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
@ -405,20 +401,20 @@ GEM
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
jekyll-turbolinks (~> 0)
rails (6.1.3.2)
actioncable (= 6.1.3.2)
actionmailbox (= 6.1.3.2)
actionmailer (= 6.1.3.2)
actionpack (= 6.1.3.2)
actiontext (= 6.1.3.2)
actionview (= 6.1.3.2)
activejob (= 6.1.3.2)
activemodel (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
rails (6.1.4)
actioncable (= 6.1.4)
actionmailbox (= 6.1.4)
actionmailer (= 6.1.4)
actionpack (= 6.1.4)
actiontext (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activemodel (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
bundler (>= 1.15.0)
railties (= 6.1.3.2)
railties (= 6.1.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
@ -430,40 +426,41 @@ GEM
railties (>= 6.0.0, < 7)
rails_warden (0.6.0)
warden (>= 1.2.0)
railties (6.1.3.2)
actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
railties (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
method_source
rake (>= 0.8.7)
rake (>= 0.13)
thor (~> 1.0)
rainbow (3.0.0)
rake (13.0.3)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
recursero-jekyll-theme (0.1.3)
jekyll (~> 4.0)
recursero-jekyll-theme (0.2.0)
jekyll (~> 4)
jekyll-commonmark (~> 1.3)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
jekyll-dotenv (>= 0.2)
jekyll-feed (~> 0.15)
jekyll-ignore-layouts (~> 0)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0.2)
jekyll-linked-posts (~> 0)
jekyll-locales (~> 0.1)
jekyll-lunr (~> 0.1)
jekyll-node-modules (~> 0.1)
jekyll-order (~> 0.1)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
jekyll-turbolinks (~> 0)
jekyll-order (~> 0)
jekyll-relative-urls (~> 0)
jekyll-seo-tag (~> 2)
jekyll-unique-urls (~> 0.1)
sutty-archives (~> 2.2)
sutty-liquid (~> 0.1)
redis (4.2.5)
sutty-liquid (~> 0)
redis (4.3.1)
redis-actionpack (5.2.0)
actionpack (>= 5, < 7)
redis-rack (>= 2.1.0, < 3)
redis-store (>= 1.1.0, < 2)
redis-activesupport (5.2.0)
redis-activesupport (5.2.1)
activesupport (>= 3, < 7)
redis-store (>= 1.3, < 2)
redis-rack (2.1.3)
@ -483,18 +480,18 @@ GEM
railties (>= 5.0)
rexml (3.2.5)
rouge (3.26.0)
rubocop (1.15.0)
rubocop (1.18.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rubocop-ast (>= 1.7.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
rubocop-ast (1.7.0)
parser (>= 3.0.1.1)
rubocop-rails (2.10.1)
rubocop-rails (2.11.3)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
@ -509,10 +506,10 @@ GEM
ruby_parser (~> 3.1)
sexp_processor (~> 4.6)
ruby_dep (1.5.0)
ruby_parser (3.15.1)
sexp_processor (~> 4.9)
rubyzip (2.3.0)
rugged (1.1.0-x86_64-linux-musl)
ruby_parser (3.16.0)
sexp_processor (~> 4.15, >= 4.15.1)
rubyzip (2.3.2)
rugged (1.1.1-x86_64-linux-musl)
safe_yaml (1.0.6)
safely_block (0.3.0)
errbase (>= 0.1.1)
@ -528,7 +525,7 @@ GEM
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
sexp_processor (4.15.2)
sexp_processor (4.15.3)
share-to-fediverse-jekyll-theme (0.1.4)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
@ -540,7 +537,7 @@ GEM
simpleidn (0.2.1)
unf (~> 0.1.4)
sourcemap (0.1.1)
spree-api-client (0.2.1)
spree-api-client (0.2.2)
fast_blank (~> 1)
httparty (~> 0.18.0)
spring (2.1.1)
@ -584,7 +581,7 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
symbol-fstring (1.0.0-x86_64-linux-musl)
symbol-fstring (1.0.2-x86_64-linux-musl)
sysexits (1.2.0)
temple (0.8.2)
terminal-table (2.0.0)
@ -619,7 +616,7 @@ GEM
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.7.0)
websocket-driver (0.7.3-x86_64-linux-musl)
websocket-driver (0.7.5-x86_64-linux-musl)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)

181
Makefile
View file

@ -1,134 +1,112 @@
.SHELL := /bin/bash
# Incluir las variables de entorno
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
root_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
include $(root_dir)/.env
SHELL := /bin/bash
.DEFAULT_GOAL := help
delegate := athshe
# Copiar el archivo de configuración y avisar cuando hay que
# actualizarlo.
.env: .env.example
@test -f $@ || cp -v $< $@
@test -f $@ && echo "Revisa $@ para actualizarlo con respecto a $<"
@test -f $@ && diff -auN --color $@ $<
assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f)
include .env
alpine_version := 3.13
hain ?= ../haini.sh/haini.sh
export
env ?= staging
# XXX: El espacio antes del comentario cuenta como espacio
args ?=## Argumentos para Hain
commit ?= origin/rails## Commit desde el que actualizar
env ?= staging## Entorno del nodo delegado
sutty ?= $(SUTTY)## Dirección local
delegate ?= $(DELEGATE)## Cambia el nodo delegado
hain ?= $(HAINISH)## Ubicación de Hainish
# El nodo delegado tiene dos entornos, production y staging.
# Dependiendo del entorno que elijamos, se van a generar los assets y el
# contenedor y subirse a un servidor u otro. No utilizamos CI/CD (aún).
#
# Production es el entorno de panel.sutty.nl
ifeq ($(env),production)
container ?= sutty
## TODO: Cambiar a otra cosa
branch ?= rails
public ?= public
endif
# Staging es el entorno de panel.staging.sutty.nl
ifeq ($(env),staging)
container := staging
branch := staging
public := staging
endif
export
help: always ## Ayuda
@echo -e "Sutty\n" | sed -re "s/^.*/\x1B[38;5;197m&\x1B[0m/"
@echo -e "Servidor: https://panel.$(SUTTY_WITH_PORT)/\n"
@echo -e "Uso: make TAREA args=\"ARGUMENTOS\"\n"
@echo -e "Tareas:\n"
@grep -E "^[a-z\-]+:.*##" Makefile | sed -re "s/(.*):.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/"
@echo -e "\nArgumentos:\n"
@grep -E "^[a-z\-]+ \?=.*##" Makefile | sed -re "s/(.*) \?=.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/"
public/packs/manifest.json.br: $(assets)
$(hain) 'cd /Sutty/sutty; PANEL_URL=https://panel.sutty.nl RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile assets:clean'
assets: node_modules public/packs/manifest.json.br ## Compilar los assets
assets: public/packs/manifest.json.br
test: always ## Ejecutar los tests
$(MAKE) rake args="test RAILS_ENV=test $(args)"
tests := $(shell find test/ -name "*_test.rb")
$(tests): always
$(hain) 'cd /Sutty/sutty; bundle exec rake test TEST="$@" RAILS_ENV=test'
test: always
$(hain) 'cd /Sutty/sutty; RAILS_ENV=test bundle exec rake test'
postgresql: /etc/hosts
postgresql: /etc/hosts ## Iniciar la base de datos
pgrep postgres >/dev/null || $(hain) postgresql
serve: /etc/hosts postgresql
serve-js: /etc/hosts node_modules ## Iniciar el servidor de desarrollo de Javascript
$(hain) 'bundle exec ./bin/webpack-dev-server'
serve: /etc/hosts postgresql Gemfile.lock ## Iniciar el servidor de desarrollo de Rails
$(MAKE) rails args=server
# make rails args="db:migrate"
rails:
rails: ## Corre rails dentro del entorno de desarrollo (pasar argumentos con args=).
$(MAKE) bundle args="exec rails $(args)"
rake:
rake: ## Corre rake dentro del entorno de desarrollo (pasar argumentos con args=).
$(MAKE) bundle args="exec rake $(args)"
bundle:
$(hain) 'cd /Sutty/sutty; bundle $(args)'
bundle: ## Corre bundle dentro del entorno de desarrollo (pasar argumentos con args=).
$(hain) 'bundle $(args)'
yarn:
rubocop: ## Yutea el código que está por ser commiteado
git status --porcelain \
| grep -E "^(A|M)" \
| sed "s/^...//" \
| grep ".rb$$" \
| ../haini.sh/haini.sh "xargs -r ./bin/rubocop --auto-correct"
audit: ## Encuentra dependencias con vulnerabilidades
$(hain) 'gem install bundler-audit'
$(hain) 'bundle audit --update'
brakeman: ## Busca posibles vulnerabilidades en Sutty
$(MAKE) bundle args='exec brakeman'
yarn: ## Tareas de yarn
$(hain) 'yarn $(args)'
# Servir JS con el dev server.
# Esto acelera la compilación del javascript, tiene que correrse por separado
# de serve.
serve-js: /etc/hosts
$(hain) 'cd /Sutty/sutty; bundle exec ./bin/webpack-dev-server'
clean: ## Limpieza
rm -rf _sites/test-* _deploy/test-* log/*.log tmp/cache tmp/letter_opener tmp/miniprofiler tmp/storage
# Limpiar los archivos de testeo
clean:
rm -rf _sites/test-* _deploy/test-*
# Generar la imagen Docker
build: assets
build: Gemfile.lock ## Generar la imagen Docker
time docker build --build-arg="BRANCH=$(branch)" --build-arg="RAILS_MASTER_KEY=`cat config/master.key`" -t sutty/$(container) .
docker tag sutty/$(container):latest sutty:keep
@echo -e "\a"
save:
time docker save sutty/$(container):latest | ssh root@$(delegate).sutty.nl docker load
save: ## Subir la imagen Docker al nodo delegado
time docker save sutty/$(container):latest | ssh root@$(delegate) docker load
date +%F | xargs -I {} git tag -f $(container)-{}
@echo -e "\a"
# proyectos.
../gems/:
mkdir -p $@
# Crear el directorio donde se almacenan las gemas binarias
# TODO: Mover a un proyecto propio, porque lo utilizamos en todos los
gem_dir := $(shell readlink -f ../gems)
gem_cache_dir := $(gem_dir)/cache
gem_binary_dir := $(gem_dir)/$(alpine_version)
ifeq ($(MAKECMDGOALS),build-gems)
gems := $(shell bundle show --paths | xargs -I {} sh -c 'find {}/ext/ -name extconf.rb &>/dev/null && basename {}')
gems := $(patsubst %-x86_64-linux,%,$(gems))
gems := $(patsubst %,$(gem_cache_dir)/%.gem,$(gems))
gems_musl := $(patsubst $(gem_cache_dir)/%.gem,$(gem_binary_dir)/%-x86_64-linux-musl.gem,$(gems))
endif
$(gem_binary_dir)/%-x86_64-linux-musl.gem:
@docker run \
-v $(gem_dir):/srv/gems \
-v `readlink -f ~/.ccache`:/home/builder/.ccache \
-e HTTP_BASIC_USER=$(HTTP_BASIC_USER) \
-e HTTP_BASIC_PASSWORD=$(HTTP_BASIC_PASSWORD) \
-e GEM=`echo $(notdir $*) | sed -re "s/-[^-]+$$//"` \
-e VERSION=`echo $(notdir $*) | sed -re "s/.*-([^-]+)$$/\1/"` \
-e JOBS=2 \
--rm -it \
sutty/gem-compiler:latest || echo "No se pudo compilar $*"
# Compilar todas las gemas binarias y subirlas a gems.sutty.nl para que
# al crear el contenedor no tengamos que compilarlas cada vez
build-gems: $(gems_musl)
cached_gems = $(wildcard $(gem_dir)/cache/*.gem)
rebuild_gems = $(patsubst $(gem_dir)/cache/%.gem,$(gem_dir)/$(alpine_version)/%-x86_64-linux-musl.gem,$(cached_gems))
rebuild-gems: $(rebuild_gems)
dirs := $(patsubst %,root/%,data sites deploy public)
$(dirs):
mkdir -p $@
ota: assets
ota-js: assets ## Actualizar Javascript en el nodo delegado
sudo chgrp -R 82 public/
rsync -avi --delete-after public/ $(delegate):/srv/sutty/srv/http/data/_$(public)/
ssh $(delegate) docker exec $(container) sh -c "cat /srv/http/tmp/puma.pid | xargs -r kill -USR2"
rsync -avi --delete-after public/ root@$(delegate):/srv/sutty/srv/http/data/_$(public)/
ssh root@$(delegate) docker exec $(container) sh -c "cat /srv/http/tmp/puma.pid | xargs -r kill -USR2"
# Hotfixes
#
# TODO: Reemplazar esto por git pull en el contenedor
commit ?= origin/rails
ota-rb:
ota: ## Actualizar Rails en el nodo delegado
umask 022; git format-patch $(commit)
scp ./0*.patch $(delegate):/tmp/
ssh $(delegate) mkdir -p /tmp/patches-$(commit)/
@ -140,6 +118,19 @@ ota-rb:
ssh $(delegate) docker exec $(container) ota $(commit)
rm ./0*.patch
# Todos los archivos de assets. Si alguno cambia, se van a recompilar
# los assets que luego se suben al nodo delegado.
assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f)
public/packs/manifest.json.br: $(assets)
$(hain) 'PANEL_URL=https://panel.sutty.nl RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile assets:clean'
# Correr un test en particular por ejemplo
# `make test/models/usuarie_test.rb`
tests := $(shell find test/ -name "*_test.rb")
$(tests): always
$(MAKE) test args="TEST=$@"
# Agrega las direcciones locales al sistema
/etc/hosts: always
@echo "Chequeando si es necesario agregar el dominio local $(SUTTY)"
@grep -q " $(SUTTY)$$" $@ || echo -e "127.0.0.1 $(SUTTY)\n::1 $(SUTTY)" | sudo tee -a $@
@ -147,4 +138,12 @@ ota-rb:
@grep -q " panel.$(SUTTY)$$" $@ || echo -e "127.0.0.1 panel.$(SUTTY)\n::1 panel.$(SUTTY)" | sudo tee -a $@
@grep -q " postgresql.$(SUTTY)$$" $@ || echo -e "127.0.0.1 postgresql.$(SUTTY)\n::1 postgresql.$(SUTTY)" | sudo tee -a $@
# Instala las dependencias de Javascript
node_modules: package.json
$(MAKE) yarn
# Instala las dependencias de Rails
Gemfile.lock: Gemfile
$(MAKE) bundle args=install
.PHONY: always

View file

@ -15,6 +15,17 @@ Este repositorio es la plataforma _Ruby on Rails_ para alojar el
Para más información visita el [sitio de Sutty](https://sutty.nl/).
### Desarrollar
Todas las tareas se gestionan con `make`, por favor instala GNU Make
antes de comenzar.
```bash
make help
```
[Leer la documentación](https://docs.sutty.nl/)
## English
Sutty is a platform for hosting safer, faster and more resilient
@ -25,3 +36,13 @@ This repository is the Ruby on Rails platform that hosts the
self-managed [panel](https://panel.sutty.nl/).
For more information, visit [Sutty's website](https://sutty.nl/en/).
### Development
Every task is run via `make`, please install GNU Make before developing.
```bash
make help
```
[Read the documentation](https://docs.sutty.nl/en/)

View file

@ -5,13 +5,23 @@ class DeployJob < ApplicationJob
class DeployException < StandardError; end
# rubocop:disable Metrics/MethodLength
def perform(site, notify = true)
def perform(site, notify = true, time = Time.now)
ActiveRecord::Base.connection_pool.with_connection do
@site = Site.find(site)
# Si ya hay una tarea corriendo, aplazar esta
# Si ya hay una tarea corriendo, aplazar esta. Si estuvo
# esperando más de 10 minutos, recuperar el estado anterior.
#
# Como el trabajo actual se aplaza al siguiente, arrastrar la
# hora original para poder ir haciendo timeouts.
if @site.building?
DeployJob.perform_in(60, site, notify)
if 10.minutes.ago >= time
@site.update status: 'waiting'
raise DeployException,
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
end
DeployJob.perform_in(60, site, notify, time)
return
end
@ -29,8 +39,11 @@ class DeployJob < ApplicationJob
end
deploy_others
notify_usuaries if notify
# Volver a la espera
@site.update status: 'waiting'
notify_usuaries if notify
end
end
# rubocop:enable Metrics/MethodLength

View file

@ -80,7 +80,7 @@ class DeployLocal < Deploy
# Corre yarn dentro del repositorio
def yarn
return unless yarn_lock?
return true unless yarn_lock?
run 'yarn'
end

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
# Agrega la columna de request_uri a la tabla de logs
class AddRequestUriToAccessLogs < ActiveRecord::Migration[6.1]
def change
return unless Rails.env.production?
add_column :access_logs, :request_uri, :string, default: ''
end
end