4 Commits

Author SHA1 Message Date
a7d00529f6 Update Makefile
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 13s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:14:42 -04:00
4198ad488b Update papi-helm/values.yaml
Some checks failed
Build and Push to Private Registry101 / build (push) Failing after 13s
Build and Push to Private Registry101 / deploy (push) Has been skipped
2025-04-11 13:14:25 -04:00
4e84fc9501 Update papi-helm/values.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 13:08:50 -04:00
0417eacbeb Update Makefile
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:08:16 -04:00
9 changed files with 21 additions and 49 deletions

View File

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

View File

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

View File

@@ -3,8 +3,10 @@
FROM python:3.12
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt

View File

@@ -2,7 +2,7 @@ ENV=dev
VER=0.0.11
TAG=${ENV}-${VER}
TAG_ARM=${ENV}-arm-${VER}
REGISTRY=192.168.1.134:5000
REGISTRY=kube-reg.fairfaxmedia.net
#REGISTRY=direct.fairfaxmedia.net:1529
SVC=papi/svc1
@@ -17,8 +17,8 @@ clean:
rm -rf test.db
rm -rf htmlcov
install.log: requirements.txt
pip3 install -r requirements.txt > install.log
install:
pip3 install -r requirements.txt
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,8 +45,7 @@ integration:
arm-tok:
kubectl --context arm-k3s create token serviceaccounts-cluster-admin -duration=1000000000s
kubectl --context arm-k3s create token serviceaccounts-cluster-admin
echo login at https://k3a.fairfaxmedia.net
@@ -54,7 +53,7 @@ k8s-tok:
kubectl --context microk8s create token serviceaccounts-cluster-admin
echo login at https://kube.fairfaxmedia.net
run: install.log
run: install
uvicorn papi:app --reload --port 8912 --host 0.0.0.0

View File

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

3
db.py
View File

@@ -12,8 +12,7 @@ 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():

View File

@@ -1,18 +0,0 @@
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: git.fairfaxmedia.net/papi/svc1
repository: kube-reg.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: true
minReplicas: 0
maxReplicas: 5
enabled: false
minReplicas: 1
maxReplicas: 100
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"),index=True)
author_id = Column(Integer, ForeignKey("users.id"))
router = APIRouter(prefix="/posts")