diff --git a/.copier-docker-config.yaml b/.copier-docker-config.yaml index 1fe3c58..39cb5a2 100644 --- a/.copier-docker-config.yaml +++ b/.copier-docker-config.yaml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; do NOT edit manually -_commit: v0.29.3-5-gb3044be +_commit: v0.29.4-2-g7c35c83 _src_path: . app_dirname: entelecheia app_install_root: /opt diff --git a/.copier-template/.docker/{% if build_images_from_dockerfile %}Dockerfile.`{{ docker_image_variant_name }}`{% endif %}.jinja b/.copier-template/.docker/{% if build_images_from_dockerfile %}Dockerfile.`{{ docker_image_variant_name }}`{% endif %}.jinja index 8d4083e..1d15fcf 100644 --- a/.copier-template/.docker/{% if build_images_from_dockerfile %}Dockerfile.`{{ docker_image_variant_name }}`{% endif %}.jinja +++ b/.copier-template/.docker/{% if build_images_from_dockerfile %}Dockerfile.`{{ docker_image_variant_name }}`{% endif %}.jinja @@ -61,7 +61,10 @@ ENV USER_GID $ARG_USER_GID # Creates a non-root user with sudo privileges # check if user exists and if not, create user RUN if id -u $USERNAME >/dev/null 2>&1; then \ - echo "User exists"; \ + # if the current user's user id is different from the specified user id, change the user id of the current user to the specified user id + if [ "$USER_UID" -ne "$(id -u $USERNAME)" ]; then \ + usermod --uid $USER_UID --gid $USER_GID $USERNAME; \ + fi; \ else \ groupadd --gid $USER_GID $USERNAME && \ adduser --uid $USER_UID --gid $USER_GID --force-badname --disabled-password --gecos "" $USERNAME && \ @@ -103,8 +106,11 @@ RUN sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)" {%- endif %} USER root -RUN chown --recursive "${USER_UID}:${USER_GID}" "${WORKSPACE_ROOT}" -RUN chown --recursive "${USER_UID}:${USER_GID}" "${APP_INSTALL_ROOT}" +# if the user id is different from the specified user id, change the owner of the workspace to the specified user id +RUN if [ "$USER_UID" -ne "$(id -u $USERNAME)" ]; then \ + chown --recursive $USER_UID:$USER_UID $WORKSPACE_ROOT; \ + chown --recursive $USER_UID:$USER_UID $APP_INSTALL_ROOT; \ + fi USER $USERNAME # Specifies the command that will be executed when the container is run diff --git a/.copier-template/.github/workflows/{% if use_deploy_workflows %}deploy-`{{ docker_image_variant_name }}`-image.yaml{% endif %}.jinja b/.copier-template/.github/workflows/{% if use_deploy_workflows %}deploy-`{{ docker_image_variant_name }}`-image.yaml{% endif %}.jinja index ac8be15..20ebd55 100644 --- a/.copier-template/.github/workflows/{% if use_deploy_workflows %}deploy-`{{ docker_image_variant_name }}`-image.yaml{% endif %}.jinja +++ b/.copier-template/.github/workflows/{% if use_deploy_workflows %}deploy-`{{ docker_image_variant_name }}`-image.yaml{% endif %}.jinja @@ -66,6 +66,7 @@ jobs: type=raw,value=${{ env.IMAGE_VERSION }}-${{ env.IMAGE_VARIANT }} # set latest tag for docker branch type=raw,value=latest-${{ env.IMAGE_VARIANT }} + type=raw,value=latest # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. diff --git a/.docker/Dockerfile.base b/.docker/Dockerfile.base index c4cc344..e716422 100644 --- a/.docker/Dockerfile.base +++ b/.docker/Dockerfile.base @@ -59,7 +59,10 @@ ENV USER_GID $ARG_USER_GID # Creates a non-root user with sudo privileges # check if user exists and if not, create user RUN if id -u $USERNAME >/dev/null 2>&1; then \ - echo "User exists"; \ + # if the current user's user id is different from the specified user id, change the user id of the current user to the specified user id + if [ "$USER_UID" -ne "$(id -u $USERNAME)" ]; then \ + usermod --uid $USER_UID --gid $USER_GID $USERNAME; \ + fi; \ else \ groupadd --gid $USER_GID $USERNAME && \ adduser --uid $USER_UID --gid $USER_GID --force-badname --disabled-password --gecos "" $USERNAME && \ @@ -98,8 +101,11 @@ USER $USERNAME RUN sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)" USER root -RUN chown --recursive "${USER_UID}:${USER_GID}" "${WORKSPACE_ROOT}" -RUN chown --recursive "${USER_UID}:${USER_GID}" "${APP_INSTALL_ROOT}" +# if the user id is different from the specified user id, change the owner of the workspace to the specified user id +RUN if [ "$USER_UID" -ne "$(id -u $USERNAME)" ]; then \ + chown --recursive $USER_UID:$USER_UID $WORKSPACE_ROOT; \ + chown --recursive $USER_UID:$USER_UID $APP_INSTALL_ROOT; \ + fi USER $USERNAME # Specifies the command that will be executed when the container is run diff --git a/.github/workflows/deploy-base-image.yaml b/.github/workflows/deploy-base-image.yaml index 609420e..da6a224 100644 --- a/.github/workflows/deploy-base-image.yaml +++ b/.github/workflows/deploy-base-image.yaml @@ -66,6 +66,7 @@ jobs: type=raw,value=${{ env.IMAGE_VERSION }}-${{ env.IMAGE_VARIANT }} # set latest tag for docker branch type=raw,value=latest-${{ env.IMAGE_VARIANT }} + type=raw,value=latest # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.