David K. Bainbridge | a0241eb | 2015-12-09 09:54:40 -0800 | [diff] [blame] | 1 | IMAGE_NAME:=xosproject/xos-postgres |
| 2 | CONTAINER_NAME:=xos-db-postgres |
David K. Bainbridge | b7a3ee1 | 2015-12-03 20:24:30 -0800 | [diff] [blame] | 3 | NO_DOCKER_CACHE?=false |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 4 | |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 5 | .PHONY: build |
David K. Bainbridge | b7a3ee1 | 2015-12-03 20:24:30 -0800 | [diff] [blame] | 6 | build: ; docker build --no-cache=${NO_DOCKER_CACHE} --rm -t ${IMAGE_NAME} . |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 7 | |
| 8 | .PHONY: run |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 9 | run: ; docker run -d -p 5432:5432 --name ${CONTAINER_NAME} ${IMAGE_NAME} |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 10 | |
| 11 | .PHONY: stop |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 12 | stop: ; docker stop ${CONTAINER_NAME} |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 13 | |
| 14 | .PHONY: rm |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 15 | rm: ; docker rm ${CONTAINER_NAME} |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 16 | |
| 17 | .PHONE: rmi |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 18 | rmi: ; docker rmi ${IMAGE_NAME} |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 19 | |
| 20 | .PHONY: backup |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 21 | backupvol: ; docker run --volumes-from ${CONTAINER_NAME} -v /backup:/backup postgres tar cvf /backup/backup-postgres.tar /var/lib/postgresql |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 22 | |
| 23 | .PHONY: restore |
David K. Bainbridge | 9c24cbf | 2015-12-03 11:49:01 -0800 | [diff] [blame] | 24 | restorevol: ; docker run --volumes-from ${CONTAINER_NAME} -v /backup:/backup postgres cd /var/lib/postgresql && tar xvf /backup/backup-postgres.tar |
Tony Mack | 8a261c6 | 2015-10-29 21:14:41 +0000 | [diff] [blame] | 25 | |