-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
64 lines (51 loc) · 2.72 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
# Some helpful utility commands.
# make sure to replace this with the IP of your own server
DOCKER_SERVER=159.203.191.135
all: copy_secrets deploy migrate
bash:
ssh root@$(DOCKER_SERVER)
migrate:
# run python manage.py syncdb
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py syncdb --noinput'
# run python manage.py migrate
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py migrate'
deploy: copy_secrets
# build the stack
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose build'
# stop the stack (supervisord will restart it)
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose stop'
copy_secrets:
# copies the .env file and the key to the server
scp .env root@$(DOCKER_SERVER):/code/djangopackages/.env
fetchnewdata:
# run backup
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run postgres backup'
# download latest backup
scp root@$(DOCKER_SERVER):/data/djangopackages/backups/`ssh root@$(DOCKER_SERVER) ls -1t /data/djangopackages/backups/ | head -1` latest.dump
dropdb oc
createdb oc
pg_restore --verbose --clean --no-acl --no-owner -j 2 -h localhost -d oc latest.dump
migrate_heroku_db_to_docker:
# create a dump of the heroku db
heroku pg:backups capture --app djangopackages
# download the dump
curl -o heroku.dump `heroku pg:backups public-url --app djangopackages`
# convert the dump to raw sql
pg_restore -f heroku.sql heroku.dump
# copy the dump to the server
scp heroku.sql root@$(DOCKER_SERVER):/data/djangopackages/backups/heroku.sql
# restore dump
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run postgres restore heroku.sql'
migrate_db_to_new_home:
#ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run postgres backup'
scp root@$(DOCKER_SERVER):/data/djangopackages/backups/`ssh root@$(DOCKER_SERVER) ls -1t /data/djangopackages/backups/ | head -1` latest.dump
scp -P 56565 latest.dump [email protected]:/data-slow/djangopackages/backups/latest.dump
ssh [email protected] -p56565 -C 'cd /code/djangopackages && docker-compose run postgres restore latest.dump'
shell:
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py shell_plus'
runcron:
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py pypi_updater'
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py package_updater'
ssh root@$(DOCKER_SERVER) -C 'cd /code/djangopackages && docker-compose run django python manage.py searchv2_build'
test:
python manage.py test --settings=settings.test