Skip to content

Commit 5982ebd

Browse files
committed
Add ALLOW_RUN_AS_ROOT environment variable support
1 parent 079fd1c commit 5982ebd

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Dockerfile.odin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ RUN make release PROFILE=production
3737
FROM debian:${DEBIAN_VERSION}-slim as runtime
3838
WORKDIR /apps
3939
COPY --from=builder /data/odin/target/release/odin /data/odin/target/release/huginn ./
40+
ENV ALLOW_RUN_AS_ROOT="1"
4041
ENTRYPOINT ["/apps/odin"]
4142
CMD ["--version"]

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22
services:
33
odin:
4-
image: mbround18/odin:latest
4+
image: mbround18/odin:sha-179b1b5
55
build:
66
context: .
77
dockerfile: ./Dockerfile.odin
@@ -10,7 +10,7 @@ services:
1010
valheim:
1111
depends_on:
1212
- odin
13-
image: mbround18/valheim:latest
13+
image: mbround18/valheim:sha-179b1b5
1414
environment:
1515
PORT: 2456
1616
NAME: "Created With Valheim Docker"

src/odin/utils/is_root.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
use std::env;
12
use users::{get_current_uid, get_user_by_uid};
23

34
pub fn is_root() -> bool {
5+
let bypass = env::var("ALLOW_RUN_AS_ROOT").unwrap_or(String::from("0"));
6+
if bypass.eq("1") || bypass.eq("true") {
7+
return true;
8+
}
49
let current_uid = get_current_uid();
510
match get_user_by_uid(current_uid) {
611
Some(user) => user.uid() == 0,

0 commit comments

Comments
 (0)