2019-08-08 04:46:51 +00:00
|
|
|
.PHONY: all build clean format test
|
2019-04-15 03:56:55 +00:00
|
|
|
|
2019-06-02 09:39:39 +00:00
|
|
|
docker: clean format install
|
2019-08-08 04:46:51 +00:00
|
|
|
docker build -t selfpass:latest .
|
2019-06-02 02:42:46 +00:00
|
|
|
|
2019-08-08 04:46:51 +00:00
|
|
|
build:
|
2019-07-11 06:05:59 +00:00
|
|
|
go build -mod=vendor -o ./bin/server ./cmd
|
2019-05-06 00:56:27 +00:00
|
|
|
|
2019-04-15 03:56:55 +00:00
|
|
|
clean:
|
2019-08-08 04:46:51 +00:00
|
|
|
rm -rf ./bin ./vendor
|
2019-04-15 03:56:55 +00:00
|
|
|
|
2019-08-10 04:17:27 +00:00
|
|
|
deploy:
|
|
|
|
docker stack deploy -c docker-stack.yml selfpass
|
2019-05-29 15:02:04 +00:00
|
|
|
|
2019-05-28 01:16:50 +00:00
|
|
|
up:
|
2019-08-10 04:17:27 +00:00
|
|
|
docker-compose up
|
2019-04-15 03:56:55 +00:00
|
|
|
|
2019-05-28 01:16:50 +00:00
|
|
|
upd:
|
2019-08-10 04:17:27 +00:00
|
|
|
docker-compose up -d
|
2019-05-28 01:16:50 +00:00
|
|
|
|
|
|
|
down:
|
|
|
|
docker-compose down
|
|
|
|
|
|
|
|
machine-create-google:
|
|
|
|
docker-machine create --driver google \
|
2019-05-29 15:02:04 +00:00
|
|
|
--google-address selfpass \
|
2019-05-28 01:16:50 +00:00
|
|
|
--google-project selfpass-241808 \
|
2019-06-02 02:42:46 +00:00
|
|
|
--google-machine-type g1-small \
|
2019-05-28 01:16:50 +00:00
|
|
|
--google-machine-image https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-9-stretch-v20190514 \
|
2019-05-29 15:02:04 +00:00
|
|
|
--google-username selfpass \
|
|
|
|
--google-zone us-west1-c \
|
2019-08-08 04:46:51 +00:00
|
|
|
${DOCKER_MACHINE_NAME}
|
2019-06-02 19:37:39 +00:00
|
|
|
$(MAKE) machine-install-stackdriver-agent
|
|
|
|
$(MAKE) machine-add-grpc-server-tag
|
2019-05-28 01:16:50 +00:00
|
|
|
|
|
|
|
machine-rm:
|
2019-08-08 04:46:51 +00:00
|
|
|
docker-machine rm ${DOCKER_MACHINE_NAME}
|
2019-05-28 01:16:50 +00:00
|
|
|
|
2019-06-02 02:42:46 +00:00
|
|
|
machine-ssh:
|
2019-08-08 04:46:51 +00:00
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME}
|
2019-06-02 02:42:46 +00:00
|
|
|
|
|
|
|
machine-put-data:
|
2019-08-08 04:46:51 +00:00
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME} "if [[ ! -e data ]]; then mkdir data && chmod 777 data; fi"
|
|
|
|
docker-machine scp ./data/bolt.db ${DOCKER_MACHINE_NAME}:data/bolt.db
|
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME} "chmod 666 data/bolt.db"
|
2019-06-02 02:42:46 +00:00
|
|
|
|
|
|
|
machine-get-data:
|
2019-08-08 04:46:51 +00:00
|
|
|
docker-machine scp ${DOCKER_MACHINE_NAME}:data/bolt.db ./data/
|
|
|
|
|
|
|
|
machine-put-certs:
|
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME} "if [[ ! -e certs ]]; then mkdir certs; fi && chmod -R 755 certs"
|
|
|
|
docker-machine scp ./certs/ca.pem ${DOCKER_MACHINE_NAME}:certs/ca.pem
|
|
|
|
docker-machine scp ./certs/server.pem ${DOCKER_MACHINE_NAME}:certs/server.pem
|
|
|
|
docker-machine scp ./certs/server-key.pem ${DOCKER_MACHINE_NAME}:certs/server-key.pem
|
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME} "chmod 444 certs/*"
|
2019-06-02 02:42:46 +00:00
|
|
|
|
|
|
|
machine-add-grpc-server-tag:
|
2019-08-08 04:46:51 +00:00
|
|
|
gcloud compute instances add-tags ${DOCKER_MACHINE_NAME} \
|
2019-06-02 02:42:46 +00:00
|
|
|
--zone us-west1-c \
|
|
|
|
--tags grpc-server
|
|
|
|
|
|
|
|
machine-install-stackdriver-agent:
|
2019-08-08 04:46:51 +00:00
|
|
|
docker-machine ssh ${DOCKER_MACHINE_NAME} "curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh && sudo bash install-monitoring-agent.sh"
|
2019-06-02 02:42:46 +00:00
|
|
|
|
2019-04-15 03:56:55 +00:00
|
|
|
format:
|
2019-05-22 15:22:40 +00:00
|
|
|
gofmt -w -s -l .
|
|
|
|
|
2019-06-01 20:32:11 +00:00
|
|
|
install:
|
|
|
|
go mod tidy
|
|
|
|
go mod vendor
|
|
|
|
|
2019-05-22 15:22:40 +00:00
|
|
|
install-spc:
|
|
|
|
go install ./cmd/spc
|
2019-04-15 03:56:55 +00:00
|
|
|
|
|
|
|
gen-protoc:
|
|
|
|
protoc --go_out=plugins=grpc:. \
|
2019-06-30 04:17:22 +00:00
|
|
|
--dart_out=grpc:. \
|
2019-04-15 03:56:55 +00:00
|
|
|
./credentials/protobuf/service.proto
|
|
|
|
|
2019-05-06 00:56:27 +00:00
|
|
|
gen-csr-json:
|
|
|
|
mkdir certs
|
|
|
|
cd certs && cfssl print-defaults csr > csr.json
|
|
|
|
|
|
|
|
gen-ca:
|
|
|
|
cd certs && cfssl genkey -initca csr.json | cfssljson -bare ca
|
|
|
|
|
|
|
|
gen-server-cert:
|
2019-07-13 19:51:05 +00:00
|
|
|
cd certs && cfssl gencert -ca ca.pem -ca-key ca-key.pem -profile www csr.json | cfssljson -bare server
|
2019-05-06 00:56:27 +00:00
|
|
|
|
|
|
|
gen-client-cert:
|
2019-07-13 19:51:05 +00:00
|
|
|
cd certs && cfssl gencert -ca ca.pem -ca-key ca-key.pem -profile client csr.json | cfssljson -bare client
|
2019-05-06 00:56:27 +00:00
|
|
|
|
2019-04-15 03:56:55 +00:00
|
|
|
test:
|
|
|
|
go test -cover ./...
|