diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2927d5c..c395fef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,8 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: write # Grant write permissions to modify repository contents steps: - uses: actions/checkout@v4 - name: Build diff --git a/Makefiles/docker.mk b/Makefiles/docker.mk index 6ccdcf8..81ad35c 100644 --- a/Makefiles/docker.mk +++ b/Makefiles/docker.mk @@ -6,9 +6,16 @@ DOCKER_HOST = docker # Specifies the context directory used for building the Docker image. DOCKER_BUILD_CONTEXT = . -# Fallback to default UID and GID if the current environment doesn't have it -DOCKER_UID ?= $(shell id -u || echo 1001) # default to 1001 if id -u fails -DOCKER_GID ?= $(shell id -g || echo 1001) # default to 1001 if id -g fails +# Check if $USER is set, if not, use "whoami" as fallback to get the username +USER_ENV ?= $(or $(USER), $(shell whoami)) + +# Use the USER_ENV variable to get the UID and GID +DOCKER_UID ?= $(shell id -u $(USER_ENV)) # Get UID based on the username +DOCKER_GID ?= $(shell id -g $(USER_ENV)) # Get GID based on the username + +# Alternatively, fallback to system's current UID and GID if USER_ENV is not set +DOCKER_UID ?= $(shell id -u) # Fallback to current user's UID if $USER_ENV fails +DOCKER_GID ?= $(shell id -g) # Fallback to current user's GID if $USER_ENV fails # Arguments to pass to the Docker command for setting user and mounting volumes. DOCKER_USER_ARG ?= --user $(DOCKER_UID):$(DOCKER_GID)