@contiamo/dev
Version:
Dev environment for contiamo
157 lines (126 loc) • 5.46 kB
Plain Text
include .bingo/Variables.mk
STUNNEL_KEY_FILE = config/pg-stunnel/cert/tls.key
STUNNEL_CRT_FILE = config/pg-stunnel/cert/tls.crt
REDIR_IMAGE=eu.gcr.io/dev-and-test-env/pantheon:redir
TEST_TAG?=latest
# fallback just incase gitsemver doesn't exist
# note that `?=` means it will not run these commands
# if the value is already set
GIT_VERSION ?= $(shell bash scripts/git-semver.sh)
GIT_COMMIT ?= $(shell git rev-parse HEAD)
PROJECT_ROOT ?= $(shell git rev-parse --show-toplevel)
BINS=$(shell go env GOBIN)
# COMPOSE_FILES?=-f docker-compose.yml -f docker-compose-extra.yml -f docker-compose-dbg.yml
COMPOSE_FILES?=-f docker-compose.yml
.PHONY: help
help:
@echo "Contiamo local development environment."
@echo
@echo "Commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo
@echo 'To get started,'
@echo ' - run `make docker-auth` to configure Docker to pull images from Google Container Repository'
@echo ' - run `make build` to configure Docker to pull images from Google Container Repository'
${BINS}/localdev: $(shell find ./cli -name '*.go') cli/go.*
@echo "+ build $@"
# generate the version here, again, because we can be more sure that
# the build bins are now installed
cd cli && go install -tags 'osusergo netgo' -v -ldflags "\
-X github.com/contiamo/dev/cli/config.GitCommit=${GIT_COMMIT} \
-X github.com/contiamo/dev/cli/config.Version=${GIT_VERSION}" \
./localdev
install: ${BINS}/localdev
dist: $(GORELEASER) $(shell find ./cli -name '*.go') cli/go.*
$(GORELEASER) build --skip-validate --rm-dist
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Verifies `golint` passes
@echo "+ $@"
@cd cli && $(GOLANGCI_LINT) run -v --timeout=90s --max-same-issues=100
TIMEOUT=5
.PHONY: changelog
changelog: ## Print git hitstory based changelog
@git --no-pager log --no-merges --pretty=format:"%h : %s (by %an)" $(shell git describe --tags --abbrev=0)...HEAD
@echo ""
.PHONY: clean
clean: ## Stop the environment and remove volumes
docker-compose down -v -t ${TIMEOUT}
.PHONY: docker-auth
docker-auth:
gcloud auth login
gcloud auth configure-docker
.PHONY: pull
pull: ## Pull the latest Docker images
@docker-compose \
-f docker-compose.yml -f docker-compose-extra.yml \
pull \
datastore ui auth pantheon pgbouncer profiler hub graphql sync-ingester tenjin \
demo sync-agent-tableau
@echo "Successfully pulled images. Checking that git here is up to date..."
@git fetch
@if ! git merge-base --is-ancestor origin/master HEAD; \
then echo; echo " ⚠️ You are not up to date with remote master. Consider running git pull."; echo; false; \
else echo "Up to date."; fi
.PHONY: repro
repro: ## Compute the exact image digests that are used in the current setup.
@docker-compose config --resolve-image-digests \
| scripts/yaml2json.sh \
| jq -r '{version, services: (.services|map_values({image}))}' \
| scripts/json2yaml.sh
.PHONY: build
build:
cd pantheon-redir && docker build -t ${REDIR_IMAGE} .
.PHONY: get-pg-key
get-pg-key: ## Enable pg_wire by downloading a TLS private key from kubectl
kubectl get secret wildcard.dev.contiamo.io-tls -o json |jq -r '.data["tls.key"] | @base64d' > "${STUNNEL_KEY_FILE}"
kubectl get secret wildcard.dev.contiamo.io-tls -o json |jq -r '.data["tls.crt"] | @base64d' > "${STUNNEL_CRT_FILE}"
.PHONY: start
start: ## Run the local dev environment on http://localhost:9898
@docker-compose up -d -t ${TIMEOUT} metadb
# give metadb some time to potentially load a snapshot
@sleep 5
@docker-compose ${COMPOSE_FILES} up -d -t ${TIMEOUT} --remove-orphans
@$(MAKE) .startmsg
.PHONY: pantheon-start
pantheon-start: ## Run the local dev environment on http://localhost:9898, redirecting to local Pantheon
@env PANTHEON_IMAGE=${REDIR_IMAGE} make start
@echo
@echo "Ingress is proxying"
@echo " - http://localhost:9898/pantheon/api/v1/* to http://localhost:4300/api/v1/* ."
@echo " - http://localhost:9898/pantheon/jdbc/* to http://localhost:8765/* ."
.PHONY: stop
stop: ## Stop the running docker container
docker-compose ${COMPOSE_FILES} down --remove-orphans -t ${TIMEOUT}
.PHONY: test
test: ## run the Hub API end-to-end tests
docker run \
--net dev_default \
-e BASE_URL=http://nginx \
-e FOODMARTDB_HOST=postgresql-foodmart \
eu.gcr.io/dev-and-test-env/contiamo-e2e:${TEST_TAG} \
datahub-e2e
.PHONY: restart
restart:
@echo "restarting $(service)"
@docker-compose ${COMPOSE_FILES} stop $(service) && docker-compose ${COMPOSE_FILES} up -d $(service)
@$(MAKE) .startmsg
.startmsg:
@echo "" \
&& printf '%-10s %s\n' 'Tracing ui:' 'http://localhost:16686/search' \
&& printf '%-10s %s\n' 'Dev ui:' 'http://localhost:9898/contiamo/profile' \
&& printf '%-10s %s\n' 'SMTP ui:' 'http://localhost:8025' \
&& printf '%-10s %s\n' 'Spark ui:' 'http://localhost:4040' \
&& printf '%-10s %s\n' 'Email:' 'lemon@example.com' \
&& printf '%-10s %s\n' 'Password:' 'localdev' \
&& if test -f "${STUNNEL_KEY_FILE}"; \
then printf '%-10s %s\n' "stunnel:" "✅ configured for pg protocol at localhost:5435" ; \
else printf '%-10s %s\n' "stunnel:" "❌ not configured"; fi \
&& printf '%-10s %s\n' 'JMX:' 'port 5001, username pantheon, password localdev'
.PHONY:pr-preview
pr-preview:
@scripts/pr_preview.sh ${services}
@$(MAKE) .startmsg
.PHONY: load-snapshot
load-snapshot:
@scripts/restore.sh localdev.snapshot
@$(MAKE) .startmsg