This repository uses Bitbucket Pipelines for Continuous Integration and Continuous Deployment (CI/CD). The pipeline builds and pushes Docker images and manages dynamic branches for development.
The CI/CD pipeline is designed to automate the build and deployment processes, ensuring that the application is consistently built, tested, and deployed across different environments. The pipeline has two main sections:
- Branches: Executes the pipeline when code is pushed to the
master
branch. - Pull Requests: Executes the pipeline for any pull requests, managing dynamic branches for development.
The definitions
section defines reusable steps for the pipeline.
The pipelines section defines the triggers and steps for different events.
For the master branch, the pipeline builds and pushes a Docker image to the AWS ECR repository.
For any pull request, the pipeline builds the project in development mode and transfers the built files to a remote server, creating a dynamic directory based on the branch name.
Ensure the following environment variables are set in your Bitbucket repository settings:
- AWS_KEY: AWS Access Key ID.
- AWS_SECRET: AWS Secret Access Key.
- AWS_DEFAULT_REGION: AWS Region (e.g., sa-east-1).
- SSH_PRIVATE_KEY: Base64-encoded SSH private key for accessing the remote server.
To serve the dynamically created branches, add the following configuration to your Nginx server block:
location /branch {
root /var/www/projeto/;
index index.html;
try_files $uri $uri/ /index.html;
}
This configuration sets up Nginx to serve files from the /var/www/projeto/ directory for any requests to /branch, falling back to index.html for single-page application (SPA) routing.
- Bitbucket account with Pipelines enabled.
- AWS account with ECR repository created.
- Remote server with SSH access configured.
- Nginx server properly set up to serve your application.
This CI/CD pipeline ensures that your application is built, tested, and deployed efficiently. Feel free to customize the pipeline configuration to fit your project’s specific requirements.