Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moshclouds/nimbusecr
Welcome to NimbusECR! This project demonstrates a full CI/CD pipeline using GitHub Actions to build and push a Dockerized Spring Boot application to Amazon Elastic Container Registry (ECR). đŠī¸
https://github.com/moshclouds/nimbusecr
actions docker ecr iam java spring-boot
Last synced: about 1 month ago
JSON representation
Welcome to NimbusECR! This project demonstrates a full CI/CD pipeline using GitHub Actions to build and push a Dockerized Spring Boot application to Amazon Elastic Container Registry (ECR). đŠī¸
- Host: GitHub
- URL: https://github.com/moshclouds/nimbusecr
- Owner: moshclouds
- Created: 2024-11-19T01:56:49.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-11-19T13:36:46.000Z (about 1 month ago)
- Last Synced: 2024-11-19T14:43:34.284Z (about 1 month ago)
- Topics: actions, docker, ecr, iam, java, spring-boot
- Language: Java
- Homepage:
- Size: 583 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NimbusECR đ
Welcome to **NimbusECR**! This project demonstrates a full CI/CD pipeline using **GitHub Actions** to build and push a Dockerized Spring Boot application to **Amazon Elastic Container Registry (ECR)**. đŠī¸
## đ Table of Contents
- [About the Project](#about-the-project)
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [CI/CD Workflow Details](#cicd-workflow-details)
- [Directory Structure](#directory-structure)
- [Built With](#built-with)---
## đ About the Project
**NimbusECR** is a starter Spring Boot REST API application with a `hello world` endpoint, designed to showcase the following:
- Building a Spring Boot application using **Maven**
- Containerizing the application with **Docker**
- Pushing the image to **Amazon Elastic Container Registry (ECR)** using **GitHub Actions**
- Deploying and running the container on local or cloud environments---
## ⨠Features
- đą **Lightweight Spring Boot Starter App**: Minimalistic REST API for easy understanding.
- đ **Dockerized Build**: Containerized application for consistent deployments.
- âī¸ **ECR Integration**: Pushes the Docker image to Amazon ECR seamlessly.
- đ¤ **Automated CI/CD**: Utilizes GitHub Actions for build and push automation.---
## đ ī¸ Prerequisites
Before you begin, ensure you have the following:
1. **AWS IAM User**:
- The IAM user should have the `AmazonEC2ContainerRegistryFullAccess` policy attached.
2. **AWS CLI**: Installed and configured with credentials for the IAM user.
3. **GitHub Secrets**: Set up the following secrets in your GitHub repository:
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_REGION`
- `AWS_ECR_REGISTRY`: The AWS account ID.
- `AWS_ECR_REPO_NAME`: The name of your ECR repository.4. **Docker**: Installed and configured on your local machine if you want to run the image locally.
---
## đ Getting Started
### **Clone the Repository**
```bash
git clone https://github.com/your-username/nimbus-ecr.git
cd nimbus-ecr
```### **Run Locally**
1. **Build the Project**:
```bash
mvn clean install
```2. **Build and Run Docker Container**:
```bash
docker build -t nimbusecr:local .
docker run -p 8080:8080 nimbusecr:local
```3. **Access the Endpoint**:
Open your browser or use `curl` to hit:
```bash
curl http://localhost:8080/hello
```---
## đ¤ CI/CD Workflow Details
### **GitHub Actions Workflow**
The `.github/workflows/main.yml` file defines the CI/CD pipeline. Below is an explanation of each step:1. **Check Out the Code**:
Uses `actions/checkout@v4` to pull the code from the repository.2. **Set Up JDK**:
Installs OpenJDK 21 to build the Spring Boot application.3. **Clean Build Directory**:
Removes any previous build artifacts using `mvn clean`.4. **Build Project**:
Builds the Spring Boot JAR file using `mvn install`.5. **Configure AWS Credentials**:
Configures GitHub Actions to use your AWS credentials.6. **Login to Amazon ECR**:
Authenticates Docker to your Amazon ECR repository.7. **Build and Push Docker Image**:
- Builds the Docker image for the application.
- Pushes the image to your specified Amazon ECR repository.---
## đī¸ Directory Structure
```
nimbus-ecr/
âââ src/ # Application source code
â âââ main/
â â âââ java/
â â â âââ com.example.demo/ # Your Spring Boot code
â â âââ resources/ # Application resources
âââ target/ # Compiled JAR and build artifacts
âââ Dockerfile # Docker configuration file
âââ pom.xml # Maven project file
âââ .github/
âââ workflows/
âââ main.yml # CI/CD workflow file
```---
## đ ī¸ Built With
- **Spring Boot**: A Java framework for building RESTful APIs.
- **Maven**: Dependency and build management.
- **Docker**: Containerization platform.
- **Amazon ECR**: Secure container registry.
- **GitHub Actions**: CI/CD automation.---
## đ Example API Endpoint
The application exposes a simple REST API:
### `GET /`
**Response**:
```json
{
"message": "server, online!"
}
```---
## đ Contributing
Contributions are welcome! If you find any issues or have suggestions, feel free to open an issue or a pull request.
---
### đ Ready to Deploy
Once the Docker image is pushed to Amazon ECR, you can pull it and run it locally or deploy it in your AWS environment.
```bash
# Authenticate Docker
aws ecr get-login-password --region | docker login --username AWS --password-stdin# Pull the image
docker pull :# Run the container
docker run -p 8080:8080 :
```
---
### Proof Of Concepts