From 1ff1cf4f2e2589b8b41eaafed9eb3c9db6c128d5 Mon Sep 17 00:00:00 2001 From: Lorenzo Venerandi Date: Fri, 21 Feb 2025 01:17:48 +0100 Subject: [PATCH] fixed permission bug --- src/__init__.py | 2 +- src/wasm_builder/build.py | 7 ++++++- src/wasm_builder/docker/build.Dockerfile | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index 658c85b..b977c55 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -13,7 +13,7 @@ class Pelato: def setup_vars(self): - load_dotenv() + load_dotenv(override=True) self.registry_url = os.getenv('REGISTRY_URL') self.reg_user = os.getenv('REGISTRY_USER') diff --git a/src/wasm_builder/build.py b/src/wasm_builder/build.py index a7c2a4e..0ecba9e 100644 --- a/src/wasm_builder/build.py +++ b/src/wasm_builder/build.py @@ -70,13 +70,18 @@ def __build_wasm(task_dir, client, reg_user, reg_pass, detached, wait_list): oci_url = wadm['spec']['components'][0]['properties']['image'] name = wadm['spec']['components'][0]['name'] + '-build' + uid = os.getuid() + gid = os.getgid() + # Build the wasm module print(f" - Building WASM module {oci_url}") container = client.containers.run( "wash-build-image:latest", environment=[f'REGISTRY={oci_url}', f'WASH_REG_USER={reg_user}', - f'WASH_REG_PASSWORD={reg_pass}'], + f'WASH_REG_PASSWORD={reg_pass}', + f'HOST_UID={uid}', + f'HOST_GID={gid}'], volumes={path: {'bind': '/app', 'mode': 'rw'}}, remove=True, detach=True, diff --git a/src/wasm_builder/docker/build.Dockerfile b/src/wasm_builder/docker/build.Dockerfile index 94542c7..5ffb58d 100644 --- a/src/wasm_builder/docker/build.Dockerfile +++ b/src/wasm_builder/docker/build.Dockerfile @@ -48,4 +48,4 @@ RUN mkdir /app WORKDIR /app # Install go dependencies, build the wasm module, push it to the registry -CMD ["sh", "-c", "go env -w GOFLAGS=-buildvcs=false && go mod download && go mod verify && wash build && wash push $REGISTRY build/*.wasm"] \ No newline at end of file +CMD ["sh", "-c", "go env -w GOFLAGS=-buildvcs=false && go mod download && go mod verify && wash build && wash push $REGISTRY build/*.wasm && chown -R ${HOST_UID}:${HOST_GID} ."] \ No newline at end of file