Skip to content

Commit

Permalink
Merge pull request #23 from ww24/fix-makefile
Browse files Browse the repository at this point in the history
fix(makefile): update
  • Loading branch information
ww24 authored Jan 23, 2021
2 parents 18f2e28 + 06a6b19 commit 373eb88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ vendor/
!.dockerignore

config.yml
service_account.json
bin/
*.tfvars
39 changes: 3 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
PROJECT_ID ?=
REGION ?= asia-northeast1
IMAGE := asia.gcr.io/${PROJECT_ID}/calendar-notifier:latest
CONFIG := $(shell base64 < config.yml)

BIN := $(abspath ./bin)
GO ?= go
GO_ENV ?= GOBIN=$(BIN)
Expand All @@ -16,43 +11,15 @@ $(BIN)/wire:
.PHONY: build
build:
docker build -t calendar-notifier .
docker tag calendar-notifier ${IMAGE}

.PHONY: deploy
deploy: CLOUD_RUN_SERVICE_ACCOUNT_EMAIL ?=
deploy:
docker push ${IMAGE}
@gcloud run deploy calendar-notifier \
--image="${IMAGE}" \
--region=${REGION} \
--platform=managed \
--max-instances=1 \
--memory=128Mi \
--service-account=${CLOUD_RUN_SERVICE_ACCOUNT_EMAIL} \
--no-allow-unauthenticated \
--set-env-vars \
CONFIG=${CONFIG}

.PHONY: deploy-scheduler
deploy-scheduler: SCHEDULER_SERVICE_ACCOUNT_EMAIL ?=
deploy-scheduler:
@gcloud scheduler jobs update http calendar-notifier \
--http-method=post \
--schedule="*/10 * * * *" \
--uri="${SCHEDULED_ENDPOINT}/launch" \
--oidc-service-account-email="${SCHEDULER_SERVICE_ACCOUNT_EMAIL}" \
--time-zone="Asia/Tokyo"

.PHONY: run
run: CONFIG_BASE64 ?= $(shell base64 < config.yml)
run: SERVICE_ACCOUNT ?= $(shell base64 < service_account.json)
run:
@CONFIG=$(CONFIG) \
@CONFIG_BASE64=$(CONFIG_BASE64) \
docker-compose up -d
docker logs -f calendar-notifier

.PHONY: install-tools
install-tools:
cat tools.go | awk -F'"' '/_/ {print $$2}' | xargs -tI {} go install {}

.PHONY: generate
generate: $(BIN)/stringer $(BIN)/wire
PATH=$(BIN):${PATH} $(GO_ENV) $(GO) generate ./...

0 comments on commit 373eb88

Please sign in to comment.