2016-02-12 23:52:43 +08:00
|
|
|
APP_HOME="/usr/src/app"
|
2017-06-02 22:34:01 +08:00
|
|
|
DB_IP=$(shell docker inspect scinote_db_development | grep "\"IPAddress\": " | awk '{ match($$0, /"IPAddress": "([0-9\.]*)",/, a); print a[1] }')
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2017-03-29 22:00:11 +08:00
|
|
|
define PRODUCTION_CONFIG_BODY
|
|
|
|
SECRET_KEY_BASE=$(shell openssl rand -hex 64)
|
|
|
|
PAPERCLIP_HASH_SECRET=$(shell openssl rand -base64 128 | tr -d '\n')
|
|
|
|
DATABASE_URL=postgresql://postgres@db/scinote_production
|
|
|
|
PAPERCLIP_STORAGE=filesystem
|
|
|
|
ENABLE_TUTORIAL=true
|
|
|
|
ENABLE_RECAPTCHA=false
|
|
|
|
ENABLE_USER_CONFIRMATION=false
|
|
|
|
ENABLE_USER_REGISTRATION=true
|
2017-04-24 16:12:07 +08:00
|
|
|
DEFACE_ENABLED=false
|
2017-03-29 22:00:11 +08:00
|
|
|
endef
|
|
|
|
export PRODUCTION_CONFIG_BODY
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
all: docker database
|
|
|
|
|
|
|
|
heroku:
|
|
|
|
@heroku buildpacks:remove https://github.com/ddollar/heroku-buildpack-multi.git
|
|
|
|
@heroku buildpacks:set https://github.com/ddollar/heroku-buildpack-multi.git
|
|
|
|
@echo "Set environment variables, DATABASE_URL, RAILS_SERVE_STATIC_FILES, RAKE_ENV, RAILS_ENV, SECRET_KEY_BASE, SKYLIGHT_AUTHENTICATION"
|
|
|
|
|
|
|
|
docker:
|
|
|
|
@docker-compose build
|
|
|
|
|
2017-03-17 17:48:20 +08:00
|
|
|
docker-production:
|
|
|
|
@docker-compose -f docker-compose.production.yml build
|
|
|
|
|
2017-03-29 22:00:11 +08:00
|
|
|
config-production:
|
|
|
|
ifeq (production.env,$(wildcard production.env))
|
|
|
|
$(error File production.env already exists!)
|
|
|
|
endif
|
|
|
|
@echo "$$PRODUCTION_CONFIG_BODY" > production.env ;
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
db-cli:
|
|
|
|
@$(MAKE) rails cmd="rails db"
|
|
|
|
|
2016-07-21 19:11:15 +08:00
|
|
|
db-load-dump:
|
|
|
|
@$(MAKE) rails cmd="rake db:drop db:create;pg_restore --verbose --clean --no-acl --no-owner -h $(DB_IP) -p 5432 -U postgres -d scinote_development latest.dump"
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
database:
|
|
|
|
@$(MAKE) rails cmd="rake db:create db:setup db:migrate"
|
|
|
|
|
2017-03-29 22:00:11 +08:00
|
|
|
database-production:
|
|
|
|
@$(MAKE) rails-production cmd="bash -c 'while ! nc -z db 5432; do sleep 1; done; rake db:create && rake db:migrate && rake db:seed'"
|
|
|
|
|
2017-04-24 16:12:07 +08:00
|
|
|
deface:
|
|
|
|
@$(MAKE) rails cmd="rake deface:precompile"
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
rails:
|
2017-03-17 17:48:20 +08:00
|
|
|
@docker-compose run --rm web $(cmd)
|
|
|
|
|
|
|
|
rails-production:
|
|
|
|
@docker-compose -f docker-compose.production.yml run --rm web $(cmd)
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
run:
|
2016-07-21 19:11:15 +08:00
|
|
|
rm tmp/pids/server.pid || true
|
|
|
|
@docker-compose up -d
|
2017-04-21 15:45:30 +08:00
|
|
|
@docker attach scinote_web_development
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
start:
|
|
|
|
@docker-compose start
|
|
|
|
|
|
|
|
stop:
|
|
|
|
@docker-compose stop
|
|
|
|
|
2016-11-19 22:26:16 +08:00
|
|
|
worker:
|
|
|
|
@$(MAKE) rails cmd="rake jobs:work"
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
cli:
|
|
|
|
@$(MAKE) rails cmd="/bin/bash"
|
|
|
|
|
2017-03-17 17:48:20 +08:00
|
|
|
cli-production:
|
|
|
|
@$(MAKE) rails-production cmd="/bin/bash"
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
tests:
|
|
|
|
@$(MAKE) rails cmd="rake test"
|
|
|
|
|
|
|
|
console:
|
|
|
|
@$(MAKE) rails cmd="rails console"
|
|
|
|
|
2017-03-29 22:00:11 +08:00
|
|
|
console-production:
|
|
|
|
@$(MAKE) rails-production cmd="rails console"
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
log:
|
|
|
|
@docker-compose web log
|
|
|
|
|
|
|
|
status:
|
|
|
|
@docker-compose ps
|
|
|
|
|
|
|
|
export:
|
|
|
|
@git checkout-index -a -f --prefix=scinote/
|
|
|
|
@tar -zcvf scinote-$(shell git rev-parse --short HEAD).tar.gz scinote
|
|
|
|
@rm -rf scinote
|