Skip to content

Commit

Permalink
Update: Added K8s & Jenkins CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Nov 10, 2024
1 parent e6d0bd9 commit db21cd0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nginx/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
nginx:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80" # Map host port 80 to container port 80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf # Mount custom nginx config file
restart: always # Automatically restart container if it crashes
59 changes: 59 additions & 0 deletions nginx/start_nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Define the docker-compose file location
COMPOSE_FILE="docker-compose.yml"

# Display help message
function show_help() {
echo "Usage: $0 [option]"
echo "Options:"
echo " build Build the Nginx Docker image"
echo " start Start the Nginx container"
echo " stop Stop the Nginx container"
echo " restart Restart the Nginx container"
echo " logs Show logs of the Nginx container"
echo " clean Stop and remove the container"
echo " help Display this help message"
}

# Check if docker-compose file exists
if [ ! -f "$COMPOSE_FILE" ]; then
echo "Error: $COMPOSE_FILE not found!"
exit 1
fi

# Handle script arguments
case "$1" in
build)
echo "Building the Nginx Docker image..."
docker-compose -f $COMPOSE_FILE build
;;
start)
echo "Starting the Nginx container..."
docker-compose -f $COMPOSE_FILE up -d
;;
stop)
echo "Stopping the Nginx container..."
docker-compose -f $COMPOSE_FILE down
;;
restart)
echo "Restarting the Nginx container..."
docker-compose -f $COMPOSE_FILE down
docker-compose -f $COMPOSE_FILE up -d
;;
logs)
echo "Displaying logs of the Nginx container..."
docker-compose -f $COMPOSE_FILE logs -f
;;
clean)
echo "Cleaning up: stopping and removing the container..."
docker-compose -f $COMPOSE_FILE down -v
;;
help)
show_help
;;
*)
echo "Invalid option!"
show_help
;;
esac

0 comments on commit db21cd0

Please sign in to comment.