Skip to content

Commit

Permalink
Dont change user for docker desktop users
Browse files Browse the repository at this point in the history
  • Loading branch information
Carbrex committed Jun 21, 2024
1 parent 86c8a98 commit 30055bc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ services:
chessground:
build:
context: docker
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
dockerfile: ui.Dockerfile
entrypoint: ["/bin/sh", "-c", "pnpm install && pnpm run compile && pnpx http-server -p 8080"]
restart: unless-stopped
Expand All @@ -133,6 +136,9 @@ services:
pgn_viewer:
build:
context: docker
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
dockerfile: ui.Dockerfile
entrypoint: ["/bin/sh", "-c", "pnpm install && pnpm run demo"]
restart: unless-stopped
Expand Down Expand Up @@ -221,6 +227,9 @@ services:
ui:
build:
context: docker
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
dockerfile: ui.Dockerfile
restart: unless-stopped
user: ${USER_ID}:${GROUP_ID}
Expand Down
8 changes: 8 additions & 0 deletions docker/ui.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ RUN corepack enable

RUN pnpm config set store-dir /.pnpm-store

ARG USER_ID
ARG GROUP_ID

RUN if [ "$USER_ID" != "1000" ] && [ "$USER_ID" != "0" ]; then \
adduser -D -u $USER_ID -G $(id -gn node) -h $(eval echo ~node) newuser; \
chown -R $USER_ID:$(id -gn node) $(eval echo ~node); \
fi

WORKDIR /app
18 changes: 14 additions & 4 deletions lila-docker
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash -e

run_setup() {
echo "USER_ID=$(id -u)" > .env
echo "GROUP_ID=$(id -g)" >> .env
write_user_id_to_env

rust_cmd setup

Expand Down Expand Up @@ -52,8 +51,7 @@ all_profiles() {
}

build_all_profiles() {
echo "USER_ID=$(id -u)" > .env
echo "GROUP_ID=$(id -g)" >> .env
write_user_id_to_env

COMPOSE_PROFILES=$(all_profiles) docker compose pull
COMPOSE_PROFILES=$(all_profiles) docker compose build
Expand Down Expand Up @@ -150,6 +148,18 @@ rust_cmd() {
load_config_to_env
}

write_user_id_to_env() {
if docker info 2>/dev/null | grep -q "Operating System: Docker Desktop"; then
echo "Running on Docker Desktop"
echo "USER_ID=0" > .env
echo "GROUP_ID=0" >> .env
else
echo "Running on Docker Engine"
echo "USER_ID=$(id -u)" > .env
echo "GROUP_ID=$(id -g)" >> .env
fi
}

load_config_to_env() {
export $(cat settings.env | xargs)
}
Expand Down

0 comments on commit 30055bc

Please sign in to comment.