22 Commits

Author SHA1 Message Date
1dd6dc669b Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 1m5s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-12-26 14:16:43 -05:00
bdeb26ed78 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-12-26 14:15:26 -05:00
518d4011c5 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-12-26 14:09:25 -05:00
32dd1d5a78 debug info in workflow
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-12-26 14:07:39 -05:00
3901479e8f blank change
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
blank change
2025-12-26 14:04:29 -05:00
3b57f8a214 Update Makefile
Some checks failed
Build and Push to Private Registry101 / deploy (push) Has been cancelled
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-04-11 13:24:43 -04:00
04f4c41334 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-04-11 13:22:15 -04:00
98da0b0e9a Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / deploy (push) Blocked by required conditions
Build and Push to Private Registry101 / build (push) Has been cancelled
2025-04-11 13:18:57 -04:00
4bd5432039 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 1m7s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:15:45 -04:00
223b266a21 Update papi-helm/values.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 16s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:06:30 -04:00
f499f94ff2 Update Makefile
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 15s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:06:09 -04:00
9edb7f27e0 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 17s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:05:08 -04:00
49eab09f91 Update README.md
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 16s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:03:58 -04:00
6f943af5c5 Update README.md
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 18s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:01:43 -04:00
fc5252a812 Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 14s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 12:59:50 -04:00
f12bc16208 Update README.md
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 1m6s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 12:57:21 -04:00
stephen schuresko
b64f93db81 feat: adjust ingress class and update autoscaling replica limits in values.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 1m5s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-03-14 08:33:49 -04:00
stephen schuresko
df92ab4896 feat: update token duration for service account in Makefile 2025-03-14 08:33:35 -04:00
stephen schuresko
cb150c9abe feat: secure kubeconfig permissions in deployment step of build-and-push workflow
Some checks failed
Build and Push to Private Registry101 / build (push) Successful in 9s
Build and Push to Private Registry101 / deploy (push) Failing after 4s
2025-03-07 14:22:32 -05:00
stephen schuresko
6a8cee2f6e feat: update Docker login step in build-and-push workflow for improved security
Some checks failed
Build and Push to Private Registry101 / build (push) Successful in 9s
Build and Push to Private Registry101 / deploy (push) Failing after 4s
2025-03-07 14:14:44 -05:00
stephen schuresko
e59924b1fe feat: enhance deployment and installation process in build-and-push workflow
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 6s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-03-07 14:13:09 -05:00
1a64c9335b Update README.md
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 1m0s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-03-07 14:04:52 -05:00
8 changed files with 48 additions and 17 deletions

View File

@@ -20,11 +20,13 @@ jobs:
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- uses: actions/checkout@v3
- run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry
- run: echo docker login ${{ vars.DOCK_REG}} -u ${{ vars.DOCK_REG_USER }}
name: login preview
- run: docker login ${{ vars.DOCK_REG}} -u ${{ vars.DOCK_REG_USER }} -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry
name: Login to private registry
- run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image
- run: docker build -t ${{ vars.DOCK_REG}}/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image
name: Build Docker image
- run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image
- run: docker push ${{ vars.DOCK_REG}}/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image
name: Push Docker image
deploy:
runs-on: ubuntu-latest-full
@@ -38,7 +40,8 @@ jobs:
- env:
KUBEB64: '${{ secrets.KUBEB64 }}'
name: deploy
run: mkdir -p $HOME/.kube &&echo "$KUBEB64" | base64 -d > $HOME/.kube/config &&
/usr/local/bin/helm upgrade --install papi-prod papi-helm/ -f ./papi-helm/v.prod.yaml --set image.tag=${{ steps.extract_branch.outputs.branch }} --set name=papi-prod # Deploy the Helm chart
run: mkdir -p $HOME/.kube &&echo "$KUBEB64" | base64 -d > $HOME/.kube/config && chmod 700 $HOME/.kube/config &&
/usr/local/bin/helm upgrade --install papi-${{ steps.extract_branch.outputs.branch }} papi-helm/ --set image.repository=${{ vars.DOCK_REG }}/papi/svc1:${{ steps.extract_branch.outputs.branch }} -f ./papi-helm/v.prod.yaml --set image.tag=${{ steps.extract_branch.outputs.branch }} --set name=papi-prod # Deploy the Helm chart

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"llama-vscode.endpoint": "http://192.168.1.142:11434"
}

View File

@@ -2,7 +2,7 @@ ENV=dev
VER=0.0.11
TAG=${ENV}-${VER}
TAG_ARM=${ENV}-arm-${VER}
REGISTRY=kube-reg.fairfaxmedia.net
REGISTRY=192.168.1.134:5000
#REGISTRY=direct.fairfaxmedia.net:1529
SVC=papi/svc1
@@ -17,8 +17,8 @@ clean:
rm -rf test.db
rm -rf htmlcov
install:
pip3 install -r requirements.txt
install.log: requirements.txt
pip3 install -r requirements.txt > install.log
report.xml: *.py
pytest --cov=papi --cov=posts --cov=users test_papi.py test_posts.py test_users.py --junitxml=report.xml --cov-report=html --cov-report=xml --cov-report=term --cov-fail-under 90
@@ -45,7 +45,8 @@ integration:
arm-tok:
kubectl --context arm-k3s create token serviceaccounts-cluster-admin
kubectl --context arm-k3s create token serviceaccounts-cluster-admin -duration=1000000000s
echo login at https://k3a.fairfaxmedia.net
@@ -53,7 +54,7 @@ k8s-tok:
kubectl --context microk8s create token serviceaccounts-cluster-admin
echo login at https://kube.fairfaxmedia.net
run: install
run: install.log
uvicorn papi:app --reload --port 8912 --host 0.0.0.0

View File

@@ -2,6 +2,7 @@
This is the Posts API project, a simple API for managing blog posts.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
@@ -9,6 +10,7 @@ This is the Posts API project, a simple API for managing blog posts.
- [Contributing](#contributing)
- [License](#license)
## Installation
1. Clone the repository:
@@ -23,6 +25,8 @@ This is the Posts API project, a simple API for managing blog posts.
```bash
pip install -r requirements.txt
```
## Usage
@@ -108,6 +112,7 @@ make deploy
```
### postman-like hopscotch collection:
hopscotch_collection.json can be imported into the following tool

3
db.py
View File

@@ -12,7 +12,8 @@ engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
version = os.environ.get("VERSION", "0.0.0")
def create_db():
Base.metadata.create_all(bind=engine)
def get_db():

18
install.log Normal file
View File

@@ -0,0 +1,18 @@
Requirement already satisfied: fastapi in /home/steve/py312/lib/python3.12/site-packages (from -r requirements.txt (line 1)) (0.115.8)
Requirement already satisfied: sqlalchemy in /home/steve/py312/lib/python3.12/site-packages (from -r requirements.txt (line 2)) (2.0.29)
Requirement already satisfied: uvicorn in /home/steve/py312/lib/python3.12/site-packages (from -r requirements.txt (line 3)) (0.30.6)
Requirement already satisfied: pyresttest in /home/steve/py312/lib/python3.12/site-packages (from -r requirements.txt (line 4)) (1.7.1)
Requirement already satisfied: starlette<0.46.0,>=0.40.0 in /home/steve/py312/lib/python3.12/site-packages (from fastapi->-r requirements.txt (line 1)) (0.45.3)
Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4 in /home/steve/py312/lib/python3.12/site-packages (from fastapi->-r requirements.txt (line 1)) (2.10.6)
Requirement already satisfied: typing-extensions>=4.8.0 in /home/steve/py312/lib/python3.12/site-packages (from fastapi->-r requirements.txt (line 1)) (4.12.2)
Requirement already satisfied: greenlet!=0.4.17 in /home/steve/py312/lib/python3.12/site-packages (from sqlalchemy->-r requirements.txt (line 2)) (3.0.3)
Requirement already satisfied: click>=7.0 in /home/steve/py312/lib/python3.12/site-packages (from uvicorn->-r requirements.txt (line 3)) (8.1.7)
Requirement already satisfied: h11>=0.8 in /home/steve/py312/lib/python3.12/site-packages (from uvicorn->-r requirements.txt (line 3)) (0.14.0)
Requirement already satisfied: pyyaml in /home/steve/py312/lib/python3.12/site-packages (from pyresttest->-r requirements.txt (line 4)) (6.0.1)
Requirement already satisfied: pycurl in /home/steve/py312/lib/python3.12/site-packages (from pyresttest->-r requirements.txt (line 4)) (7.45.3)
Requirement already satisfied: future in /home/steve/py312/lib/python3.12/site-packages (from pyresttest->-r requirements.txt (line 4)) (1.0.0)
Requirement already satisfied: annotated-types>=0.6.0 in /home/steve/py312/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4->fastapi->-r requirements.txt (line 1)) (0.7.0)
Requirement already satisfied: pydantic-core==2.27.2 in /home/steve/py312/lib/python3.12/site-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4->fastapi->-r requirements.txt (line 1)) (2.27.2)
Requirement already satisfied: anyio<5,>=3.6.2 in /home/steve/py312/lib/python3.12/site-packages (from starlette<0.46.0,>=0.40.0->fastapi->-r requirements.txt (line 1)) (4.6.2.post1)
Requirement already satisfied: idna>=2.8 in /home/steve/py312/lib/python3.12/site-packages (from anyio<5,>=3.6.2->starlette<0.46.0,>=0.40.0->fastapi->-r requirements.txt (line 1)) (3.6)
Requirement already satisfied: sniffio>=1.1 in /home/steve/py312/lib/python3.12/site-packages (from anyio<5,>=3.6.2->starlette<0.46.0,>=0.40.0->fastapi->-r requirements.txt (line 1)) (1.3.1)

View File

@@ -7,7 +7,7 @@ replicaCount: 1
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
image:
repository: kube-reg.fairfaxmedia.net/papi/svc1
repository: git.fairfaxmedia.net/papi/svc1
# This sets the pull policy for images.
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
@@ -61,7 +61,7 @@ ingress:
enabled: true
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
tls: []
# - secretName: chart-example-tls
@@ -92,9 +92,9 @@ readinessProbe:
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
enabled: true
minReplicas: 0
maxReplicas: 5
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

View File

@@ -9,7 +9,7 @@ class Post(db.Base):
id = Column(Integer, primary_key=True, index=True)
title = Column(String)
content = Column(String)
author_id = Column(Integer, ForeignKey("users.id"))
author_id = Column(Integer, ForeignKey("users.id"),index=True)
router = APIRouter(prefix="/posts")