Skip to content

[CI] [GHA] Use non-root user in Dockerfiles#28903

Open
akashchi wants to merge 148 commits into
openvinotoolkit:masterfrom
akashchi:ci/gha/non-root-dockerfiles
Open

[CI] [GHA] Use non-root user in Dockerfiles#28903
akashchi wants to merge 148 commits into
openvinotoolkit:masterfrom
akashchi:ci/gha/non-root-dockerfiles

Conversation

@akashchi
Copy link
Copy Markdown
Contributor

Tickets:

  • 150997

@akashchi akashchi added the WIP work in progress label Feb 10, 2025
@akashchi akashchi added this to the 2025.1 milestone Feb 10, 2025
@github-actions github-actions Bot added category: CI OpenVINO public CI github_actions Pull requests that update GitHub Actions code category: dockerfiles labels Feb 10, 2025
@akashchi akashchi requested a review from mryzhov June 4, 2025 09:03
@akashchi akashchi removed the WIP work in progress label Jun 4, 2025
@akashchi akashchi marked this pull request as ready for review June 4, 2025 09:03
@akashchi akashchi requested review from a team as code owners June 4, 2025 09:03
@akashchi akashchi requested a review from akladiev June 4, 2025 09:03
Comment thread .github/dockerfiles/ov_build/fedora_29/Dockerfile Outdated
Comment thread .github/actions/openvino_provider/action.yml Outdated
Comment thread .github/dockerfiles/ov_build/fedora_29/Dockerfile
Comment thread .github/dockerfiles/ov_build/debian_10_arm/Dockerfile
Copy link
Copy Markdown
Contributor

@mryzhov mryzhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please take a look at the comments, looks like we can simplify several things

Comment thread .github/dockerfiles/ov_build/manylinux_2_28/Dockerfile
Comment thread .github/dockerfiles/ov_build/ubuntu_20_04_arm64/Dockerfile
Comment thread .github/dockerfiles/ov_build/ubuntu_20_04_x64/Dockerfile
Comment thread .github/dockerfiles/ov_build/ubuntu_20_04_x64_nvidia/Dockerfile
Comment thread .github/dockerfiles/ov_build/ubuntu_22_04_android/Dockerfile
Comment thread .github/dockerfiles/ov_test/ubuntu_22_04_x64/Dockerfile
Comment thread .github/dockerfiles/ov_test/ubuntu_24_04_x64/Dockerfile
runs-on: ubuntu-22.04
container:
image: ${{ fromJSON(needs.docker.outputs.images).ov_test.fedora_33 }}
image: fedora:33
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to lock the version of the image then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a GHA image, it is a Docker Hub image, I do not think it would be updated silently except for security updates.

Comment thread .github/workflows/job_build_linux.yml Outdated
runner: 'aks-linux-4-cores-8gb-arm'
image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04'
runner: 'ubuntu-22.04'
image: 'ubuntu:20.04'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gha image could be updated silently we need to lock the particular version

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a GHA image, it is a Docker Hub image, and it should not be updated silently except for security updates.

@akashchi akashchi requested a review from mryzhov June 6, 2025 12:40
@akashchi akashchi added the no_stale Do not mark as stale label Jun 10, 2025
@akashchi akashchi requested a review from Copilot June 11, 2025 12:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates multiple Dockerfiles to use a dedicated non-root user (runner) instead of root, improving container security. Key changes include adding environment variable definitions for USER_NAME, USER_ID, GROUP_NAME, and GROUP_ID; creating a non-root user and group via groupadd/useradd or usermod where needed; and modifying file ownership and default users accordingly.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.

File Description
.github/dockerfiles/ov_test/* Add non-root user setup for Ubuntu, Fedora, and Debian test images
.github/dockerfiles/ov_build/* Update multiple build Dockerfiles to switch to a non-root user, with some cases using usermod instead of useradd based on base image requirements
.github/dockerfiles/docker_tag Update tag identifier
Comments suppressed due to low confidence (1)

.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile:97

  • For consistency with other Dockerfiles that set ownership using '${USER_NAME}:${USER_NAME}', please verify if the group component should use ${USER_NAME} instead of ${GROUP_ID}.
RUN chown -R ${USER_NAME}:${GROUP_ID} /venv

ENV PATH="$NVM_DIR/versions/node/v${NODE_VERSION}/bin/:${PATH}"

# Change ownership of the venv directory to the non-root user
RUN chown -R ${USER_NAME}:${USER_NAME} /venv
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Since the non-root user creation and directory ownership steps are repeated across many Dockerfiles, consider centralizing this logic or standardizing the approach across files to simplify future maintenance.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: build OpenVINO cmake script / infra category: CI OpenVINO public CI category: dockerfiles category: packaging OpenVINO packaging / distribution github_actions Pull requests that update GitHub Actions code no_stale Do not mark as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants