forked from compsoc-edinburgh/email-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
63 lines (43 loc) · 1.41 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
# pull in from dotenv
include .env
export
DOCKER_TAG_NAME = compsoc-email-studio
REMOTE = [email protected]
REMOTE_DESTINATION = email-studio
STAGING = staging
all: run
run:
node server.js
watch:
npx nodemon server.js
init:
npm install
clean:
rm -rf ${STAGING}
init-db:
cat schema.sql | sqlite3 ${DATABASE}
build:
docker build . -t ${DOCKER_TAG_NAME}
run-docker: build
docker-compose up
export: clean build
mkdir -p ${STAGING}
docker save ${DOCKER_TAG_NAME} -o ${STAGING}/${DOCKER_TAG_NAME}.tar
gzip ${STAGING}/${DOCKER_TAG_NAME}.tar
ls -lh ${STAGING}/${DOCKER_TAG_NAME}.tar.gz
deploy: upload
ssh -t ${REMOTE} 'cd ${REMOTE_DESTINATION}; sudo docker-compose stop; sudo docker load -i ${DOCKER_TAG_NAME}.tar; sudo docker-compose up -d;'
init-deploy:
ssh -t ${REMOTE} 'mkdir -p ${REMOTE_DESTINATION}'
scp docker-compose.yml ${REMOTE}:${REMOTE_DESTINATION}
-scp -r instance ${REMOTE}:${REMOTE_DESTINATION}
-scp .env ${REMOTE}:${REMOTE_DESTINATION}
upload: export
rsync -avz --progress ${STAGING}/${DOCKER_TAG_NAME}.tar.gz ${REMOTE}:${REMOTE_DESTINATION}/${DOCKER_TAG_NAME}.tar.gz
ssh -t ${REMOTE} 'gzip -df ${REMOTE_DESTINATION}/${DOCKER_TAG_NAME}.tar.gz'
upload-reg: build
docker push ${DOCKER_TAG_NAME}
deploy-reg: upload-reg
ssh -t ${REMOTE} 'cd ${REMOTE_DESTINATION}; sudo docker-compose stop; sudo docker pull ${DOCKER_TAG_NAME}; sudo docker-compose up -d;'
connect:
ssh ${REMOTE}