Skip to content
Merged
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
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/copyright/MIT.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions .idea/dataSources.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/markdown.xml

This file was deleted.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions .idea/mrmat-python-api-fastapi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/pylint.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/runConfigurations/build.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/runConfigurations/lint.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/pytest_in_tests.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/runConfigurations/run.xml

This file was deleted.

7 changes: 7 additions & 0 deletions .idea/vagrant.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 22 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ CONTAINER_SOURCES := $(shell find var/container)
HELM_SOURCES := $(shell find var/helm)
HELM_TARGET := dist/mrmat-python-api-fastapi-$(VERSION).tgz

# Can be either 'sidecar' or 'ambient'
ISTIO := ambient
# My cluster names default to the hostname they run on
CLUSTER_NAME := $(shell hostname -s)
# Can be either 'istio-sidecar' or 'istio-ambient'
MESH := istio-ambient
# Can be 'ingress', 'gateway-api' or 'istio'
EDGE := gateway-api

# How the container then connects to its datastore
API_DB_URL="sqlite:////data/db.sqlite3"

# All of this can be overridden by the include in ~/etc/api-secrets.mk
-include ~/etc/secrets.mk

all: python container helm
python: $(PYTHON_TARGET)
Expand All @@ -27,32 +37,37 @@ $(PYTHON_TARGET): $(PYTHON_SOURCES)

$(HELM_TARGET): $(HELM_SOURCES) container
helm package \
--app-version "$(VERSION)" \
--version $(VERSION) \
--app-version "$(VERSION)" \
--destination dist/ \
var/helm
helm push dist/mrmat-python-api-fastapi-$(VERSION).tgz oci://localhost:5001/charts

container: $(PYTHON_TARGET) $(CONTAINER_SOURCES)
container: $(CONTAINER_SOURCES) $(PYTHON_TARGET)
docker build \
-f var/container/Dockerfile \
-t localhost:5001/mrmat-python-api-fastapi:$(VERSION) \
--build-arg GIT_SHA=$(GIT_SHA) \
--build-arg MRMAT_VERSION=$(VERSION) \
--build-arg WHEEL=$(PYTHON_TARGET) \
$(ROOT_PATH)
docker push localhost:5001/mrmat-python-api-fastapi:$(VERSION)

helm-install: $(HELM_TARGET)
kubectl create ns mpafastapi || true
if test "$(ISTIO)" == "sidecar"; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
if test "$(ISTIO)" == "ambient"; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
if test "$(MESH)" == "istio-sidecar"; then kubectl label --overwrite ns mpafastapi istio-injection=true; fi
if test "$(MESH)" == "istio-ambient"; then kubectl label --overwrite ns mpafastapi istio.io/dataplane-mode=ambient; fi
helm upgrade \
mrmat-python-api-fastapi \
${HELM_TARGET} \
--install \
--wait \
--force \
--namespace mpafastapi \
--set istio=$(ISTIO)
--set cluster.name=$(CLUSTER_NAME) \
--set cluster.mesh=$(MESH) \
--set edge.kind=$(EDGE) \
--set config.db_url=$(API_DB_URL)

helm-uninstall:
helm delete -n mpafastapi mrmat-python-api-fastapi
Expand Down
6 changes: 3 additions & 3 deletions var/client-k8s.http
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
### GET Owners
GET https://mpafastapi.covenant.local/api/platform/v1/owners
GET https://mpafastapi.covenant.k8s/api/platform/v1/owners

### GET resources
GET https://mpafastapi.covenant.local/api/platform/v1/resources
GET https://mpafastapi.covenant.k8s/api/platform/v1/resources

### Create Owner
POST https://mpafastapi.covenant.local/api/platform/v1/owners
POST https://mpafastapi.covenant.k8s/api/platform/v1/owners
Content-Type: application/json

{
Expand Down
17 changes: 14 additions & 3 deletions var/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM python:3.12-alpine AS build
FROM python:3.13-alpine AS build
ARG MRMAT_VERSION="0.0.0.dev0"
ARG GIT_SHA=""
ARG WHEEL=""
ADD "$WHEEL" /
RUN pip install --user /mrmat_python_api_fastapi-*.whl

FROM python:3.12-alpine
FROM python:3.13-alpine
ARG MRMAT_VERSION="0.0.0.dev0"
LABEL VERSION=$MRMAT_VERSION
ARG GIT_SHA=""

LABEL org.opencontainers.image.title="MrMat :: Python API :: FastAPI"
LABEL org.opencontainers.image.description="A demonstration of common API interactions using Python's FastAPI"
LABEL org.opencontainers.image.authors="MrMat"
LABEL org.opencontainers.image.vendor="The MrMat Organisation"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.version="$MRMAT_VERSION"
LABEL org.opencontainers.image.revision="$GIT_SHA"
LABEL org.opencontainers.image.source="https://github.com/MrMatAP/mrmat-python-api-fastapi"

RUN addgroup -g 1000 app && \
adduser -g 'App User' -u 1000 -G app -D app
COPY --from=build /root/.local /home/app/.local
Expand Down
12 changes: 12 additions & 0 deletions var/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
apiVersion: v2
name: mrmat-python-api-fastapi
description: A Helm chart for MrMat Python API FastAPI
home: https://github.com/MrMatAP/mrmat-python-api-fastapi
sources:
- https://github.com/MrMatAP/mrmat-python-api-fastapi
maintainers:
- name: MrMat
email: imfeldma@gmail.com
url: https://github.com/MrMatAP
annotations:
org.opencontainers.image.title: "MrMat :: Python API :: FastAPI"
org.opencontainers.image.authors: "MrMat"
org.opencontainers.image.vendor: "The MrMat Organisation"
org.opencontainers.image.licenses: "MIT"
type: application
version: "0.0.0"
appVersion: "0.0.0.dev0"
Loading
Loading