mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-12 05:07:40 +02:00
Add Kubernetes environment detection (#4290)
Also check if we are running within a Kubernetes environment. These do not always run using Docker or Podman of course. Also renamed all the functions and variables to use `container` instead of `docker`.
This commit is contained in:

committed by
GitHub

parent
77cd5b5954
commit
569add453d
13
src/util.rs
13
src/util.rs
@ -531,14 +531,17 @@ pub fn parse_date(date: &str) -> NaiveDateTime {
|
||||
// Deployment environment methods
|
||||
//
|
||||
|
||||
/// Returns true if the program is running in Docker or Podman.
|
||||
pub fn is_running_in_docker() -> bool {
|
||||
Path::new("/.dockerenv").exists() || Path::new("/run/.containerenv").exists()
|
||||
/// Returns true if the program is running in Docker, Podman or Kubernetes.
|
||||
pub fn is_running_in_container() -> bool {
|
||||
Path::new("/.dockerenv").exists()
|
||||
|| Path::new("/run/.containerenv").exists()
|
||||
|| Path::new("/run/secrets/kubernetes.io").exists()
|
||||
|| Path::new("/var/run/secrets/kubernetes.io").exists()
|
||||
}
|
||||
|
||||
/// Simple check to determine on which docker base image vaultwarden is running.
|
||||
/// Simple check to determine on which container base image vaultwarden is running.
|
||||
/// We build images based upon Debian or Alpine, so these we check here.
|
||||
pub fn docker_base_image() -> &'static str {
|
||||
pub fn container_base_image() -> &'static str {
|
||||
if Path::new("/etc/debian_version").exists() {
|
||||
"Debian"
|
||||
} else if Path::new("/etc/alpine-release").exists() {
|
||||
|
Reference in New Issue
Block a user