Compare commits
	
		
			5 Commits
		
	
	
		
			1ba2739665
			...
			5afc3bfaee
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5afc3bfaee | |||
| 5323b6647f | |||
| 6dac535211 | |||
| d035f9d8e7 | |||
| dfb9a306c5 | 
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -35,6 +35,10 @@ docker-compose.yml | ||||
| # 2024-01-24 Hide static files for Hyperling.com. | ||||
| Config/Hyperling.com/files/* | ||||
|  | ||||
| # Ignore things like Config/Hyperling.com-Stage/ | ||||
| # Ignore things like "Config/Hyperling.com-Stage/"" | ||||
| *-Stage | ||||
| Stage-* | ||||
|  | ||||
| # Ignore copies of the Hugo configuration, such as "Config/Hugo-MyWebsite". | ||||
| Hugo-* | ||||
| *-Hugo | ||||
|   | ||||
| @@ -4,25 +4,30 @@ | ||||
| FROM debian:bookworm-slim | ||||
|  | ||||
| ## Setup ## | ||||
| # Cache System Dependencies | ||||
| RUN apt-get update && apt-get install -y git hugo sudo curl wget bash | ||||
| # System Dependencies | ||||
| RUN apt-get update && apt-get install -y git hugo nginx cron curl bash sudo htop | ||||
|  | ||||
| # User and Group | ||||
| RUN groupadd -r hugo && useradd -r -s /usr/bin/bash -g hugo hugo | ||||
| RUN groupadd -r hugo && useradd -r -g hugo hugo | ||||
|  | ||||
| # Directory Tree | ||||
| # Hugo Directory Tree | ||||
| RUN mkdir -pv /var/www/hugo && chown -Rv hugo:hugo /var/www/hugo | ||||
|  | ||||
| # NGINX Directory Tree | ||||
| RUN mkdir -pv /var/www/html/ && chown -Rv hugo:hugo /var/www/html/ | ||||
|  | ||||
| # Copy Cron Job to Update Git Repo | ||||
| COPY files/hugo.crontab /etc/cron.d/hugo | ||||
| COPY files/hugo.cronjob.sh /var/www/hugo/cronjob.sh | ||||
| RUN chmod +x /var/www/hugo/cronjob.sh | ||||
| RUN crontab /etc/cron.d/hugo | ||||
|  | ||||
| # Copy Start Script | ||||
| COPY files/main.sh /root/main.sh | ||||
| RUN chmod +x /root/main.sh | ||||
|  | ||||
| ## Main ## | ||||
| # Install + Run Website | ||||
| WORKDIR /var/www/hugo | ||||
| USER hugo | ||||
| CMD echo "*** Cloning Repo $REPO ***" && \ | ||||
|     cd /var/www/hugo && \ | ||||
|     rm -rfv site && \ | ||||
|     git clone --recurse-submodules $REPO site && \ | ||||
|     cd site && \ | ||||
|     mkdir -pv public && \ | ||||
|     echo "*** Starting Hugo ***" && \ | ||||
|     hugo version && \ | ||||
|     hugo server -D --noBuildLock --bind 0.0.0.0 | ||||
| WORKDIR /var/www/ | ||||
| USER root | ||||
| CMD /root/main.sh "$REPO" "$PROD" "$DEV" | ||||
|   | ||||
| @@ -9,12 +9,21 @@ services: | ||||
|       network: host | ||||
|     restart: always | ||||
|     ports: | ||||
|       - 8013:1313 | ||||
|       - 8013:80   # Production minified files served using NGINX. | ||||
|       - 1380:1380 # Development files with drafts served by Hugo Server. | ||||
|     environment: | ||||
|       - REPO=$REPO | ||||
|       - PROD=$PROD | ||||
|       - DEV=$DEV | ||||
|     healthcheck: | ||||
|       test: curl -sS http://localhost:80 || curl -sS http://localhost:1380 || exit 1 | ||||
|       interval: 1m | ||||
|       timeout: 10s | ||||
|       retries: 2 | ||||
|       start_period: 30s | ||||
|     deploy: | ||||
|       mode: global | ||||
|       resources: | ||||
|         limits: | ||||
|           cpus: '0.10' | ||||
|           memory: 32M | ||||
|           memory: 64M | ||||
|   | ||||
| @@ -9,3 +9,13 @@ COMPOSE_BAKE=true | ||||
| ## Git Website Repository | ||||
| # | ||||
| REPO=https://git.hyperling.com/me/hugo-jackanope | ||||
|  | ||||
| # | ||||
| ## Web Environments | ||||
| # Please use values YES/TRUE and NO/FALSE. | ||||
|  | ||||
| # Whether to start NGINX | ||||
| PROD=YES | ||||
|  | ||||
| # Whether to start Hugo Server | ||||
| DEV=NO | ||||
|   | ||||
							
								
								
									
										10
									
								
								Config/HugoExample/files/hugo.cronjob.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								Config/HugoExample/files/hugo.cronjob.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| cd /var/www/hugo/site | ||||
|  | ||||
| git pull | ||||
|  | ||||
| hugo --gc --minify | ||||
|  | ||||
| rm -rfv /var/www/html/* | ||||
| cp -rfv public/* /var/www/html/ | ||||
							
								
								
									
										1
									
								
								Config/HugoExample/files/hugo.crontab
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Config/HugoExample/files/hugo.crontab
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| * * * * * hugo /var/www/hugo/cronjob.sh | ||||
							
								
								
									
										58
									
								
								Config/HugoExample/files/main.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								Config/HugoExample/files/main.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| REPO="$1" | ||||
| echo "REPO=$REPO" | ||||
|  | ||||
| PROD="$2" | ||||
| typeset -u PROD | ||||
| echo "PROD=$PROD" | ||||
|  | ||||
| DEV="$3" | ||||
| typeset -u DEV | ||||
| echo "DEV=$DEV" | ||||
|  | ||||
| echo "*** Creating Git Repo ***" | ||||
| sudo -u hugo git clone --recurse-submodules $REPO /var/www/hugo/site | ||||
|  | ||||
| echo "*** Copying Static Files to NGINX ***" | ||||
| sudo -u hugo /var/www/hugo/cronjob.sh | ||||
|  | ||||
| echo "*** Starting Cron ***" | ||||
| service cron start | ||||
|  | ||||
| if [[ "$PROD" == "Y"* || "$PROD" == "T"*  ]]; then | ||||
| 	echo "*** Starting Production Server Loop ***" | ||||
|  | ||||
| 	while true; do | ||||
| 		curl -sS http://localhost:80 > /dev/null || { | ||||
| 			echo "* Prod server not detected, starting..." | ||||
| 			service nginx start | ||||
| 		} | ||||
| 		sleep 15 | ||||
| 	done & | ||||
|  | ||||
| 	cd /var/log/nginx | ||||
| 	tail -f access.log error.log & | ||||
| fi | ||||
|  | ||||
| if [[ "$DEV" == "Y"* || "$DEV" == "T"* ]]; then | ||||
| 	echo "*** Starting Development Server Loop ***" | ||||
|  | ||||
| 	while true; do | ||||
| 		curl -sS http://localhost:1380 > /dev/null || { | ||||
| 			echo "* Dev server not detected, starting..." | ||||
| 			cd /var/www/hugo/site | ||||
| 			killall hugo 2>/dev/null | ||||
| 			sudo -u hugo hugo server -D --noBuildLock --bind 0.0.0.0 -p 1380 & | ||||
| 		} | ||||
| 		sleep 30 | ||||
| 	done & | ||||
| fi | ||||
|  | ||||
| cd | ||||
|  | ||||
| echo "*** Finished $0 ***" | ||||
|  | ||||
| wait -n | ||||
|  | ||||
| exit $? | ||||
		Reference in New Issue
	
	Block a user