Skip to content
Open
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
1d4ed68
CH-151 Refactor merge configuration directories to improve readability
condar-metacell Sep 30, 2024
10114cd
CH-151 Add postgres db as another base template of the django app
condar-metacell Sep 30, 2024
4925ec5
CH-151 Update django app dockerfile to use yarn instead of npm
condar-metacell Sep 30, 2024
47a7eb1
CH-151 Add initial install of yarn dependencies to harness-application
condar-metacell Oct 3, 2024
230adba
CH-151 Refactor harness-generate
condar-metacell Oct 3, 2024
7044fc0
CH-151 Refactor harness-generate
condar-metacell Oct 3, 2024
618d064
CH-151 Refactor merge_configuration_directories to use pathlib
condar-metacell Oct 3, 2024
55fd63d
CH-151 Refactor harness-generate to use pathlib glob
condar-metacell Oct 3, 2024
9a1148a
CH-151 Refactor harness-application to only use pathlib over os.path
condar-metacell Oct 4, 2024
a334992
CH-151 Refactor replace_in_file to work with pathlib
condar-metacell Oct 4, 2024
94f12de
CH-151 Add missing method calls for checking path existance
condar-metacell Oct 4, 2024
87d2cb7
CH-151 Refactor openapi functions to use pathlib and directly call fa…
condar-metacell Oct 4, 2024
15618cb
CH-151 Replace --server option with --app_name option in harness-gene…
condar-metacell Oct 4, 2024
7e194ac
CH-151 Refactor to add in a specific generate_models method for other…
condar-metacell Oct 4, 2024
e379273
CH-151 Update the harness-generate command line arguments to allow fo…
condar-metacell Oct 4, 2024
e4ef0ae
CH-151 Add flags to control which client types are generated by harne…
condar-metacell Oct 7, 2024
da8556c
CH-151 Remove dependency on os.path in harness-generate
condar-metacell Oct 7, 2024
6bc98a5
CH-151 Refactor harness-generate options to use flag enum for generat…
condar-metacell Oct 7, 2024
98eec41
CH-151 Create .ch-manifest file when creating a harness application
condar-metacell Oct 7, 2024
8d56b89
CH-151 Add cloud harness manifest support to harness-generate
condar-metacell Oct 7, 2024
f689061
CH-151 Update genapi.sh to call harness-generate
condar-metacell Oct 8, 2024
38bbc1b
CH-151 Move dependency installation and client generation to after te…
condar-metacell Oct 8, 2024
90f8454
CH-151 Call harness-generate after application harnessing
condar-metacell Oct 8, 2024
f5725a5
CH-151 Refactor to clean up some loose ends
condar-metacell Oct 8, 2024
8da4f16
CH-151 Update documentation
condar-metacell Oct 8, 2024
1756efc
CH-151 Fix linting issues
condar-metacell Oct 8, 2024
c6227cf
Merge branch 'feature/ch-151' of github.com:MetaCell/cloud-harness in…
filippomc Oct 9, 2024
3ca70a3
CH-151 Fix bugs in normalize templates function
condar-metacell Oct 9, 2024
20ac160
Merge branch 'feature/ch-151' of github.com:MetaCell/cloud-harness in…
filippomc Oct 9, 2024
689e23b
Merge pull request #778 from MetaCell/feature/ch-151
filippomc Oct 10, 2024
c362ece
Merge branch 'develop' of github.com:MetaCell/cloud-harness into develop
filippomc Oct 11, 2024
8dbce23
Fix backwards compatibility with Python 3.9
filippomc Oct 11, 2024
2c11b31
Reduce linting checks
filippomc Oct 15, 2024
d671a28
CH-157 Move harness-application builder steps to a more structured pi…
condar-metacell Oct 31, 2024
ad10cd8
CH-157 Rename template from django-app to django-fastapi
condar-metacell Nov 1, 2024
85b863a
CH-157 Add app builder for django-ninja applications using a shared b…
condar-metacell Nov 1, 2024
5b79044
CH-157 Add specific debug templates for the two different djano templ…
condar-metacell Nov 1, 2024
025d5c8
CH-157 Fix errors in django-ninja template
condar-metacell Nov 1, 2024
4648823
CH-157 Add utility method to run djano-ninja openapi export
condar-metacell Nov 1, 2024
9febcd6
CH-157 Fix bug with django ninja not considered a django template
condar-metacell Nov 1, 2024
33d9803
CH-157 Fix bug with incorrectly named field in derived app builders
condar-metacell Nov 1, 2024
dca0eae
CH-157 Update harness-generate to leverage django-ninja schema genera…
condar-metacell Nov 1, 2024
4b768ef
CH-157 Move manifest management code into its own file
condar-metacell Nov 1, 2024
11590ba
CH-157 Fix linting issues
condar-metacell Nov 4, 2024
6c85656
CH-158 option to edit user on django
filippomc Nov 5, 2024
b27916f
CH-162 fix random values generation
filippomc Nov 6, 2024
d938c97
CH-162 support for dynamic random secrets
filippomc Nov 6, 2024
fa4c3fe
Django: Improve db coherence on user sync issues
filippomc Nov 6, 2024
9be9c96
Django: Fix: Improve db coherence on user sync issues
filippomc Nov 6, 2024
b4e4102
CH-162 fix for non string secrets
filippomc Nov 6, 2024
49bc099
CH-162 fix for non string secrets +1
filippomc Nov 8, 2024
82b44da
CH-157 Fix typo in django template readme files
condar-metacell Nov 12, 2024
de3f097
CH-163 Gatekeeper version update
filippomc Nov 12, 2024
c463081
Merge pull request #783 from MetaCell/feature/CH-163
filippomc Nov 12, 2024
a0302fc
Fix secrets update
filippomc Nov 18, 2024
ecca698
CH-162 fix for secrets controls
filippomc Nov 22, 2024
f8cf3ba
CH-162 fix empty secrets gen
filippomc Nov 22, 2024
3461199
CH-162 fix empty secrets gen
filippomc Nov 22, 2024
663a7e8
CH-162 fix empty secrets gen
filippomc Nov 22, 2024
7ce854d
attempt fix codefresh deployment issues
filippomc Nov 22, 2024
4466edd
CH-162 add failsafe value
filippomc Nov 22, 2024
8ea73a8
CH-162 add failsafe value fix
filippomc Nov 22, 2024
c4989d4
CH-162 fix comments
filippomc Nov 22, 2024
1447db6
CH-162 another helm fix attempt
filippomc Nov 22, 2024
cd42d55
CH-163 fix template
filippomc Nov 22, 2024
81f5dfb
CH-157 Fixed typo in asgi and wsgi
condar-metacell Dec 9, 2024
a441b95
CH-157 Fixed issue with incorrect django settings module for asgi
condar-metacell Dec 9, 2024
23a6fed
CH-157 Change name of frontend build stage to be more generic
condar-metacell Dec 9, 2024
4dd9656
Merge pull request #787 from MetaCell/fix/CH-166
filippomc Dec 12, 2024
46188bb
Merge branch 'fix/CH-166' of github.com:MetaCell/cloud-harness into d…
filippomc Dec 19, 2024
2a4bd6e
CH-166 fix syntax issue
filippomc Jan 7, 2025
55f6362
Merge branch 'fix/CH-166' into develop
filippomc Jan 8, 2025
6e1dee3
CH-170 fix secrets upgrade
filippomc Jan 14, 2025
04aa612
CH-170 fix secrets upgrade -- bad push
filippomc Jan 14, 2025
b101e44
CH-170 fix secrets upgrade -- bad push
filippomc Jan 15, 2025
53d68ee
CH-170 fix secrets upgrade possible reset
filippomc Jan 15, 2025
77852b7
CH-170 fix for empty secrets reset
filippomc Jan 16, 2025
80c7236
Fix e2e tests run
filippomc Jan 16, 2025
b8ca1e3
CH-170 fix secrets upgrade error
filippomc Jan 16, 2025
afd7c80
Merge branch 'feature/ch-157' of github.com:MetaCell/cloud-harness in…
filippomc Jan 20, 2025
5432c84
CH-157 refactor, small fixes
filippomc Jan 21, 2025
8176368
Update version numbers
filippomc Jan 21, 2025
6a6b5f3
Add app manifests, update versions
filippomc Jan 21, 2025
c5a64e9
Add app manifests, update versions
filippomc Jan 21, 2025
2af2217
CH-157 refactor, docs, enhancements
filippomc Jan 21, 2025
0801787
Fix puppeteer not working in codefresh
filippomc Jan 21, 2025
5bd4b73
#792 Small code style tweaks
filippomc Jan 24, 2025
08b3716
CH-169 implement application build exclusion based on image param
filippomc Jan 24, 2025
4cae093
CH-169 tests and fixes
filippomc Jan 31, 2025
8e4f088
CH-134 remove nfs build
filippomc Jan 31, 2025
116ba73
Test pipeline tweak
filippomc Jan 31, 2025
67fdf62
Test pipeline tweak
filippomc Jan 31, 2025
60cded6
#792 fix template description
filippomc Feb 12, 2025
33c6e2b
bumping versions up
ddelpiano Mar 12, 2025
b073811
small refactoring for harness-generate
ddelpiano Mar 13, 2025
2d03fd8
documentation review and changes
ddelpiano Mar 13, 2025
6eeaf32
documentation edits
ddelpiano Mar 13, 2025
21b19bd
Merge pull request #795 from MetaCell/feature/CH-174
filippomc Mar 13, 2025
423145a
CH-169 try fix keycloak starting issue
filippomc Mar 14, 2025
169de78
CH-169 try fix keycloak starting issue
filippomc Mar 14, 2025
29d9cef
CH-169 try fix keycloak starting issue
filippomc Mar 14, 2025
ec5b8c1
CH-169 try fix keycloak starting issue
filippomc Mar 14, 2025
14af0b6
CH-169 try fix keycloak starting issue
filippomc Mar 15, 2025
c882f43
Merge pull request #794 from MetaCell/feature/CH-169
filippomc Mar 17, 2025
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
4 changes: 3 additions & 1 deletion .github/workflows/lint-check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Lint Check

on:
push
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]

jobs:
lint:
Expand Down
6 changes: 0 additions & 6 deletions application-templates/django-app/api/genapi.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "__APP_NAME__.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_baseapp.settings")

application = get_asgi_application()

Expand All @@ -21,6 +21,6 @@
init_services()

# start the kafka event listener
from cloudharness_django.services.events import init_listner # noqa E402
from cloudharness_django.services.events import init_listener # noqa E402

init_listner()
init_listener()
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
init_services()

# start the kafka event listener
from cloudharness_django.services.events import init_listner # noqa E402
from cloudharness_django.services.events import init_listener # noqa E402

init_listner()
init_listener()
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ ENV APP_DIR=/app

WORKDIR ${APP_DIR}
COPY frontend/package.json ${APP_DIR}
COPY frontend/package-lock.json ${APP_DIR}
RUN npm ci
COPY frontend/yarn.lock ${APP_DIR}
RUN yarn install --frozen-lockfile --timeout 60000

COPY frontend ${APP_DIR}
RUN npm run build
RUN yarn build

#####

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ See [backend/README.md#Develop]

### Frontend

Backend code is inside the *frontend* directory.
Frontend code is inside the *frontend* directory.

Frontend is by default generated as a React web application, but no constraint about this specific technology.

Expand Down
4 changes: 4 additions & 0 deletions application-templates/django-fastapi/api/genapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

ROOT_PATH=$(realpath "$(dirname "$BASH_SOURCE")/../../..")
harness-generate servers --app-name "__APP_NAME__" "$ROOT_PATH"
35 changes: 35 additions & 0 deletions application-templates/django-ninja/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG CLOUDHARNESS_FRONTEND_BUILD
ARG CLOUDHARNESS_DJANGO

FROM $CLOUDHARNESS_FRONTEND_BUILD AS frontend

ARG APP_DIR=/app

WORKDIR ${APP_DIR}
COPY frontend/package.json .
COPY frontend/yarn.lock .
RUN yarn install --timeout 60000

COPY frontend .
RUN yarn build

#####

FROM $CLOUDHARNESS_DJANGO

WORKDIR ${APP_DIR}
RUN mkdir -p ${APP_DIR}/static/www

COPY backend/requirements.txt ${APP_DIR}
RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip &&\
pip3 install --no-cache-dir -r requirements.txt --prefer-binary

COPY backend/requirements.txt backend/setup.py ${APP_DIR}
RUN python3 -m pip install -e .

COPY backend ${APP_DIR}
RUN python3 manage.py collectstatic --noinput

COPY --from=frontend /app/dist ${APP_DIR}/static/www

ENTRYPOINT uvicorn --workers ${WORKERS} --host 0.0.0.0 --port ${PORT} django_baseapp.asgi:application
114 changes: 114 additions & 0 deletions application-templates/django-ninja/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# __APP_NAME__

Django-Ninja/React-based web application.
This application is constructed to be deployed inside a cloud-harness Kubernetes.
It can be also run locally for development and test purpose.

The code is generated with the script `harness-application`.

## Configuration

### Accounts

The CloudHarness Django application template comes with a configuration that can retrieve user account updates from Keycloak (accounts)
To enable this feature:
* log in into the accounts admin interface
* select in the left sidebar Events
* select the `Config` tab
* enable "metacell-admin-event-listener" under the `Events Config` - `Event Listeners`

An other option is to enable the "metacell-admin-event-listener" through customizing the Keycloak realm.json from the CloudHarness repository.

## Develop

This application is composed of a Django-Ninja backend and a React frontend.

### Backend

Backend code is inside the *backend* directory.
See [backend/README.md#Develop]

### Frontend

Frontend code is inside the *frontend* directory.

Frontend is by default generated as a React web application, but no constraint about this specific technology.

See also [frontend/README.md]

#### Generate API client stubs
All the api stubs are automatically generated in the [frontend/rest](frontend/rest) directory by `harness-application`
and `harness-generate`.

To update frontend client stubs, run

```
harness-generate clients __APP_NAME__ -t
```

Stubs can also be updated using the `genapi.sh` from the api folder.

## Local build & run

### Install Python dependencies
1 - Clone cloud-harness into your project root folder

2 - Run the dev setup script
```
cd applications/__APP_NAME__
source dev-setup.sh
```

### Prepare backend

Create a Django local superuser account, this you only need to do on initial setup
```bash
cd backend
python3 manage.py migrate # to sync the database with the Django models
python3 manage.py collectstatic --noinput # to copy all assets to the static folder
python3 manage.py createsuperuser
# link the frontend dist to the django static folder, this is only needed once, frontend updates will automatically be applied
cd static/www
ln -s ../../../frontend/dist dist
```

### Run frontend

- `yarn dev` Local dev with no backend (no or mock data, cookie required)
- `yarn start` Local dev with backend on localhost:8000 -- see next paragraph (cookie required)
- `yarn start:dev` Local dev with backend on the remote dev deployment (cookie required)
- `yarn start:local` Local dev with backend on the local dev deployment on mnp.local (cookie required)

To obtain the login cookie, login in the application with the forwarded backend, copy the `kc-access` cookie and set it into localhost:9000

### Run backend application

start the Django server

```bash
ACCOUNTS_ADMIN_PASSWORD=metacell ACCOUNTS_ADMIN_USERNAME=admin CH_CURRENT_APP_NAME=__APP_NAME__ CH_VALUES_PATH=../../../deployment/helm/values.yaml DJANGO_SETTINGS_MODULE=django_baseapp.settings KUBERNETES_SERVICE_HOST=a uvicorn --host 0.0.0.0 --port 8000 django_baseapp.asgi:application
```

Before running this backend, have to:
- Run `harness-deployment ... -n [NAMESPACE] -i __APP_NAME__` with the setup
- port-forward keycloak and the database (see below)

### Running local with port forwardings to a kubernetes cluster
When you create port forwards to microservices in your k8s cluster you want to forced your local backend server to initialize
the AuthService and EventService services.
This can be done by setting the `KUBERNETES_SERVICE_HOST` environment variable to a dummy or correct k8s service host.
The `KUBERNETES_SERVICE_HOST` switch will activate the creation of the keycloak client and client roles of this microservice.

Run `port-forward.sh` to get the keycloak and database running.

To access those have to map to the hosts file:

```
127.0.0.1 accounts.[NAMESPACE] __APP_NAME__-db
```

After running the backend on port 8000, run `yarn start` to get a frontend to it

#### Vs code run configuration

Run configuration is automatically generated for VS code (__APP_NAME__ backend)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import time
from django.http import HttpRequest
from ninja import NinjaAPI
from ..exceptions import Http401, Http403


api = NinjaAPI(title='__APP_NAME__ API', version='0.1.0')


@api.exception_handler(Http401)
def unauthorized(request, exc):
return api.create_response(
request,
{'message': 'Unauthorized'},
status=401,
)


@api.exception_handler(Http403)
def forbidden(request, exc):
return api.create_response(
request,
{'message': 'Forbidden'},
status=403,
)


@api.get('/ping', response={200: float}, tags=['test'])
def ping(request: HttpRequest):
return time.time()


@api.get('/live', response={200: str}, tags=['test'])
def live(request: HttpRequest):
return 'OK'


@api.get('/ready', response={200: str}, tags=['test'])
def ready(request: HttpRequest):
return 'OK'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Http401(Exception):
pass


class Http403(Exception):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ninja import Schema

# Create your schema here
Loading
Loading