-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][Devops] Fix DockerFile linting issues discovered by
trivy
(#…
…16411) This is a re-submit of #16290 with fixes from #16324 and some more extra changes. Issues addressed: - AVD-DS-0017 (HIGH): The instruction 'RUN <package-manager> update' should always be followed by '<package-manager> install' in the same RUN statement. See https://avd.aquasec.com/misconfig/ds017 - AVD-DS-0002 (HIGH): Specify at least 1 USER command in Dockerfile with non-root user as argument See https://avd.aquasec.com/misconfig/ds002 - AVD-DS-0002 (HIGH): Last USER command in Dockerfile should not be 'root' Issues remaining: - AVD-DS-0026 (LOW): Add HEALTHCHECK instruction in your Dockerfile See https://avd.aquasec.com/misconfig/ds026 I didn't add `HEALTHCHECK` command to our containers, because I don't know if that makes sense and which command to launch. I.e. our containers they only provide some pre-installed tools, but they don't launch any services which we could check. User creation was outlined into a separate helper script. Our containers only come with `sycl_ci` user now which requires a password to use `sudo`. However, it is still possible to get the original `sycl` user for those who uses that container locally and needs `sudo` access.
- Loading branch information
1 parent
f541207
commit 611d6d2
Showing
12 changed files
with
107 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ $# -eq 0 ]]; then | ||
# When launched without arguments, we assume that it was launched as part of | ||
# CI workflow and therefore a different kind of user is created | ||
USER_NAME=sycl_ci | ||
SET_PASSWD=true | ||
|
||
# By default Ubuntu sets an arbitrary UID value, that is different from host | ||
# system. When CI passes default UID value of 1001, some of LLVM tools fail to | ||
# discover user home directory and fail a few LIT tests. Fixes UID and GID to | ||
# 1001, that is used as default by GitHub Actions. | ||
USER_ID=1001 | ||
else | ||
if [[ "${1:-}" != "--regular" ]]; then | ||
echo "The only supported argument is --regular!" | ||
exit 1 | ||
fi | ||
USER_NAME=sycl | ||
SET_PASSWD=false | ||
|
||
# Some user id which is different from the one assigned to sycl_ci user | ||
USER_ID=1234 | ||
fi | ||
|
||
groupadd -g $USER_ID $USER_NAME && useradd $USER_NAME -u $USER_ID -g $USER_ID -m -s /bin/bash | ||
# Add user to video/irc groups so that it can access GPU | ||
usermod -aG video $USER_NAME | ||
usermod -aG irc $USER_NAME | ||
|
||
# group 109 is required for user to access PVC card. | ||
groupadd -f -g 109 render | ||
usermod -aG render $USER_NAME | ||
|
||
if [[ $SET_PASSWD == true ]]; then | ||
if [[ ! -f /run/secrets/sycl_ci_passwd ]]; then | ||
echo "Password is requested, but /run/secrets/sycl_ci_passwd doesn't exist!" | ||
exit 2 | ||
fi | ||
|
||
# Set password for user | ||
echo "$USER_NAME:$(cat /run/secrets/sycl_ci_passwd)" | chpasswd | ||
|
||
# Allow user to run as sudo, but only with password | ||
echo "$USER_NAME ALL=(ALL) PASSWD:ALL" >> /etc/sudoers | ||
else | ||
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
#!/bin/bash | ||
|
||
if [ -d "$GITHUB_WORKSPACE" ]; then | ||
chown -R sycl:sycl $GITHUB_WORKSPACE | ||
su sycl | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters