mirror of
				https://git.seedno.de/seednode/docker-nginx-js-challenge.git
				synced 2025-11-04 09:36:53 +00:00 
			
		
		
		
	Updated script to allow latest tag
This commit is contained in:
		
							parent
							
								
									fc48c7e80a
								
							
						
					
					
						commit
						12961205d9
					
				
							
								
								
									
										19
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								build.sh
									
									
									
									
									
								
							@ -14,23 +14,28 @@ registry="${REGISTRY:-local}"
 | 
				
			|||||||
nginx_mainline="$(curl -s 'http://nginx.org/download/' | grep -oP 'href="nginx-\K[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -rn -k1,1 -k2,2 -k3,3 | head -1)"
 | 
					nginx_mainline="$(curl -s 'http://nginx.org/download/' | grep -oP 'href="nginx-\K[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -rn -k1,1 -k2,2 -k3,3 | head -1)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if no version is specified, use the mainline version
 | 
					# if no version is specified, use the mainline version
 | 
				
			||||||
nginx_version="${1:-$nginx_mainline}"
 | 
					image_version="${1:-$nginx_mainline}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# set image name
 | 
				
			||||||
 | 
					image_name="nginx-js-challenge"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# pass core count into container for build process
 | 
					# pass core count into container for build process
 | 
				
			||||||
core_count="$(nproc)"
 | 
					core_count="$(nproc)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if no arguments are passed, display usage info and exit
 | 
					# if no arguments are passed, display usage info and exit
 | 
				
			||||||
if [ "$#" -ne 1 ]; then
 | 
					if [ "$#" -ne 1 ]; then
 | 
				
			||||||
	echo "No nginx version provided. Falling back to mainline version $nginx_version."
 | 
					  echo "No nginx version provided. Falling back to mainline version ${image_version}."
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# create docker image
 | 
					# create docker image
 | 
				
			||||||
docker build --build-arg NGINX_VER="$nginx_version" \
 | 
					docker build --build-arg NGINX_VER="${image_version}" \
 | 
				
			||||||
             --build-arg CORE_COUNT="$core_count" \
 | 
					             --build-arg CORE_COUNT="${core_count}" \
 | 
				
			||||||
             -t "$registry"/nginx-js-challenge:"$nginx_version" \
 | 
					             -t "${registry}/${image_name}:${image_version}" \
 | 
				
			||||||
 | 
					             $(if [ "${LATEST}" == "yes" ]; then echo "-t ${registry}/${image_name}:latest"; fi) \
 | 
				
			||||||
             -f Dockerfile .
 | 
					             -f Dockerfile .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if a registry is specified, push to it
 | 
					# if a registry is specified, push to it
 | 
				
			||||||
if [ "$registry" != "local" ]; then
 | 
					if [ "${registry}" != "local" ]; then
 | 
				
			||||||
  docker push "$registry"/nginx-js-challenge:"$nginx_version"
 | 
					  docker push "${registry}/${image_name}:${image_version}"
 | 
				
			||||||
 | 
					  $(if [ "${LATEST}" == "yes" ]; then echo "docker push ${registry}/${image_name}:latest"; fi)
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user