-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed linting warnings and added pylint
- Loading branch information
Showing
11 changed files
with
204 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
PORT=8080 | ||
FLASK_RUN_PORT=8080 | ||
FLASK_APP=service:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,74 @@ | ||
.PHONY: all help install venv test run | ||
# These can be overidden with env vars. | ||
REGISTRY ?= rofrano | ||
IMAGE_NAME ?= hitcounter | ||
IMAGE_TAG ?= 1.0 | ||
IMAGE ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) | ||
PLATFORM ?= "linux/amd64,linux/arm64" | ||
|
||
.PHONY: help | ||
help: ## Display this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-\\.]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
.PHONY: all | ||
all: help | ||
|
||
.PHONY: clean | ||
clean: ## Removes all dangling build cache | ||
$(info Removing all dangling build cache..) | ||
-docker rmi $(IMAGE) | ||
docker image prune -f | ||
docker buildx prune -f | ||
|
||
.PHONY: venv | ||
venv: ## Create a Python virtual environment | ||
$(info Creating Python 3 virtual environment...) | ||
python3 -m venv .venv | ||
|
||
.PHONY: install | ||
install: ## Install dependencies | ||
$(info Installing dependencies...) | ||
sudo pip install -r requirements.txt | ||
|
||
.PHONY: lint | ||
lint: ## Run the linter | ||
$(info Running linting...) | ||
flake8 service --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 service --count --max-complexity=10 --max-line-length=127 --statistics | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | ||
pylint service | ||
|
||
.PHONY: test | ||
test: ## Run the unit tests | ||
$(info Running tests...) | ||
nosetests --with-spec --spec-color | ||
|
||
.PHONY: run | ||
run: ## Run the service | ||
$(info Starting service...) | ||
honcho start | ||
|
||
depoy: ## Deploy the service on Kubernetes | ||
$(info Deploying service...) | ||
kubectl apply -f kube/redis.yaml | ||
kubectl apply -f kube/secrets.yaml | ||
kubectl apply -f kube/deployment.yaml | ||
kubectl apply -f kube/service.yaml | ||
.PHONY: deploy | ||
depoy: ## Deploy the service on local Kubernetes | ||
$(info Deploying service locally...) | ||
kubectl apply -k kube/overlay/local | ||
|
||
############################################################ | ||
# COMMANDS FOR BUILDING THE IMAGE | ||
############################################################ | ||
|
||
.PHONY: init | ||
init: export DOCKER_BUILDKIT=1 | ||
init: ## Creates the buildx instance | ||
$(info Initializing Builder...) | ||
docker buildx create --use --name=qemu | ||
docker buildx inspect --bootstrap | ||
|
||
.PHONY: build | ||
build: ## Build all of the project Docker images | ||
$(info Building $(IMAGE) for $(PLATFORM)...) | ||
docker buildx build --file Dockerfile --pull --platform=$(PLATFORM) --tag $(IMAGE) --push . | ||
|
||
.PHONY: remove | ||
remove: ## Stop and remove the buildx builder | ||
$(info Stopping and removing the builder image...) | ||
docker buildx stop | ||
docker buildx rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.