Skip to content

code4romania/onghub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

NGO Hub

GitHub contributors GitHub last commit License: MPL 2.0

Insert bullets description of the project if available.

See the project live

Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

Contributing | Built with | Repos and projects | Deployment | Feedback | License | About Code for Romania

Contributing

This project is built by amazing volunteers and you can be one of them! Here's a list of ways in which you can contribute to this project. If you want to make any change to this repository, please make a fork first.

Help us out by testing this project in the staging environment. If you see something that doesn't quite work the way you expect it to, open an Issue. Make sure to describe what you expect to happen and what is actually happening in detail.

If you would like to suggest new functionality, open an Issue and mark it as a [Feature request]. Please be specific about why you think this functionality will be of use. If you can, please include some visual description of what you would like the UI to look like, if you are suggesting new UI elements.

Built With

React / NestJS

Programming languages

Javascript / Typescript

Platforms

Web

Frontend framework

React

Package managers

NPM

Database technology & provider

Postgres in AWS RDS

Repos and projects

  1. terraform-ngohub

Deployment

The deployment process requires to understand the infrastructure orchestration.

  1. There are 2 environments: staging and production
  2. FE deployed in AWS Amplify
  3. BE deployed in AWS ECS
  4. AWS Infrastructure managed by Terraform (terraform-ngohub)

alt text

Front-End Deployment

  • Deployed using AWS Amplify
  • AWS Amplify is connected with this repository
  • The build is automatically triggered when a commit is pushed to:
    • Develop - build in staging
    • Main - build in production

Backend-End Deployment

The following are the involved parts:

  1. Github Actions (build-image.yml)
  2. ECR where the Docker Images are stored
  3. ECS container orechestrator (aka where the Docker image is running/managed)
  4. Terraform project (terraform-ngohub)
  5. Terraform Cloud

When a new deployment is needed, there is a flow of events to understand:

  1. A git push or git tag to the develop / main branch will trigger the Github Action (1) to:

    1. build the Docker Image
    2. tag the image (with the branch or the tag)
    3. push the image to ECR (2)

    🧠 Note: We want to tag a commit in order to have a tagged image in ECR to be picker later. Check the existing tags and use a new one (e.g. 0.1.5)

  2. Once the Docker Image is available in ECR, we can instruct ECS to pick the new image to replace the current. We do this, by navigating to locals.tf in the terraform-ngohub repository and update the backend tag with the new, fresh one.

        backend = {
            domain = "api${local.env_suffix}.${var.root_domain}"
            image = {
                repo = data.aws_ecr_repository.ngohub_backend.repository_url
                tag  = "1.0.14" -> "1.0.15" // πŸ‘ˆ Update 1.0.14 to 1.0.15
            }
        }

    🧠 There are 2 important triggers on the Terraform Repository (4) ran by Terraform Cloud (5):

    1. terraform plan - will be visibile in the PR, and will display the infrastructure changes.

      1. PR to develop - plan for staging environment
      2. PR to main - plan for production environment
    2. terraform apply - will make the infrastructure changes as described in the plan.

      1. Merge PR to develop - apply changes in staging
      2. Merge PR to main - apply changes in production

    πŸ† In the end, we want to apply the changes (close the PR) so a new ECS Task Definition will be created using the new image with the new tag we updated and the ECS Service will replace the old task definition with the new one, ensuring zero downtime deployment.


❌ DO NOT try to push changes directly to develop/main. The branches are protected.

βœ… Recommended steps:

  1. create a new branch from develop
  2. make changes in locals.tf as described above
  3. commit changes
  4. open PR against develop
  5. check the terraform plan is working as expected
  6. close the PR
  7. test changes in the staging environment
  8. once you are sure everything is fine, repeat for the main branch to deploy into production.

Feedback

  • Request a new feature on GitHub.
  • Vote for popular feature requests.
  • File a bug in GitHub Issues.
  • Email us with other feedback [email protected]

License

This project is licensed under the MPL 2.0 License - see the LICENSE file for details

About Code for Romania

Started in 2016, Code for Romania is a civic tech NGO, official member of the Code for All network. We have a community of around 2.000 volunteers (developers, ux/ui, communications, data scientists, graphic designers, devops, it security and more) who work pro-bono for developing digital solutions to solve social problems. #techforsocialgood. If you want to learn more details about our projects visit our site or if you want to talk to one of our staff members, please e-mail us at [email protected].

Last, but not least, we rely on donations to ensure the infrastructure, logistics and management of our community that is widely spread across 11 timezones, coding for social change to make Romania and the world a better place. If you want to support us, you can do it here.