mirror of
				https://ceregatti.org/git/daniel/dayzdockerserver.git
				synced 2025-10-30 21:13:30 +00:00 
			
		
		
		
	Switch from CMD to ENTRYPOINT, then use exec in both start.sh scripts, so process id 1 can be the process it needs to be, as this is what gets SIGTERM on docker compose down.
We now get a .bashrc by default, so switch the logic to detecting the custom PS1 before putting it in .bashrc. Account for a directory that steamcmd expects.
This commit is contained in:
		
							parent
							
								
									f153f3db18
								
							
						
					
					
						commit
						4c09ef752c
					
				
					 5 changed files with 22 additions and 9 deletions
				
			
		|  | @ -54,4 +54,4 @@ USER user | ||||||
| WORKDIR /home/user | WORKDIR /home/user | ||||||
| 
 | 
 | ||||||
| # Run the server. | # Run the server. | ||||||
| CMD ["start.sh"] | ENTRYPOINT ["start.sh"] | ||||||
|  |  | ||||||
|  | @ -242,7 +242,7 @@ mergexml(){ | ||||||
| # Start the server in the foreground | # Start the server in the foreground | ||||||
| start(){ | start(){ | ||||||
| 	# Ensure mpmissions has at least one map. If not, copy it from the local read-only volume that stores pristine mpmissons directories | 	# Ensure mpmissions has at least one map. If not, copy it from the local read-only volume that stores pristine mpmissons directories | ||||||
| 	if [ ! -d "${MPMISSIONS}/${MAP}" ] | 	if [ ! -d "${MPMISSIONS}/${MAP}" ] && [ -d "/mpmissions/${MAP}" ] | ||||||
| 	then | 	then | ||||||
| 		echo | 		echo | ||||||
| 		echo "Performing one-time copy of ${MAP} mpmissions..." | 		echo "Performing one-time copy of ${MAP} mpmissions..." | ||||||
|  | @ -253,7 +253,14 @@ start(){ | ||||||
| 	if [[ ${DEVELOPMENT} = "1" ]] | 	if [[ ${DEVELOPMENT} = "1" ]] | ||||||
| 	then | 	then | ||||||
| 		echo "DEVELOPMENT mode, blocking. Unset DEVELOPMENT in the current environment to run the server." | 		echo "DEVELOPMENT mode, blocking. Unset DEVELOPMENT in the current environment to run the server." | ||||||
| 		tail -f /dev/null | 		trap ' | ||||||
|  | 			echo "Caught SIGTERM/SIGINT..." | ||||||
|  | 			exit 0 | ||||||
|  | 		' SIGTERM SIGINT | ||||||
|  | 		while true | ||||||
|  | 		do | ||||||
|  | 			sleep 1 | ||||||
|  | 		done | ||||||
| 		exit 0 | 		exit 0 | ||||||
| 	fi | 	fi | ||||||
| 	# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions. | 	# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions. | ||||||
|  |  | ||||||
|  | @ -8,4 +8,4 @@ EOF | ||||||
| 
 | 
 | ||||||
| # Start the server. | # Start the server. | ||||||
| # If the DEVELOPMENT environment variable is set to 1, the container will just block and not start the server. | # If the DEVELOPMENT environment variable is set to 1, the container will just block and not start the server. | ||||||
| dz start | exec dz start | ||||||
|  |  | ||||||
|  | @ -81,4 +81,4 @@ USER user | ||||||
| WORKDIR /home/user | WORKDIR /home/user | ||||||
| 
 | 
 | ||||||
| # Run the web server | # Run the web server | ||||||
| CMD ["start.sh"] | ENTRYPOINT ["start.sh"] | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								web/start.sh
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								web/start.sh
									
										
									
									
									
								
							|  | @ -1,15 +1,21 @@ | ||||||
| #!/usr/bin/env bash | #!/usr/bin/env bash | ||||||
| 
 | 
 | ||||||
| # Set PS1 so we know we're in the container | # Set PS1 so we know we're in the container | ||||||
| if ! [ -f .bashrc ] | if ! echo .bashrc | grep -q "dz-web" | ||||||
| then | then | ||||||
| 	echo "Creating .bashrc..." | 	echo "Adding PS1 to .bashrc..." | ||||||
| 	cat > .bashrc <<EOF | 	cat >> .bashrc <<EOF | ||||||
| alias ls='ls --color' | alias ls='ls --color' | ||||||
| export PS1="${debian_chroot:+($debian_chroot)}\u@dz-web:\w\$ " | export PS1="${debian_chroot:+($debian_chroot)}\u@dz-web:\w\$ " | ||||||
| EOF | EOF | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | # Shut steamcmd up | ||||||
|  | if ! [ -d ${HOME}/.steam ] | ||||||
|  | then | ||||||
|  | 	mkdir -p ${HOME}/.steam | ||||||
|  | fi | ||||||
|  | 
 | ||||||
| cd /web | cd /web | ||||||
| npm i | npm i | ||||||
| export DEBUG='express:*' | export DEBUG='express:*' | ||||||
|  | @ -17,4 +23,4 @@ npx nodemon web.js & | ||||||
| 
 | 
 | ||||||
| cd docroot | cd docroot | ||||||
| npm i | npm i | ||||||
| npm run dev | exec npm run dev | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Daniel Ceregatti
						Daniel Ceregatti