-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6d0bd9
commit db21cd0
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |