-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Clariteia/0.0.1
0.0.1
- Loading branch information
Showing
117 changed files
with
1,596 additions
and
224 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
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,6 @@ | ||
# Intellij IDEa / PyCharm / etc. | ||
.idea | ||
.run | ||
|
||
# Build | ||
.build |
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,8 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: build | ||
pass_filenames: false | ||
entry: make build | ||
name: Generate build | ||
language: system |
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,5 @@ | ||
.PHONY: build | ||
|
||
build: | ||
rm -rf .build | ||
sh build.sh |
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,98 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
ROOT_DIR=$(dirname "$0") | ||
BUILD_DIR=$(dirname "$0")/.build | ||
|
||
mkdir -p "$BUILD_DIR" | ||
|
||
echo "Building Microservice Init Template..." | ||
tar -czf "$BUILD_DIR/microservice-init.tar.gz" -C "$ROOT_DIR/microservice/init" . | ||
|
||
echo "Building Microservice Python Init Template..." | ||
tar -czf "$BUILD_DIR/microservice-python-init.tar.gz" -C "$ROOT_DIR/microservice/language/python/init" . | ||
|
||
echo "Building Microservice Python Package Manager Poetry Template..." | ||
tar -czf "$BUILD_DIR/microservice-python-package-manager-poetry.tar.gz" -C "$ROOT_DIR/microservice/language/python/package-manager/poetry" . | ||
|
||
echo "Building Microservice Python Package Manager Pip Template..." | ||
tar -czf "$BUILD_DIR/microservice-python-package-manager-pip.tar.gz" -C "$ROOT_DIR/microservice/language/python/package-manager/pip" . | ||
|
||
echo "Building Microservice Python Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/microservice-python-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/microservice/language/python/deploy/docker-compose" . | ||
|
||
echo "Building Microservice Python Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/microservice-python-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/microservice/language/python/deploy/kubernetes" . | ||
|
||
echo "Building Project Init Template..." | ||
tar -czf "$BUILD_DIR/project-init.tar.gz" -C "$ROOT_DIR/project/init" . | ||
|
||
echo "Building Project API Gateway Minos Init Template..." | ||
tar -czf "$BUILD_DIR/project-apigateway-minos-init.tar.gz" -C "$ROOT_DIR/project/apigateway/minos/init" . | ||
|
||
echo "Building Project API Gateway Minos Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-apigateway-minos-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/apigateway/minos/deploy/docker-compose" . | ||
|
||
echo "Building Project API Gateway Minos Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-apigateway-minos-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/apigateway/minos/deploy/kubernetes" . | ||
|
||
echo "Building Project API Gateway Minos Deploy Remote Template..." | ||
tar -czf "$BUILD_DIR/project-apigateway-minos-deploy-remote.tar.gz" -C "$ROOT_DIR/project/apigateway/minos/deploy/remote" . | ||
|
||
echo "Building Project Broker Kafka Init Template..." | ||
tar -czf "$BUILD_DIR/project-broker-kafka-init.tar.gz" -C "$ROOT_DIR/project/broker/kafka/init" . | ||
|
||
echo "Building Project Broker Kafka Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-broker-kafka-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/broker/kafka/deploy/docker-compose" . | ||
|
||
echo "Building Project Broker Kafka Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-broker-kafka-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/broker/kafka/deploy/kubernetes" . | ||
|
||
echo "Building Project Broker Kafka Deploy Remote Template..." | ||
tar -czf "$BUILD_DIR/project-broker-kafka-deploy-remote.tar.gz" -C "$ROOT_DIR/project/broker/kafka/deploy/remote" . | ||
|
||
echo "Building Project Database Postgres Init Template..." | ||
tar -czf "$BUILD_DIR/project-database-postgres-init.tar.gz" -C "$ROOT_DIR/project/database/postgres/init" . | ||
|
||
echo "Building Project Database Postgres Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-database-postgres-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/database/postgres/deploy/docker-compose" . | ||
|
||
echo "Building Project Database Postgres Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-database-postgres-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/database/postgres/deploy/kubernetes" . | ||
|
||
echo "Building Project Database Postgres Deploy Remote Template..." | ||
tar -czf "$BUILD_DIR/project-database-postgres-deploy-remote.tar.gz" -C "$ROOT_DIR/project/database/postgres/deploy/remote" . | ||
|
||
echo "Building Project Database Redis Init Template..." | ||
tar -czf "$BUILD_DIR/project-database-redis-init.tar.gz" -C "$ROOT_DIR/project/database/redis/init" . | ||
|
||
echo "Building Project Database Redis Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-database-redis-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/database/redis/deploy/docker-compose" . | ||
|
||
echo "Building Project Database Redis Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-database-redis-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/database/redis/deploy/kubernetes" . | ||
|
||
echo "Building Project Database Redis Deploy Remote Template..." | ||
tar -czf "$BUILD_DIR/project-database-redis-deploy-remote.tar.gz" -C "$ROOT_DIR/project/database/redis/deploy/remote" . | ||
|
||
echo "Building Project Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/deploy/docker-compose" . | ||
|
||
echo "Building Project Discovery Minos Init Template..." | ||
tar -czf "$BUILD_DIR/project-discovery-minos-init.tar.gz" -C "$ROOT_DIR/project/discovery/minos/init" . | ||
|
||
echo "Building Project Discovery Minos Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-discovery-minos-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/discovery/minos/deploy/docker-compose" . | ||
|
||
echo "Building Project Discovery Minos Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-discovery-minos-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/discovery/minos/deploy/kubernetes" . | ||
|
||
echo "Building Project Discovery Minos Deploy Remote Template..." | ||
tar -czf "$BUILD_DIR/project-discovery-minos-deploy-remote.tar.gz" -C "$ROOT_DIR/project/discovery/minos/deploy/remote" . | ||
|
||
echo "Building Project Deploy Docker Compose Template..." | ||
tar -czf "$BUILD_DIR/project-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/deploy/docker-compose" . | ||
|
||
echo "Building Project Deploy Kubernetes Template..." | ||
tar -czf "$BUILD_DIR/project-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/deploy/kubernetes" . |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
# {{ name }} Microservice | ||
|
||
## Description | ||
{{ description }} |
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,21 @@ | ||
name: | ||
type: str | ||
help: What is the name of the microservice? | ||
language: | ||
type: str | ||
link: true | ||
help: What programming language do you want to use? | ||
choices: | ||
python: &python_url "{{ template_registry }}/microservice-python-init.tar.gz" | ||
default: *python_url | ||
|
||
_envops: | ||
block_start_string: "{%" | ||
block_end_string: "%}" | ||
comment_start_string: "{#" | ||
comment_end_string: "#}" | ||
variable_start_string: "{{" | ||
variable_end_string: "}}" | ||
keep_trailing_newline: false | ||
|
||
_templates_suffix: .jinja |
2 changes: 1 addition & 1 deletion
2
microservice/{{ name }}/.dockerignore → ...ython/deploy/docker-compose/.dockerignore
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,3 +1,3 @@ | ||
.venv | ||
*.lmdb | ||
dist/ | ||
dist/ |
10 changes: 10 additions & 0 deletions
10
microservice/language/python/deploy/docker-compose/copier.yml
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,10 @@ | ||
_envops: | ||
block_start_string: "{%" | ||
block_end_string: "%}" | ||
comment_start_string: "{#" | ||
comment_end_string: "#}" | ||
variable_start_string: "{{" | ||
variable_end_string: "}}" | ||
keep_trailing_newline: false | ||
|
||
_templates_suffix: .jinja |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.venv | ||
*.lmdb | ||
dist/ |
22 changes: 22 additions & 0 deletions
22
microservice/language/python/deploy/kubernetes/Makefile.jinja
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,22 @@ | ||
.PHONY: deploy | ||
|
||
{% include (destination / "Makefile").as_posix() %} | ||
|
||
deploy: | ||
$(MAKE) deploy-image | ||
$(MAKE) deploy-config | ||
|
||
deploy-image: | ||
docker build --pull -t microservice-{{ name }} -f deploy/Dockerfile . | ||
docker tag microservice-{{ name }}:latest {{ kubernetes_registry }}/microservice-{{ name }}:{{ version }} | ||
docker push {{ kubernetes_registry }}/microservice-{{ name }}:{{ version }} | ||
|
||
deploy-config: | ||
kubectl apply -f deploy/deployment.yaml | ||
kubectl apply -f deploy/service.yaml | ||
|
||
restart: | ||
kubectl rollout restart --namespace={{ project_name }} deployment/microservice-{{ name }} > /dev/null | ||
|
||
logs: | ||
kubectl logs svc/microservice-{{ name }} --namespace={{ project_name }} --follow --tail 1000 |
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,31 @@ | ||
name: | ||
type: str | ||
help: What is the name of the microservice? | ||
version: | ||
type: str | ||
help: What is the version of the microservice? | ||
project_name: | ||
type: str | ||
help: What is the name of the project? | ||
kubernetes_config: | ||
type: str | ||
default: microservice-config | ||
help: What is the kubernetes config? | ||
kubernetes_registry: | ||
type: str | ||
default: "localhost:5000" | ||
help: What is the kubernetes registry? | ||
|
||
_envops: | ||
block_start_string: "{%" | ||
block_end_string: "%}" | ||
comment_start_string: "{#" | ||
comment_end_string: "#}" | ||
variable_start_string: "{{" | ||
variable_end_string: "}}" | ||
keep_trailing_newline: false | ||
|
||
_templates_suffix: .jinja | ||
|
||
_tasks: | ||
- make -s deploy |
17 changes: 17 additions & 0 deletions
17
microservice/language/python/deploy/kubernetes/deploy/Dockerfile
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,17 @@ | ||
FROM ghcr.io/clariteia/minos-microservice:0.1.8 as development | ||
|
||
COPY ./pyproject.toml ./poetry.lock ./ | ||
RUN poetry install --no-root | ||
COPY . . | ||
CMD ["poetry", "run", "microservice", "start"] | ||
|
||
FROM development as build | ||
RUN poetry export --without-hashes > req.txt && pip wheel -r req.txt --wheel-dir ./dist | ||
RUN poetry build --format wheel | ||
|
||
FROM python:3.9-slim as production | ||
COPY --from=build /microservice/dist/ ./dist | ||
RUN pip install --no-deps ./dist/* | ||
COPY config.yml ./config.yml | ||
ENTRYPOINT ["microservice"] | ||
CMD ["start"] |
24 changes: 24 additions & 0 deletions
24
microservice/language/python/deploy/kubernetes/deploy/deployment.yaml.jinja
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,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: microservice-{{ name }} | ||
namespace: {{ project_name }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: microservice-{{ name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: microservice-{{ name }} | ||
spec: | ||
containers: | ||
- name: microservice-{{ name }} | ||
image: {{ kubernetes_registry }}/microservice-{{ name }}:{{ version }} | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8080 | ||
envFrom: | ||
- configMapRef: | ||
name: {{ kubernetes_config }} |
Oops, something went wrong.