5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 16:36:22 +00:00
panel/Makefile

100 lines
3.2 KiB
Makefile
Raw Normal View History

2019-09-18 18:47:43 +00:00
# Incluir las variables de entorno
2019-10-16 17:56:49 +00:00
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
root_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
include $(root_dir)/.env
2019-09-18 18:47:43 +00:00
delegate := anarres
assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f)
public/assets-production: $(assets)
rm -rf $@
RAILS_ENV=production bundle exec rake assets:precompile
mv public/assets $@
find $@ -type f -name "*.gz" | sed -re "s/\.gz$$//" | xargs -r brotli -k -9
public/packs-production: public/packs
rm -rf $@
mv $< $@
2020-06-25 19:38:37 +00:00
find $@ -type f | xargs -r brotli -k -9
mkdir -p $<
touch $@
assets: public/assets-production public/packs-production
serve:
bundle exec rails s -b "ssl://0.0.0.0:3000?key=config/sutty.local.key&cert=config/sutty.local.crt"
2019-09-18 18:47:43 +00:00
# Limpiar los archivos de testeo
clean:
rm -rf _sites/test-* _deploy/test-*
# Generar la imagen Docker
build: assets
time docker build --build-arg="RAILS_MASTER_KEY=`cat config/master.key`" -t sutty/sutty .
2019-09-18 18:47:43 +00:00
2019-11-16 23:13:30 +00:00
save:
time docker save sutty/sutty:latest | ssh root@$(delegate).sutty.nl docker load
2019-11-16 23:13:30 +00:00
load:
ssh root@sutty.nl sh -c "gunzip -c sutty.latest.gz | docker load"
2019-09-18 18:47:43 +00:00
# Crear el directorio donde se almacenan las gemas binarias
../gems/:
mkdir -p $@
ifeq ($(MAKECMDGOALS),convert-gems)
2019-10-16 17:56:49 +00:00
gem_dir := $(shell readlink -f ../gems)
2019-12-14 16:22:07 +00:00
gems := $(shell bundle show --paths | xargs -I {} sh -c 'test -f {}/ext/*/extconf.rb && basename {}')
2019-12-30 18:29:40 +00:00
gems += $(shell bundle show --paths | xargs -I {} sh -c 'test -f {}/ext/extconf.rb && basename {}')
gems := $(patsubst %-x86_64-linux,%,$(gems))
2019-10-16 17:56:49 +00:00
gems_musl := $(patsubst %,$(gem_dir)/%-x86_64-linux-musl.gem,$(gems))
gems_gnu := $(patsubst %,$(gem_dir)/%-x86_64-linux.gem,$(gems))
endif
2019-10-16 17:56:49 +00:00
$(gem_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 $* | sed -re "s/-[^-]+$$//"` \
-e VERSION=`echo $* | sed -re "s/.*-([^-]+)$$/\1/"` \
-e JOBS=2 \
--rm \
2019-10-16 17:56:49 +00:00
sutty/gem-compiler:latest
$(gem_dir)/%-x86_64-linux.gem:
HTTP_BASIC_USER=$(HTTP_BASIC_USER) \
HTTP_BASIC_PASSWORD=$(HTTP_BASIC_PASSWORD) \
GEM=`echo $* | sed -re "s/-[^-]+$$//"` \
VERSION=`echo $* | sed -re "s/.*-([^-]+)$$/\1/"` && \
cd $(dir $@) && \
gem fetch --source=https://gems.sutty.nl --platform=ruby \
--version $${VERSION} $${GEM} && \
gem compile -V --prune $${GEM}-$${VERSION}.gem && \
gem inabox -o $@ \
--host https://$${HTTP_BASIC_USER}:$${HTTP_BASIC_PASSWORD}@gems.sutty.nl
2019-09-18 18:47:43 +00:00
# Compilar todas las gemas binarias y subirlas a gems.sutty.nl para que
# al crear el contenedor no tengamos que compilarlas cada vez
2019-10-16 17:56:49 +00:00
convert-gems: $(gems_musl)
dirs := $(patsubst %,root/%,data sites deploy public)
$(dirs):
mkdir -p $@
test-container: $(dirs)
docker run -v $(PWD)/root/data:/srv/http/data \
-v $(PWD)/root/sites:/srv/http/_sites \
-v $(PWD)/root/deploy:/srv/http/_deploy \
-v $(PWD)/root/public:/srv/http/_public \
-v $(PWD)/config/credentials.yml.enc:/srv/http/config/credentials.yml.enc \
-e RAILS_MASTER_KEY=`cat config/master.key` \
2019-12-30 18:29:40 +00:00
-e RAILS_ENV=production \
2019-10-16 17:56:49 +00:00
-it \
--rm \
--name=sutty \
2019-12-30 18:29:40 +00:00
sutty/sutty /bin/sh