Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Add Pants #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Python
__pycache__

# Skaffold
tags.json
# Pants workspace files
/.pants.d/
/dist/
/.pids
/.pants.workdir.file_lock*
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python_requirements()
27 changes: 0 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
SHELL=bash

MICROSERVICES = users


Expand All @@ -8,32 +7,6 @@ help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'


define lint
isort ${1}/app --check && \
flake8 ${1}/app ${1}/tests && \
black ${1}/app ${1}tests --check
endef


.PHONY: lint
lint: ## Linter code
@echo "🚨 Linting code..."
@for i in $(MICROSERVICES); do $(call lint,$$i); done


define format
isort ${1}/app && \
autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place ${1}/app ${1}/tests --exclude=__init__.py && \
black ${1}/app ${1}tests
endef


.PHONY: format
format: ## Format code
@echo "🎨 Formatting code..."
@for i in $(MICROSERVICES); do $(call format,$$i); done


.PHONY: tests
tests: ## Run tests
@echo "🍜 Running tests..."
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The full stack of this project is composed by:
* [ARQ](https://arq-docs.helpmanual.io/) - Job queues and RPC in python with asyncio and redis.
* [PostgreSQL](https://www.postgresql.org/) - The World's Most Advanced Open Source Relational Database
* [Redis](https://redis.io/) - An open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker.
* [Minikube](https://minikube.sigs.k8s.io/) - A Kubernetes cluster manager for local development.
* [Tilt](https://tilt.dev/) - A multi-service dev environment for teams on Kubernetes.

## Installation
Expand Down
6 changes: 3 additions & 3 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services = ['users', 'users-worker', 'redis', 'postgres', 'ingress']
services = ['users', 'worker', 'redis', 'postgres', 'ingress']
yaml_files = ["k8s/%s.yaml" % service for service in services]

k8s_yaml(yaml_files)
docker_build('users', 'users', dockerfile='users/docker/backend.dockerfile')
docker_build('users-worker', 'users', dockerfile='users/docker/worker.dockerfile')
docker_build('kludex/users', '.', dockerfile='services/users/Dockerfile')
docker_build('kludex/worker', '.', dockerfile='services/worker/Dockerfile')
k8s_resource(workload="users-deployment", port_forwards="8000:80")
4 changes: 2 additions & 2 deletions k8s/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
- name: POSTGRES_HOST
value: "postgres-service"
- name: perform-migrations
image: users
image: kludex/users
command: ["alembic", "upgrade", "head"]
env:
- name: POSTGRES_HOST
Expand All @@ -76,7 +76,7 @@ spec:
name: postgres-configuration
containers:
- name: users
image: users
image: kludex/users
ports:
- containerPort: 80
livenessProbe:
Expand Down
16 changes: 8 additions & 8 deletions k8s/users-worker.yaml → k8s/worker.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: users-worker-service
name: worker-service
labels:
app: users-worker
app: worker
spec:
type: NodePort
ports:
Expand All @@ -15,22 +15,22 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: users-worker-deployment
name: worker-deployment
labels:
app: users-worker
app: worker
spec:
replicas: 1
selector:
matchLabels:
app: users-worker
app: worker
template:
metadata:
labels:
app: users-worker
app: worker
spec:
containers:
- name: users-worker
image: users-worker
- name: worker
image: kludex/worker
ports:
- containerPort: 8000
env:
Expand Down
Loading