forked from kieran/vaxme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (54 loc) · 1.56 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
.ONESHELL:
SHELL = /bin/bash
NODE_ENV ?= development
PORT ?= 3000
include .env.${NODE_ENV}
.PHONY: nvm install clean run dist start_mongo stop_mongo seed_mongo docker_run
node_modules/:
@npm i
install: node_modules/
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
#
# Docker stuff
#
start_mongo:
mongod --fork --dbpath=/data/db --logpath=/tmp/mongodb.log --logappend
stop_mongo:
mongod --shutdown
seed_mongo:
mongo --host ${MONGO_URL} --eval "db.postal_codes.drop()"
mongo --host ${MONGO_URL} --eval 'db.postal_codes.createIndex({ geometry: "2dsphere" })'
@gunzip -c ./data/postal_codes.json.gz | \
jq --compact-output '[ .features[] | select(.type == "Feature") | { geometry, properties: { postal_code: .properties.CFSAUID, province_name: .properties.PRNAME } } ]' | \
mongoimport --db vaxme -c postal_codes --jsonArray
docker_build:
docker image build --platform x86_64 -t vaxmeca:1.0 .
docker_start:
docker run -it --publish 3000:${PORT} vaxmeca: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 --dbpath=/data/db --logpath=/tmp/mongodb.log --logappend
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/vaxmeca/api
gcloud_deploy:
gcloud run deploy --image gcr.io/vaxmeca/api --platform managed --memory=512Mi