Skip to content

Commit

Permalink
Merge pull request #1 from dinesh-aot/EPICSYSTEM-152
Browse files Browse the repository at this point in the history
initial setup
  • Loading branch information
dinesh-aot authored Jul 26, 2024
2 parents 099932f + e22d361 commit e596956
Show file tree
Hide file tree
Showing 148 changed files with 10,727 additions and 5,050 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/api-cd.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: SCAFFOLD API CD
name: Compliance API CD


on:
push:
branches:
- develop
paths:
- "scaffold-api/**"
- "compliance-api/**"
workflow_dispatch:
inputs:
environment:
Expand All @@ -17,17 +17,17 @@ on:
defaults:
run:
shell: bash
working-directory: ./scaffold-api
working-directory: ./compliance-api

env:
APP_NAME: "scaffold-api"
APP_NAME: "compliance-api"
TAG_NAME: "${{ github.event.inputs.environment || 'dev' }}" # If the environment type is manually selected, use the input value; otherwise, use 'dev' as default

jobs:
api-cd:
runs-on: ubuntu-20.04

if: github.repository == 'bcgov/EPIC.scaffold'
if: github.repository == 'bcgov/EPIC.compliance'
environment:
name: "dev"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/api-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: SCAFFOLD API CI
name: Compliance API CI

on:
pull_request:
branches:
- develop
paths:
- "scaffold-api/**"
- "compliance-api/**"

defaults:
run:
shell: bash
working-directory: ./scaffold-api
working-directory: ./compliance-api

jobs:
setup-job:
Expand Down Expand Up @@ -97,8 +97,8 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: scaffold-api
name: codecov-scaffold-api
flags: compliance-api
name: codecov-compliance-api
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
shell: bash
run: |
oc project ${{ secrets.OPENSHIFT_REPOSITORY }}-tools
oc tag scaffold-api:latest scaffold-api:${{ github.event.inputs.environment }}
oc tag scaffold-web:latest scaffold-web:${{ github.event.inputs.environment }}
oc tag compliance-api:latest compliance-api:${{ github.event.inputs.environment }}
oc tag compliance-web:latest compliance-web:${{ github.event.inputs.environment }}
oc rollout status dc/scaffold-api -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} -w
oc rollout status dc/scaffold-web -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} -w
oc rollout status dc/compliance-api -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} -w
oc rollout status dc/compliance-web -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} -w
10 changes: 5 additions & 5 deletions .github/workflows/web-cd.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: SCAFFOLD WEB CD
name: Compliance WEB CD


on:
push:
branches:
- develop
paths:
- "scaffold-web/**"
- "compliance-web/**"
workflow_dispatch:
inputs:
environment:
Expand All @@ -17,17 +17,17 @@ on:
defaults:
run:
shell: bash
working-directory: ./scaffold-web
working-directory: ./compliance-web

env:
APP_NAME: "scaffold-web"
APP_NAME: "compliance-web"
TAG_NAME: "${{ github.event.inputs.environment || 'dev' }}" # If the environment type is manually selected, use the input value; otherwise, use 'dev' as default

jobs:
web-cd:
runs-on: ubuntu-20.04

if: github.repository == 'bcgov/EPIC.scaffold'
if: github.repository == 'bcgov/EPIC.compliance'
environment:
name: "dev"

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/web.ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: SCAFFOLD WEB CI
name: Compliance WEB CI

on:
pull_request:
branches:
- develop
paths:
- "scaffold-web/**"
- "compliance-web/**"
push:
branches:
- develop

defaults:
run:
shell: bash
working-directory: ./scaffold-web
working-directory: ./compliance-web

jobs:
setup-job:
runs-on: ubuntu-20.04

if: github.repository == 'bcgov/EPIC.scaffold'
if: github.repository == 'bcgov/EPIC.compliance'

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -76,13 +76,13 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: scaffold-web
name: codecov-scaffold-web
flags: compliance-web
name: codecov-compliance-web
fail_ci_if_error: true
verbose: true
override_branch: ${{ env.CODECOV_BRANCH }}
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./scaffold-web/coverage
directory: ./compliance-web/coverage

build-check:
needs: setup-job
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ dmypy.json
# Pyre type checker
.pyre/
.DS_Store
scaffold-api/.DS_Store
scaffold-api/.DS_Store
compliance-api/.DS_Store
compliance-api/.DS_Store
/.idea/vcs.xml
/.idea/inspectionProfiles/profiles_settings.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/misc.xml
/.idea/modules.xml
/.idea/scaffold-public.iml
/.idea/compliance-public.iml

# VSCode Chrome extension user data
.vscode/chrome
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"version": "0.2.0",
"configurations": [
{
"name": "Scaffold API",
"name": "Compliance API",
"type": "python",
"cwd": "${workspaceFolder}/scaffold-api/",
"cwd": "${workspaceFolder}/compliance-api/",
"request": "launch",
"program": "${workspaceFolder}/scaffold-api/wsgi.py",
"program": "${workspaceFolder}/compliance-api/wsgi.py",
"console": "integratedTerminal",
"justMyCode": true
}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.analysis.extraPaths": [
"./scaffold-api/src"
"./compliance-api/src"
]
}
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Scaffold Setup Instructions
# Compliance Setup Instructions

This document outlines the setup instructions for both the backend and front-end components of the project. Ensure you follow the steps in sequence for a smooth setup.

Expand All @@ -9,10 +9,10 @@ Ensure Python 3.12.4 is installed in your WSL environment. Download it from the

### 2. Set Up PYTHONPATH
Add the following line to your `.bashrc` or `.zshrc` file to set the `PYTHONPATH` environment variable:
export PYTHONPATH="/path/to/scaffold-api:${PYTHONPATH}"
export PYTHONPATH="/path/to/compliance-api:${PYTHONPATH}"

### 3. Configure Environment Variables
Create a `.env` file in your scaffold-api with the necessary configurations. Reference sample.env to see what variables you need to configure
Create a `.env` file in your compliance-api with the necessary configurations. Reference sample.env to see what variables you need to configure

### 4. Start Docker Compose
In a separate terminal, launch Docker Compose to set up your containers:
Expand Down Expand Up @@ -41,24 +41,24 @@ make run
- set FLASK_APP=app.py
set FLASK_ENV=development

2. Configure `PYTHONPATH` to your project's folder location up to `scaffold-api/src`:
- set PYTHONPATH=path\to\scaffold-api\src && PYTHONPATH=path\to\scaffold-api
2. Configure `PYTHONPATH` to your project's folder location up to `compliance-api/src`:
- set PYTHONPATH=path\to\compliance-api\src && PYTHONPATH=path\to\compliance-api

## Step 2: Start Docker

1. Open a terminal.
2. Navigate to the `scaffold-api` directory:
cd scaffold-api
2. Navigate to the `compliance-api` directory:
cd compliance-api

3. Run the following command to start the services using Docker Compose:
docker-compose up

## Step 3: Set Up `scaffold-api`
## Step 3: Set Up `compliance-api`

1. Open a separate terminal.

2. Navigate to the `` directory:
cd scaffold-api
cd compliance-api

3. Create a virtual environment. Refer to the official Python documentation on how to create a virtual environment: [Python venv](https://docs.python.org/3/library/venv.html).
python -m venv venv
Expand All @@ -77,7 +77,7 @@ make run

### 1. Navigate to Front End Directory
Change to the front-end directory:
cd scaffold-web
cd compliance-web

### 2. Install Dependencies
Install necessary npm packages:
Expand Down Expand Up @@ -149,7 +149,7 @@ You need a policy to allow pods in xxxx-dev to connect with each other


# Github Workflows
you can find a working example here: https://github.com/bcgov/EPIC.scaffold/tree/main/.github/workflows
you can find a working example here: https://github.com/bcgov/EPIC.compliance/tree/main/.github/workflows

- create a github-action service account openshift in the tools namespace and bind to it image puller and image pusher roles
- Add the following secrets in the repo settings under repository secrets: OPENSHIFT_IMAGE_REGISTRY (the public image repository, ignore the path just the base url), OPENSHIFT_LOGIN_REGISTRY (you can pull this from the same place you get your oc login command, OPENSHIFT_REPOSITORY, OPENSHIFT_SA_NAME (github_action), OPENSHIFT_SA_TOKEN(github-action token, find it in secrets)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions scaffold-api/README.md → compliance-api/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SCAFFOLD-API
# Compliance-API

A scaffold Python flask API application to be used as a template.
A compliance Python flask API application to be used as a template.

## Getting Started

Expand All @@ -10,9 +10,9 @@ A scaffold Python flask API application to be used as a template.
- [Docker](https://www.docker.com/)
- [Docker-Compose](https://docs.docker.com/compose/install/)
* Install Dependencies
- Run `make setup` in the root of the project (scaffold-api)
- Run `make setup` in the root of the project (compliance-api)
* Start the databases
- Run `docker-compose up` in the root of the project (scaffold-api)
- Run `docker-compose up` in the root of the project (compliance-api)

## Environment Variables

Expand Down Expand Up @@ -47,4 +47,4 @@ Open [http://localhost:5000/api](http://localhost:5000/api) to view it in the br

Ensure the latest version of [VS Code](https://code.visualstudio.com) is installed.

The [`launch.json`](.vscode/launch.json) is already configured with a launch task (SCAFFOLD-API Launch) that allows you to launch chrome in a debugging capacity and debug through code within the editor.
The [`launch.json`](.vscode/launch.json) is already configured with a launch task (Compliance-API Launch) that allows you to launch chrome in a debugging capacity and debug through code within the editor.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
version: "3.9"

services:
scaffold-api-db:
compliance-api-db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data2
environment:
- POSTGRES_USER=scaffold
- POSTGRES_PASSWORD=scaffold
- POSTGRES_DB=scaffold
- POSTGRES_USER=compliance
- POSTGRES_PASSWORD=compliance
- POSTGRES_DB=compliance
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- 54332:5432/tcp
restart: unless-stopped

scaffold-api-db-test:
compliance-api-db-test:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data3
environment:
- POSTGRES_USER=scaffold
- POSTGRES_PASSWORD=scaffold
- POSTGRES_DB=scaffold
- POSTGRES_USER=compliance
- POSTGRES_PASSWORD=compliance
- POSTGRES_DB=compliance
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- 54333:5432/tcp
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 14 additions & 14 deletions scaffold-api/sample.env → compliance-api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@ FLASK_ENV=development
export FLASK_APP=wsgi.py

# local db variables
DATABASE_USERNAME=scaffold
DATABASE_PASSWORD=scaffold
DATABASE_NAME=scaffold
DATABASE_USERNAME=compliance
DATABASE_PASSWORD=compliance
DATABASE_NAME=compliance
DATABASE_HOST=localhost
DATABASE_PORT=54332

DATABASE_TEST_USERNAME=scaffold
DATABASE_TEST_PASSWORD=scaffold
DATABASE_TEST_NAME=scaffold
DATABASE_TEST_USERNAME=compliance
DATABASE_TEST_PASSWORD=compliance
DATABASE_TEST_NAME=compliance
DATABASE_TEST_HOST=localhost
DATABASE_TEST_PORT=5432

JWT_OIDC_TEST_ISSUER="http://localhost:8081/auth/realms/demo"
JWT_OIDC_TEST_WELL_KNOWN_CONFIG="http://localhost:8081/auth/realms/demo/.well-known/openid-configuration"
JWT_OIDC_TEST_ALGORITHMS="RS256"
JWT_OIDC_TEST_AUDIENCE="scaffold-web"
JWT_OIDC_TEST_AUDIENCE="compliance-web"
JWT_OIDC_TEST_CLIENT_SECRET="1111111111"
JWT_OIDC_TEST_JWKS_CACHE_TIMEOUT="6000"

JWT_OIDC_WELL_KNOWN_CONFIG=https://localhost:8080/auth/realms/scaffold/.well-known/openid-configuration
JWT_OIDC_WELL_KNOWN_CONFIG=https://localhost:8080/auth/realms/compliance/.well-known/openid-configuration
JWT_OIDC_AUDIENCE=account
JWT_OIDC_ISSUER=https://localhost:8080/auth/realms/scaffold
JWT_OIDC_ISSUER=https://localhost:8080/auth/realms/compliance
JWT_OIDC_ALGORITHMS=RS256
JWT_OIDC_JWKS_URI=https://localhost:8080/auth/realms/scaffold/protocol/openid-connect/certs
JWT_OIDC_JWKS_URI=https://localhost:8080/auth/realms/compliance/protocol/openid-connect/certs
JWT_OIDC_CACHING_ENABLED=True
JWT_OIDC_JWKS_CACHE_TIMEOUT=3000000

SITE_URL=http://localhost:3000
KEYCLOAK_BASE_URL=https://localhost:8080
KEYCLOAK_URL_REALM=scaffold
KEYCLOAK_URL_REALM=compliance

SCAFFOLD_ADMIN_CLIENT_ID=scaffold-admin
SCAFFOLD_ADMIN_CLIENT_SECRET=<GENERATED_CLIENT_SECRET>
COMPLIANCE_ADMIN_CLIENT_ID=compliance-admin
COMPLIANCE_ADMIN_CLIENT_SECRET=<GENERATED_CLIENT_SECRET>

CORS_ORIGIN=http://192.168.0.145:8000,http://192.168.0.145:3000,http://localhost:8000,http://localhost:3000,http://localhost:5000

S3_BUCKET=<BUCKET_NAME>
S3_ACCESS_KEY_ID=scaffold-admin
S3_ACCESS_KEY_ID=compliance-admin
S3_SECRET_ACCESS_KEY=<GENERATED_S3_SECRET>
S3_HOST=
S3_REGION=
Expand Down
Loading

0 comments on commit e596956

Please sign in to comment.