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
|
|
|
|
2020-09-22 18:17:59 +00:00
|
|
|
delegate := athshe
|
2020-09-11 17:46:23 +00:00
|
|
|
|
2020-06-01 21:46:06 +00:00
|
|
|
assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f)
|
|
|
|
|
2020-10-08 18:15:50 +00:00
|
|
|
alpine_version := 3.12
|
|
|
|
|
2020-11-19 23:35:29 +00:00
|
|
|
public/assets-production/: $(assets)
|
2020-11-20 00:24:49 +00:00
|
|
|
RAILS_ENV=production bundle exec rake assets:precompile assets:clean
|
2020-11-19 23:35:29 +00:00
|
|
|
rsync --delete-after -a public/assets/ $@
|
2020-06-01 21:46:06 +00:00
|
|
|
|
2020-11-19 23:35:29 +00:00
|
|
|
public/packs-production/: public/packs/
|
|
|
|
rsync -a --delete-after $< $@
|
2020-06-01 21:46:06 +00:00
|
|
|
|
2020-11-19 23:35:29 +00:00
|
|
|
assets: public/assets-production/ public/packs-production/
|
2020-06-01 21:46:06 +00:00
|
|
|
|
2020-02-06 16:18:10 +00:00
|
|
|
serve:
|
2020-11-19 23:35:29 +00:00
|
|
|
bundle exec rails s -b "ssl://0.0.0.0:3000?key=../sutty.local/domain/sutty.local.key&cert=../sutty.local/domain/sutty.local.crt"
|
2020-02-06 16:18:10 +00:00
|
|
|
|
2019-09-18 18:47:43 +00:00
|
|
|
# Limpiar los archivos de testeo
|
|
|
|
clean:
|
|
|
|
rm -rf _sites/test-* _deploy/test-*
|
|
|
|
|
|
|
|
# Generar la imagen Docker
|
2020-06-01 21:46:06 +00:00
|
|
|
build: assets
|
|
|
|
time docker build --build-arg="RAILS_MASTER_KEY=`cat config/master.key`" -t sutty/sutty .
|
2020-09-22 18:17:59 +00:00
|
|
|
docker tag sutty/sutty:latest sutty:keep
|
2019-09-18 18:47:43 +00:00
|
|
|
|
2019-11-16 23:13:30 +00:00
|
|
|
save:
|
2020-09-11 17:46:23 +00:00
|
|
|
time docker save sutty/sutty:latest | ssh root@$(delegate).sutty.nl docker load
|
2020-09-22 18:17:59 +00:00
|
|
|
date +%F | xargs git tag -f
|
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 $@
|
|
|
|
|
2019-10-16 17:56:49 +00:00
|
|
|
gem_dir := $(shell readlink -f ../gems)
|
2020-10-08 18:15:50 +00:00
|
|
|
ifeq ($(MAKECMDGOALS),build-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 {}')
|
2020-10-08 18:15:50 +00:00
|
|
|
gems := $(patsubst %,$(gem_dir)/cache/%.gem,$(gems))
|
|
|
|
gems_musl := $(patsubst $(gem_dir)/cache/%.gem,$(gem_dir)/$(alpine_version)/%-x86_64-linux-musl.gem,$(gems))
|
2020-02-06 17:18:14 +00:00
|
|
|
endif
|
2019-10-16 17:56:49 +00:00
|
|
|
|
|
|
|
$(gem_dir)/%-x86_64-linux-musl.gem:
|
2020-10-08 18:15:50 +00:00
|
|
|
@docker run \
|
2019-10-16 17:56:49 +00:00
|
|
|
-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) \
|
2020-10-08 18:15:50 +00:00
|
|
|
-e GEM=`echo $(notdir $*) | sed -re "s/-[^-]+$$//"` \
|
|
|
|
-e VERSION=`echo $(notdir $*) | sed -re "s/.*-([^-]+)$$/\1/"` \
|
2020-06-01 21:46:06 +00:00
|
|
|
-e JOBS=2 \
|
2020-10-08 18:15:50 +00:00
|
|
|
--rm -it \
|
|
|
|
sutty/gem-compiler:latest || echo "No se pudo compilar $*"
|
2020-06-01 21:46:06 +00:00
|
|
|
|
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
|
2020-10-08 18:15:50 +00:00
|
|
|
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)
|
2019-10-16 17:56:49 +00:00
|
|
|
|
|
|
|
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
|