Insert bullets description of the project if available.
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
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.
React / NestJS
Javascript / Typescript
Web
React
NPM
Postgres in AWS RDS
The deployment process requires to understand the infrastructure orchestration.
- There are 2 environments: staging and production
- FE deployed in AWS Amplify
- BE deployed in AWS ECS
- AWS Infrastructure managed by Terraform (terraform-ngohub)
- 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
The following are the involved parts:
- Github Actions (build-image.yml)
- ECR where the Docker Images are stored
- ECS container orechestrator (aka where the Docker image is running/managed)
- Terraform project (terraform-ngohub)
- Terraform Cloud
When a new deployment is needed, there is a flow of events to understand:
-
A
git push
orgit tag
to thedevelop / main
branch will trigger the Github Action (1) to:- build the Docker Image
- tag the image (with the branch or the tag)
- 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)
-
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):
-
terraform plan
- will be visibile in the PR, and will display the infrastructure changes.- PR to develop - plan for
staging
environment - PR to main - plan for
production
environment
- PR to develop - plan for
-
terraform apply
- will make the infrastructure changes as described in the plan.- Merge PR to develop - apply changes in
staging
- Merge PR to main - apply changes in
production
- Merge PR to develop - apply changes in
π 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.
- create a new branch from develop
- make changes in locals.tf as described above
- commit changes
- open PR against develop
- check the
terraform plan
is working as expected - close the PR
- test changes in the staging environment
- once you are sure everything is fine, repeat for the
main
branch to deploy intoproduction
.
- Request a new feature on GitHub.
- Vote for popular feature requests.
- File a bug in GitHub Issues.
- Email us with other feedback [email protected]
This project is licensed under the MPL 2.0 License - see the LICENSE file for details
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.