Compare commits

...

4 commits

Author SHA1 Message Date
f
af9baadea7 Merge branch 'develop' into antifascista 2021-10-14 10:40:22 -03:00
f
6c1a6b48a4 Merge branch 'develop' into antifascista 2021-10-13 12:39:26 -03:00
f
ea2cf81ab4 makefile 2021-10-05 20:21:45 -03:00
f
1bf468a262 Use gems compiled for Alpine Linux 2021-10-03 19:41:28 -03:00
3 changed files with 190 additions and 8 deletions

View file

@ -1,9 +1,9 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
source 'https://rubygems.org' source 'https://gems.sutty.nl'
# core - base # core - base
ruby '2.7.4' ruby '2.7.3'
gem 'rails', '~> 6.0.0' gem 'rails', '~> 6.0.0'
# core - rails additions # core - rails additions

View file

@ -17,7 +17,7 @@ GIT
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
GEM GEM
remote: https://rubygems.org/ remote: https://gems.sutty.nl/
specs: specs:
aasm (5.2.0) aasm (5.2.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -93,6 +93,9 @@ GEM
argon2 (2.1.1) argon2 (2.1.1)
ffi (~> 1.14) ffi (~> 1.14)
ffi-compiler (~> 1.0) ffi-compiler (~> 1.0)
argon2 (2.0.3-x86_64-linux-musl)
ffi (~> 1.14)
ffi-compiler (~> 1.0)
ast (2.4.2) ast (2.4.2)
async (1.30.1) async (1.30.1)
console (~> 1.10) console (~> 1.10)
@ -121,11 +124,14 @@ GEM
tzinfo tzinfo
bootsnap (1.9.1) bootsnap (1.9.1)
msgpack (~> 1.0) msgpack (~> 1.0)
bootsnap (1.9.1-x86_64-linux-musl)
msgpack (~> 1.0)
brakeman (5.1.1) brakeman (5.1.1)
browser (5.3.1) browser (5.3.1)
buftok (0.2.0) buftok (0.2.0)
builder (3.2.4) builder (3.2.4)
byebug (11.1.3) byebug (11.1.3)
byebug (11.1.3-x86_64-linux-musl)
capybara (3.35.3) capybara (3.35.3)
addressable addressable
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
@ -169,6 +175,7 @@ GEM
daemons (1.4.1) daemons (1.4.1)
dalli (2.7.11) dalli (2.7.11)
debug_inspector (1.1.0) debug_inspector (1.1.0)
debug_inspector (1.1.0-x86_64-linux-musl)
delayed_job (4.1.9) delayed_job (4.1.9)
activesupport (>= 3.0, < 6.2) activesupport (>= 3.0, < 6.2)
delayed_job_active_record (4.1.6) delayed_job_active_record (4.1.6)
@ -195,6 +202,7 @@ GEM
equalizer (0.0.11) equalizer (0.0.11)
erubi (1.10.0) erubi (1.10.0)
eventmachine (1.2.7) eventmachine (1.2.7)
eventmachine (1.2.7-x86_64-linux-musl)
execjs (2.8.1) execjs (2.8.1)
factory_bot (6.2.0) factory_bot (6.2.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
@ -226,7 +234,7 @@ GEM
faraday-rack (1.0.0) faraday-rack (1.0.0)
faraday_middleware (1.1.0) faraday_middleware (1.1.0)
faraday (~> 1.0) faraday (~> 1.0)
ffi (1.15.4) ffi (1.15.4-x86_64-linux-musl)
ffi-compiler (1.0.1) ffi-compiler (1.0.1)
ffi (>= 1.0.0) ffi (>= 1.0.0)
rake rake
@ -267,6 +275,7 @@ GEM
hashdiff (1.0.1) hashdiff (1.0.1)
hashie (4.1.0) hashie (4.1.0)
hiredis (0.6.3) hiredis (0.6.3)
hiredis (0.6.3-x86_64-linux-musl)
htmlentities (4.3.4) htmlentities (4.3.4)
http (4.4.1) http (4.4.1)
addressable (~> 2.3) addressable (~> 2.3)
@ -277,9 +286,10 @@ GEM
http-cookie (1.0.4) http-cookie (1.0.4)
domain_name (~> 0.5) domain_name (~> 0.5)
http-form_data (2.3.0) http-form_data (2.3.0)
http-parser (1.2.3) http-parser (1.2.3-x86_64-linux-musl)
ffi-compiler (>= 1.0, < 2.0) ffi-compiler (>= 1.0, < 2.0)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
http_parser.rb (0.6.0-x86_64-linux-musl)
httpclient (2.8.3) httpclient (2.8.3)
i18n (1.8.10) i18n (1.8.10)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -292,14 +302,16 @@ GEM
inflection (1.0.0) inflection (1.0.0)
iniparse (1.5.0) iniparse (1.5.0)
interception (0.5) interception (0.5)
json (2.5.1) json (2.5.1-x86_64-linux-musl)
jwt (2.3.0) jwt (2.3.0)
kgio (2.11.4) kgio (2.11.4)
kgio (2.11.4-x86_64-linux-musl)
koala (3.0.0) koala (3.0.0)
addressable addressable
faraday faraday
json (>= 1.8) json (>= 1.8)
libv8 (8.4.255.0) libv8 (8.4.255.0)
libv8 (8.4.255.0-x86_64-linux)
listen (3.7.0) listen (3.7.0)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
@ -325,19 +337,25 @@ GEM
libv8 (>= 6.9.411) libv8 (>= 6.9.411)
minitest (5.14.4) minitest (5.14.4)
msgpack (1.4.2) msgpack (1.4.2)
msgpack (1.4.2-x86_64-linux-musl)
multi_json (1.15.0) multi_json (1.15.0)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.1.1) multipart-post (2.1.1)
mysql2 (0.5.3) mysql2 (0.5.3)
mysql2 (0.5.3-x86_64-linux-musl)
naught (1.1.0) naught (1.1.0)
nenv (0.3.0) nenv (0.3.0)
nestful (1.1.4) nestful (1.1.4)
net-ldap (0.17.0) net-ldap (0.17.0)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.5.8) nio4r (2.5.8)
nio4r (2.5.8-x86_64-linux-musl)
nokogiri (1.12.5) nokogiri (1.12.5)
mini_portile2 (~> 2.6.1) mini_portile2 (~> 2.6.1)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux-musl)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
nori (2.6.0) nori (2.6.0)
notiffany (0.1.3) notiffany (0.1.3)
nenv (~> 0.1) nenv (~> 0.1)
@ -392,6 +410,7 @@ GEM
omniauth (~> 1.5) omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0) omniauth-oauth2 (>= 1.4.0)
openssl (2.2.0) openssl (2.2.0)
openssl (2.2.0-x86_64-linux-musl)
overcommit (0.58.0) overcommit (0.58.0)
childprocess (>= 0.6.3, < 5) childprocess (>= 0.6.3, < 5)
iniparse (~> 1.4) iniparse (~> 1.4)
@ -400,6 +419,7 @@ GEM
parser (3.0.2.0) parser (3.0.2.0)
ast (~> 2.4.1) ast (~> 2.4.1)
pg (0.21.0) pg (0.21.0)
pg (0.21.0-x86_64-linux-musl)
power_assert (2.0.1) power_assert (2.0.1)
protocol-hpack (1.4.2) protocol-hpack (1.4.2)
protocol-http (0.22.5) protocol-http (0.22.5)
@ -425,11 +445,14 @@ GEM
public_suffix (4.0.6) public_suffix (4.0.6)
puma (4.3.10) puma (4.3.10)
nio4r (~> 2.0) nio4r (~> 2.0)
puma (4.3.8-x86_64-linux-musl)
nio4r (~> 2.0)
pundit (2.1.1) pundit (2.1.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
pundit-matchers (1.7.0) pundit-matchers (1.7.0)
rspec-rails (>= 3.0.0) rspec-rails (>= 3.0.0)
racc (1.5.2) racc (1.5.2)
racc (1.5.2-x86_64-linux-musl)
rack (2.2.3) rack (2.2.3)
rack-livereload (0.3.17) rack-livereload (0.3.17)
rack rack
@ -467,6 +490,7 @@ GEM
thor (>= 0.20.3, < 2.0) thor (>= 0.20.3, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
raindrops (0.19.2) raindrops (0.19.2)
raindrops (0.19.2-x86_64-linux-musl)
rake (13.0.6) rake (13.0.6)
rb-fsevent (0.11.0) rb-fsevent (0.11.0)
rb-inotify (0.10.1) rb-inotify (0.10.1)
@ -497,7 +521,7 @@ GEM
rspec-mocks (~> 3.10) rspec-mocks (~> 3.10)
rspec-support (~> 3.10) rspec-support (~> 3.10)
rspec-support (3.10.2) rspec-support (3.10.2)
rszr (0.5.2) rszr (0.5.2-x86_64-linux-musl)
rubocop (1.22.1) rubocop (1.22.1)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.0.0.0) parser (>= 3.0.0.0)
@ -534,6 +558,8 @@ GEM
rubyzip (2.3.2) rubyzip (2.3.2)
sassc (2.4.0) sassc (2.4.0)
ffi (~> 1.9) ffi (~> 1.9)
sassc (2.4.0-x86_64-linux-musl)
ffi (~> 1.9)
sassc-rails (2.1.2) sassc-rails (2.1.2)
railties (>= 4.0.0) railties (>= 4.0.0)
sassc (>= 2.0) sassc (>= 2.0)
@ -615,10 +641,14 @@ GEM
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.8) unf_ext (0.0.8)
unf_ext (0.0.8-x86_64-linux-musl)
unicode-display_width (2.1.0) unicode-display_width (2.1.0)
unicorn (6.0.0) unicorn (6.0.0)
kgio (~> 2.6) kgio (~> 2.6)
raindrops (~> 0.7) raindrops (~> 0.7)
unicorn (6.0.0-x86_64-linux-musl)
kgio (~> 2.6)
raindrops (~> 0.7)
valid_email2 (4.0.0) valid_email2 (4.0.0)
activemodel (>= 3.2) activemodel (>= 3.2)
mail (~> 2.5) mail (~> 2.5)
@ -634,6 +664,8 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0) hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.5) websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-driver (0.7.5-x86_64-linux-musl)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
writeexcel (1.0.5) writeexcel (1.0.5)
xpath (3.2.0) xpath (3.2.0)
@ -648,6 +680,7 @@ GEM
PLATFORMS PLATFORMS
ruby ruby
x86_64-linux-musl
DEPENDENCIES DEPENDENCIES
aasm aasm
@ -764,7 +797,7 @@ DEPENDENCIES
zendesk_api zendesk_api
RUBY VERSION RUBY VERSION
ruby 2.7.4p191 ruby 2.7.3p183
BUNDLED WITH BUNDLED WITH
2.2.27 2.2.27

149
Makefile Normal file
View file

@ -0,0 +1,149 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help
# 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 $@ $<
include .env
export
# 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
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/"
assets: node_modules public/packs/manifest.json.br ## Compilar los assets
test: always ## Ejecutar los tests
$(MAKE) rake args="test RAILS_ENV=test $(args)"
postgresql: /etc/hosts ## Iniciar la base de datos
pgrep postgres >/dev/null || $(hain) 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
rails: ## Corre rails dentro del entorno de desarrollo (pasar argumentos con args=).
$(MAKE) bundle args="exec rails $(args)"
rake: ## Corre rake dentro del entorno de desarrollo (pasar argumentos con args=).
$(MAKE) bundle args="exec rake $(args)"
bundle: ## Corre bundle dentro del entorno de desarrollo (pasar argumentos con args=).
$(hain) 'bundle $(args)'
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)'
clean: ## Limpieza
rm -rf _sites/test-* _deploy/test-* log/*.log tmp/cache tmp/letter_opener tmp/miniprofiler tmp/storage
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: ## 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"
ota-js: assets ## Actualizar Javascript en el nodo delegado
sudo chgrp -R 82 public/
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"
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)/
scp ./0*.patch $(delegate):/tmp/patches-$(commit)/
scp ./ota.sh $(delegate):/tmp/
ssh $(delegate) docker cp /tmp/patches-$(shell echo $(commit) | cut -d / -f 1) $(container):/tmp/
ssh $(delegate) docker cp /tmp/ota.sh $(container):/usr/local/bin/ota
ssh $(delegate) docker exec $(container) apk add --no-cache patch
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 $@
@grep -q " api.$(SUTTY)$$" $@ || echo -e "127.0.0.1 api.$(SUTTY)\n::1 api.$(SUTTY)" | sudo tee -a $@
@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