forked from ruby-china/homeland-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (65 loc) · 2.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
RAKE = docker-compose run app bundle exec rake
RUN = docker-compose run app
RUN_WEB = docker-compose run web
ACME = /root/.acme.sh/acme.sh
ACME_HOME = --home /var/www/ssl
install:
@make secret
@touch app.local.env
@$(RUN) bundle install --retry=3 --jobs=2
@$(RUN) bundle exec rails db:create
@$(RUN) bundle exec rails db:migrate
@$(RUN) bundle exec rails db:seed
@$(RUN) bundle exec rails assets:precompile RAILS_ENV=production
@make reindex
install_ssl:
rm -f etc/nginx/conf.d/homeland/ssl.conf
docker-compose start web
$(RUN_WEB) bash -c 'echo $$domain'
$(RUN_WEB) bash -c '$(ACME) --issue -d $$domain -w /var/www/homeland/public $(ACME_HOME) --debug'
openssl dhparam -out shared/ssl/dhparam.pem 2048
cp etc/nginx/conf.d/homeland/ssl.conf.default etc/nginx/conf.d/homeland/ssl.conf
$(RUN_WEB) bash -c '$(ACME) --installcert $(ACME_HOME) -d $$domain --keypath /var/www/ssl/homeland.key --fullchainpath /var/www/ssl/homeland.crt --reloadcmd "nginx -s reload"'
@echo "---------------------------------------------\n\nSSL install successed.\n\nNow you need enable https=true by update app.local.env.\nAnd then run: make restart\n\n"
update:
@make secret
@touch app.local.env
@$(RUN) bundle exec rails db:migrate
@$(RUN) bundle exec rails assets:precompile RAILS_ENV=production
@make stop && make start
@make clean
restart:
@make stop && make start
start:
@docker-compose up -d
status:
@docker-compose ps
stop:
@docker-compose stop web app worker
stop-all:
@docker-compose down
console:
@$(RUN) bundle exec rails console
reindex:
@echo "Reindex ElasticSearch..."
@$(RAKE) environment elasticsearch:import:model CLASS=Topic FORCE=y
@$(RAKE) environment elasticsearch:import:model CLASS=Page FORCE=y
@$(RAKE) environment elasticsearch:import:model CLASS=User FORCE=y
secret:
@test -f app.secret.env || echo "secret_key_base=`openssl rand -hex 32`" > app.secret.env
@cat app.secret.env
start-brew-services:
@brew services start memcached
@brew services start postgres
@brew services start redis
@brew services start elasticsearch
@brew services start nginx
stop-brew-services:
@brew services stop memcached
@brew services stop postgres
@brew services stop redis
@brew services stop elasticsearch
@brew services stop nginx
clean:
@echo "Clean Docker images..."
@docker ps -aqf status=exited | xargs docker rm && docker images -qf dangling=true | xargs docker rmi