Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pr title validation feature #65

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
18 changes: 18 additions & 0 deletions .github/workflows/pr_title_validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR Title Validation

on:
pull_request:
types: [opened, reopened, edited]

jobs:
validate_title:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run validation script
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: python validate_title.py "$PR_TITLE"
62 changes: 46 additions & 16 deletions docker-setups/angular-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
3. [Set up for Angular project](#3-set-up-for-angular-project)
4. [Setting up the Docker Environment](#4-setting-up-the-docker-environment)
- [Dockerfile](#41-dockerfile)
- [Angular version-specific file path for Nginx](#set-the-correct-file-path-for-nginx)
- [Docker Compose](#42-docker-compose)
- [nginx.conf](#43-nginxconf)
- [.dockerignore](#44-dockerignore)
5. [Testing the Docker Environment](#5-testing-the-docker-environment)
- [Using docker-compose](#build-and-run-using-docker-compose-file)
- [Step by step build](#or-alternatively-build-step-by-step)
- [Build and run using docker-compose file](#build-and-run-using-docker-compose-file)
- [Build and Manage Docker Containers Using Docker Compose](#build-and-manage-docker-containers-using-docker-compose)
6. [Access Angular Application](#6-access-angular-application)
7. [Sample Repository](#7-sample-repository)
8. [Conclusion](#8-conclusion)
- [Benefits of Docker Setup](#benefits-of-docker-setup)
- [Future Enhancements](#future-enhancements)
- [Remember to:](#remember-to)

Each section is linked to its corresponding content in the document for easy navigation.

Expand Down Expand Up @@ -201,12 +201,11 @@ services:
context: .
dockerfile: Dockerfile
args:
APP_NAME: your-app-name
image: angular-sample-image
container_name: angular-sample-container
APP_NAME: angular-docker
image: angular-docker
container_name: angular-docker
ports:
- '127.0.0.1:5000:80'

- '127.0.0.1:5000:80' # Ensure ports are only exposed locally by binding to 127.0.0.1
```

[Back to top](#table-of-contents)
Expand Down Expand Up @@ -256,30 +255,43 @@ Run the following command to build and compose your docker image using docker-co
```shell
docker-compose -f docker-compose.yml up
```
### OR Alternatively build step by step

#### Build Docker Image
### Build and Manage Docker Containers Using Docker Compose

#### Create docker-compose.yml file

Create a file named docker-compose.yml in the root directory of your project. This file will contain the configuration for your Docker services.

[4.2 Docker Compose](#42-docker-compose)

#### Build Docker images using Docker Compose

Run the following command in the root directory of your project to build the Docker images. Replace `your-app-name` with a suitable value as an argument:
Instead of manually building the Docker image, you'll use Docker Compose to build it based on the configuration in docker-compose.yml. Run the following command:

```shell
docker build --build-arg APP_NAME=your-app-name -t ng-docker-app:v1.0.0 -f ./Dockerfile .
docker-compose build
```

#### Create Docker Containers
#### Run Docker containers using Docker Compose

Start the Docker containers using the following command:
Once the image is built, you can use Docker Compose to start the containers:

```shell
docker run -p 5000:80 -d ng-docker-app:v1.0.0
docker-compose up -d
```

#### Optional: To get the list of currently running containers
This command will start the containers defined in the docker-compose.yml file in detached mode.

#### Optional: List currently running containers:

You can use Docker Compose to view the list of currently running containers:

```shell
docker container ls
```

This setup will utilize Docker Compose to manage your containers, making the process more streamlined and manageable, especially as your project grows in complexity.

[Back to top](#table-of-contents)

## 6. Access Angular Application
Expand Down Expand Up @@ -310,4 +322,22 @@ Setting up a Docker environment for your Angular application with Nginx offers s

Consider enhancing your Docker setup by adding features such as environment-specific configurations, health checks, and Docker Swarm/Kubernetes integration for production deployments.

[Back to top](#table-of-contents)

### Remember to:

- Maintain consistent naming conventions for services, container_name, image, and volume.

- Add COMPOSE_PROJECT_NAME in .env.example and .env files to avoid conflicts with other projects.

```plaintext
COMPOSE_PROJECT_NAME=project-name
```

- Use docker-compose for setting up the containers instead of manual building processes.

- Add 127.0.0.1 to map and expose port only locally like this "127.0.0.1:5000:5000" to avoid security risks.

By following these updates and best practices, your Docker setup for Angular applications will be more robust and secure.

[Back to top](#table-of-contents)
65 changes: 40 additions & 25 deletions docker-setups/dotnet-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
- [1. Dockerfile](#1-dockerfile)
- [2. Dockerignore](#2-dockerignore)
- [3. Docker Compose (Optional for Development)](#3-docker-compose-optional-for-development)
- [4. Build Docker Image](#4-build-docker-image)
- [5. Run Docker Container](#5-run-docker-container)
- [6. Test the Container](#6-test-the-container)
- [7. Deployment](#7-deployment)
- [4. Build Docker images using Docker Compose](#4-build-docker-images-using-docker-compose)
- [5. Run Docker containers using Docker Compose](#5-run-docker-containers-using-docker-compose)
- [6. Optional: List currently running containers:](#6-optional-list-currently-running-containers)
- [7. Test the Container](#7-test-the-container)
- [8. Deployment](#8-deployment)
- [Push Dockerized application to DockerHub](#push-dockerized-application-to-dockerhub)
- [Run Dockerized application](#run-dockerized-application)
- [4. Addressing Common Issues](#4-addressing-common-issues)
- [5. Best Practices for Enhanced Dockerization](#5-best-practices-for-enhanced-dockerization)
- [6. Conclusion](#6-conclusion)
- [Benefits of Docker](#benefits-of-docker)
- [Future Enhancements](#future-enhancements)
- [Remember to:](#remember-to)
## 1. Introduction

### Purpose
Expand Down Expand Up @@ -104,9 +108,9 @@ version: "3"
services:
foundation-mariadb:
image: mariadb:11.2.2
container_name: foundation-db
container_name: foundation-mariadb
ports:
- 3307:3306
- '127.0.0.1:3307:3306' # Bind port to localhost to enhance security
env_file:
- .env
environment:
Expand All @@ -115,7 +119,7 @@ services:
- MYSQL_PASSWORD=${MARIADB_PASSWORD}
- MYSQL_DATABASE=${MARIADB_DATABASE}
volumes:
- foundation-db-data:/var/lib/mysql
- foundation-mariadb-db-data:/var/lib/mysql
restart: always

foundation-backend:
Expand All @@ -124,46 +128,47 @@ services:
dockerfile: Dockerfile
depends_on:
- foundation-mariadb
image: foundation-backend:1.0
container_name: foundation-api
image: foundation-backend
container_name: foundation-backend
ports:
- 5000:5000
- '127.0.0.1:5000:5000' # Bind port to localhost to enhance security
environment:
- DOTNET_URLS=http://+:5000

volumes:
foundation-db-data:
driver: local
```
### 4. Build Docker images using Docker Compose

### 4. Build Docker Image:
Instead of manually building the Docker image, you'll use Docker Compose to build it based on the configuration in docker-compose.yml. Run the following command:

Build the Docker image using the Dockerfile you created.

```bash
docker build -t your-app-name .
```shell
docker-compose build
```

### 5. Run Docker Container:

Run the Docker container from the built image. If using Docker Compose, you can simply run `docker-compose up`.

```bash
docker run -d -p 5000:5000 --name your-container-name your-app-name
### 5. Run Docker containers using Docker Compose
Once the image is built, you can use Docker Compose to start the containers:
```shell
docker-compose up -d
```
This command will start the containers defined in the docker-compose.yml file in detached mode.

- The `-d` flag runs the container in detached mode (background).
- The `-p 5000:80` flag maps port 5000 inside the container to port 5000 on your host machine, allowing you to access your application in a browser at `http://localhost:5000`.
### 6. Optional: List currently running containers:
You can use Docker Compose to view the list of currently running containers:
```shell
docker container ls
```

### 6. Test the Container:
### 7. Test the Container:

Access your application in a web browser or using a tool like curl to ensure it's running properly.

```bash
curl http://localhost:5000
```

### 7. Deployment:
### 8. Deployment:

For deployment to a production instance, you can push your Docker image to a container registry like Docker Hub or Azure Container Registry. Then, pull the image onto your production server and run it similarly to the development setup.

Expand Down Expand Up @@ -241,3 +246,13 @@ Dockerizing your .NET application offers several benefits:
Consider enhancing your DockerFile by using minimal base images, layer caching, multi-stage builds, minimizing dependencies, and leveraging .dockerignore files and implementing robust monitoring and logging solutions for insights into container performance

[Back to top](#table-of-contents)

### Remember to:

- Add COMPOSE_PROJECT_NAME in .env.example and .env files to avoid conflicts with other projects.

```plaintext
COMPOSE_PROJECT_NAME=project-name
```

[Back to top](#table-of-contents)
16 changes: 14 additions & 2 deletions docker-setups/nodejs-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
6. [Conclusion](#6-conclusion)
- [Benefits of Docker Setup](#benefits-of-docker-setup)
- [Future Enhancements](#future-enhancements)
- [Remember to:](#remember-to)

Each section is linked to its corresponding content in the document for easy navigation.

Expand Down Expand Up @@ -110,10 +111,11 @@ services:
ports:
- "127.0.0.1:${MARIADB_DOCKER_PORT}:3306"
volumes:
- app-db:/var/lib/mysql
- mariadb-db-data:/var/lib/mysql

volumes:
app-db: ~
mariadb-db-data:
driver: local
```

## 4. Testing the Docker Environment
Expand Down Expand Up @@ -163,3 +165,13 @@ Setting up a Docker environment for your NestJS application with MariaDB databas
Consider enhancing your Docker setup by adding features such as environment-specific configurations, health checks, and Docker Swarm/Kubernetes integration for production deployments.

[Back to top](#table-of-contents)

### Remember to:

- Add COMPOSE_PROJECT_NAME in .env.example and .env files to avoid conflicts with other projects.

```plaintext
COMPOSE_PROJECT_NAME=project-name
```

[Back to top](#table-of-contents)
25 changes: 25 additions & 0 deletions validate_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import re
import sys

def validate_title(title):
print("The title is:", title)
prefix_pattern = r'^(build|chore|ci|docs|feat|fix|perf|refactor|style|test|sample)[:\s].+'
max_length = 50

match = re.match(prefix_pattern, title, re.IGNORECASE)
print("Match:", match)

if not match:
print("PR title must start with one of the following prefixes: build, chore, ci, docs, feat, fix, perf, refactor, style, test, sample", file=sys.stderr)
sys.exit(1)

title_content = title.split(':', 1)[-1].strip()
print("Title Content:", title_content)

if len(title_content) > max_length:
print(f"PR title content must not exceed {max_length} characters", file=sys.stderr)
sys.exit(1)

if __name__ == "__main__":
title = sys.argv[1]
validate_title(title)
Loading