-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (54 loc) · 2.13 KB
/
Makefile
File metadata and controls
58 lines (54 loc) · 2.13 KB
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
dc=docker compose -f docker-compose.yml $(1)
dc-run=$(call dc, run --rm web $(1))
dc-run-sp=$(call dc, run --service-ports --rm web $(1))
usage:
@echo "Available targets:"
@echo " * setup - Initiates everything (building images, installing gems, creating db and migrating"
@echo " * build - Build image"
@echo " * bundle - Install missing gems"
@echo " * db-migrate - Runs the migrations for dev database"
@echo " * db-test-migrate - Runs the migrations for test database"
@echo " * seed - Seeds dev database with example profiles, and indexes them in Elasticsearch"
@echo " * dev - Fires a shell inside your container"
@echo " * up - Runs the development server"
@echo " * tear-down - Removes all the containers and tears down the setup"
@echo " * stop - Stops the server"
@echo " * test - Runs all tests"
# With db
setup: build bundle db-create db-migrate db-test-migrate
build:
$(call dc, build)
bundle:
$(call dc-run, bundle install)
dev:
$(call dc-run, bash)
up:
$(call dc-run-sp)
tear-down:
$(call dc, down)
stop:
$(call dc, stop)
console:
$(call dc-run, bundle exec rails console)
db-create:
$(call dc-run, bundle exec rake db:create)
db-migrate:
$(call dc-run, bundle exec rake db:migrate)
db-test-migrate:
$(call dc-run, bundle exec rake db:migrate RAILS_ENV=test)
seed:
$(call dc-run, sh -c 'rake db:seed')
test:
$(call dc-run-sp, sh -c 'bundle exec rspec')
# Restore local DB from latest.dump
restore-db:
@echo "Stopping DB container..."
docker compose down -v
@echo "Starting DB container..."
docker compose up -d db
@echo "Dropping and creating development database..."
docker compose exec db psql -U postgres -c "DROP DATABASE IF EXISTS speakerinnen_development;"
docker compose exec db psql -U postgres -c "CREATE DATABASE speakerinnen_development;"
@echo "Restoring latest.dump..."
cat latest.dump | docker compose exec -T db pg_restore -U postgres -d speakerinnen_development --clean --if-exists --no-owner
@echo "Database restore complete!"