mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-11-04 04:08:20 +02:00 
			
		
		
		
	Fix persistent folder check within containers
The previous persistent folder check worked by checking if a file exists. If you used a bind-mount, then this file is not there. But when using a docker/podman volume those files are copied, and caused the container to not start. This change checks the `/proc/self/mountinfo` for a specific patern to see if the data folder is persistent or not. Fixes #2622
This commit is contained in:
		@@ -104,14 +104,6 @@ RUN touch src/main.rs
 | 
			
		||||
# hadolint ignore=DL3059
 | 
			
		||||
RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi
 | 
			
		||||
 | 
			
		||||
# Create a special empty file which we check within the application.
 | 
			
		||||
# If this file exists, then we exit Vaultwarden to prevent data loss when someone forgets to use volumes.
 | 
			
		||||
# If you really really want to use volatile storage you can set the env `I_REALLY_WANT_VOLATILE_STORAGE=true`
 | 
			
		||||
# This file should disappear if a volume is mounted on-top of this using a docker volume.
 | 
			
		||||
# We run this in the build image and copy it over, because the runtime image could be missing some executables.
 | 
			
		||||
# hadolint ignore=DL3059
 | 
			
		||||
RUN touch /vaultwarden_docker_persistent_volume_check
 | 
			
		||||
 | 
			
		||||
######################## RUNTIME IMAGE  ########################
 | 
			
		||||
# Create a new stage with a minimal image
 | 
			
		||||
# because we already have a binary built
 | 
			
		||||
@@ -153,7 +145,6 @@ EXPOSE 3012
 | 
			
		||||
# and the binary from the "build" stage to the current stage
 | 
			
		||||
WORKDIR /
 | 
			
		||||
COPY --from=vault /web-vault ./web-vault
 | 
			
		||||
COPY --from=build /vaultwarden_docker_persistent_volume_check /data/vaultwarden_docker_persistent_volume_check
 | 
			
		||||
COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/vaultwarden .
 | 
			
		||||
 | 
			
		||||
COPY docker/healthcheck.sh /healthcheck.sh
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user