mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-30 18:23:35 -04:00 
			
		
		
		
	feat: added gosu & updated run.sh to switch to the dedicated user (#1395)
Co-authored-by: Maka0 <360614-Maka0@users.noreply.gitlab.com>
This commit is contained in:
		
							parent
							
								
									7ce02c31d5
								
							
						
					
					
						commit
						a7c6e89dfa
					
				| @ -97,7 +97,7 @@ ENV GIT_COMMIT_HASH=$COMMIT | ||||
| # curl for used by healthcheck | ||||
| RUN apt-get update \ | ||||
|     && apt-get install --no-install-recommends -y \ | ||||
|     curl \ | ||||
|     curl gosu \ | ||||
|     && apt-get autoremove \ | ||||
|     && rm -rf /var/lib/apt/lists/* | ||||
| 
 | ||||
|  | ||||
| @ -12,17 +12,28 @@ PGID=${PGID:-911} | ||||
| add_user() { | ||||
|     groupmod -o -g "$PGID" abc | ||||
|     usermod -o -u "$PUID" abc | ||||
| } | ||||
| 
 | ||||
| change_user() { | ||||
|     # If container is started as root then create a new user and switch to it | ||||
|     if [ "$(id -u)" = "0" ]; then | ||||
|         add_user | ||||
|         chown -R $PUID:$PGID /app | ||||
| 
 | ||||
|         echo "Switching to dedicated user" | ||||
|         exec gosu $PUID "$BASH_SOURCE" "$@" | ||||
|     elif [ "$(id -u)" = $PUID ]; then | ||||
|         echo " | ||||
|     User uid:    $(id -u abc) | ||||
|     User gid:    $(id -g abc) | ||||
|         User uid:    $PUID | ||||
|         User gid:    $PGID | ||||
|         " | ||||
|     chown -R abc:abc /app | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| init() { | ||||
|     # $MEALIE_HOME directory | ||||
|     cd /app | ||||
| 
 | ||||
|     # Activate our virtual environment here | ||||
|     . /opt/pysetup/.venv/bin/activate | ||||
| 
 | ||||
| @ -45,7 +56,8 @@ if [ "$ARG1" == "reload" ]; then | ||||
| else | ||||
|     echo "Production" | ||||
| 
 | ||||
|     add_user | ||||
|     change_user | ||||
| 
 | ||||
|     init | ||||
| 
 | ||||
|     # Start API | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user