-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
89 lines (65 loc) · 2.02 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.ONESHELL:
SHELL = /bin/bash
NODE_ENV ?= development
ELECTION ?= bc
PORT ?= 3000
include .env.${NODE_ENV}
.PHONY: nvm install election/ clean run dist update_polls start_mongo stop_mongo seed_mongo docker_run
node_modules/:
@npm i
election/:
@rm -f ./election && ln -s ./elections/${ELECTION} ./election
install: node_modules/ election/
clean:
@rm -rf ./node_modules
run: install
set -m
npm run serve &
npm run api
fg %1
api: install
@node server/index.js
dist: install
@npm run dist
update_polls: install
@npm run update_polls
#
# Docker stuff
#
start_mongo:
mongod --fork --logpath /mongodb.log
stop_mongo:
mongod --shutdown
seed_mongo:
mongo --host ${MONGO_URL} --eval "db.ridings.drop()"
# @cat ./elections/uk/ridings.geojson | \
# jq --compact-output '[ .features[] | select(.type == "Feature") | { geometry, properties: { name: .properties.pcon15nm } } ]' | \
# mongoimport --db votewell -c ridings --jsonArray
# @cat ./elections/ca/ridings.geojson | \
# jq --compact-output '[ .features[] | select(.type == "Feature") | { geometry, properties: { name: .properties.ENNAME } } ]' | \
# mongoimport --db votewell -c ridings --jsonArray
@cat ./elections/bc/ridings.geojson | \
jq --compact-output '[ .features[] | select(.type == "Feature") | { geometry, properties: { name: .properties.ED_NAME } } ]' | \
mongoimport --db votewell -c ridings --jsonArray
mongo --host ${MONGO_URL} --eval 'db.ridings.createIndex({ geometry: "2dsphere" })'
docker_build:
docker image build -t votewell:1.0 .
docker_start:
docker run -it --publish 3000:${PORT} votewell:1.0
# starts mongo as a background process, returning express to the foreground
# needs .ONESHELL directive & bash
docker_run:
set -m
node server/index.js &
mongod --fork --logpath /mongodb.log
fg %1
#
# GCP Deploy (Google Cloud Run)
#
# build & deploy to google cloud run
# - https://api-xbhormaofa-ue.a.run.app
#
gcloud_build:
gcloud builds submit --tag gcr.io/votewell/api
gcloud_deploy:
gcloud run deploy --image gcr.io/votewell/api --platform managed