Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note 2: For database manipulation, you are highly recommended to use SQLAlchemy. SQLAlchemy is an open-source SQL toolkit and object-relational mapper for the Python programming language. It allows you to write Python code in your project to map from the database schema to the applications’ Python objects. No SQL is required to create, maintain and query the database. SQLAlchemy is an implementation of the object-relational mapping (ORM) concept.

 

 

2. IDE / Editor

Note: If you are using the same editor / IDE within the team you can push the editor / IDE configurations and setting to the repository so that all your team members have the same experience.

3. Coding Guidelines

Python:

You must include the requirements.txt with library’s particular version in the project. Reference: Requirements files Google Style Guide: https://google.github.io/styleguide/pyguide.html

4. Source Code Repository

The source code repository must be hosted on BitBucket

...

Code Block
# Specifies intentionally untracked files to ignore when using Git

venv/
.vendor/
__pycache__/
.*
*~
*.sw[mnpcod]
*.log
*.tmp
*.tmp.*
log.txt
*.sublime-project
*.sublime-workspace
.vscode/
npm-debug.log*
.idea/
.sass-cache/
.tmp/
.versions/
coverage/
dist/
node_modules/
tmp/
temp/
hooks/
platforms/
plugins/
plugins/android.json
plugins/ios.json
www/
$RECYCLE.BIN/
.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate
*.md5
*.map

README.md

The bucket must contain a README.md file containing below sections:

  • Getting Started

    • Prerequisites

    • Installing

  • Running the tests

  • Deployment

  • Built With (framework, Main Dependencies)

  • License (required by public repositories)

5. Authentication / Authorization

Authentication

All authentications must be in a stateless manner. Do NOT use sessions. To use CAS for authentication use CAS file in the development tools project hosted here: https://bitbucket.org/ctiteam/dev-tools/  To understand how CAS authentication works, you may refer to CAS Sequence diagram

Authorization

To authorize the users you can create a group in active directory and rely on CAS response XML, which then contains memberOf.

6. Testing

  For API testing refer to http://kb.sites.apiit.edu.my/knowledge-base/api-documentation/

7. Build / Deployment

 

What is pipeline?

Integrated CI/CD for Bitbucket Cloud that’s trivial to set up, automating your code from test to production. Easy setup and configuration There are no CI servers to set up, user management to configure, or repos to synchronize. Just enable Pipelines with a few simple clicks and you’re ready to go. A unified experience with Bitbucket Stop jumping between multiple applications. Manage your entire development workflow within Bitbucket, from code to deployment. Automate dev to deployment Sufficient coverage gives you the confidence to deploy. Reduce human error and keep the team lean working on critical tasks. Support for every platform Build and test with any language or platform including Java, JavaScript, PHP, Ruby, Python, .NET Code and more. Configuration as code Store and manage your build configurations in a single bitbucket-pipelines.yml file. Only 7 lines of code to get you started. Map the branch structure Pipelines can be aligned with the branch structure, making it easier to work with branching workflows like feature branching or git-flow.

What is Zappa and why using it?

Zappa makes it super easy to build and deploy serverless, event-driven Python applications (including, but not limited to, WSGI web apps) on AWS Lambda + API Gateway. Think of it as “serverless” web hosting for your Python apps. That means infinite scaling, zero downtime, zero maintenance – and at a fraction of the cost of your current deployments! If you’ve got a Python web app (including Django and Flask apps), it’s as easy as:

...

For more information on other zappa settings visit https://github.com/Miserlou/Zappa

Setting up pipelines

Must do steps in pipeline:

Code Block
ionic build "npm run ionic:build -- --prod" 
aws s3 cp www/

Build Images

What build image to be used for each env?

Dockerfile with AWS CLI used for deployment for various builders. Reference: AWS CLI BitBucket and CTI Docker Repository for AWS CLI To use pipeline in the BitBucket repository you must enable it in the settings. This action can only be done by Bucket Admin. To set-up the pipeline you need to have a file called  bitbucket-pipelines.yml  in the root of the repository. Sample bitbucket-pipelines.yml:

Code Block
clone:
# LFS is used when you have large files like Oracle Instant Client
  lfs: true

pipelines:
  default:
    - step:
        name: Deploy to dev
        image: python:3.9
        caches:
          - venv
        deployment: test
        script:
          - python -m venv venv
          - source venv/bin/activate
          - pip install -r requirements.txt
          - sed -i.bak "s,\(VAR_NAME = \).*,\1'$VAR_NAME'," destination_file.py
          - zappa update dev || zappa deploy dev

    - step:
        name: Deploy to staging
        image: python:3.9
        caches:
          - venv
        deployment: staging
        script:
          - python -m venv venv
          - source venv/bin/activate
          - pip install -r requirements.txt
          - sed -i.bak "s,\(VAR_NAME = \).*,\1'$VAR_NAME'," destination_file.py
          - zappa update staging || zappa deploy staging

    - step:
        name: Deploy to production
        image: python:3.9
        caches:
          - venv
        trigger: manual
        deployment: production
        script:
          - python -m venv venv
          - source venv/bin/activate
          - pip install -r requirements.txt
          - sed -i.bak "s,\(VAR_NAME = \).*,\1'$VAR_NAME'," destination_file.py
          - zappa update production || zappa deploy production

definitions:
  caches:
    venv: $BITBUCKET_CLONE_DIR/venv

8. Monitoring and Maintenance

Save the log in CloudWatch. Code has to be maintained to ensure continuous availability and security. 

9. User Feedback Collection

User feedback collection is via APSpace Feedback