Skip to content

Commit ada8c86

Browse files
[SYCL][Devops] Fix DockerFile linting issues discovered by trivy (#16290)
Linter/checker used: [trivy v0.58.0](https://github.com/aquasecurity/trivy/releases/tag/v0.58.0) 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.
1 parent d96f6db commit ada8c86

8 files changed

+26
-5
lines changed

devops/containers/ubuntu2204_base.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ COPY actions/cleanup /actions/cleanup
2929
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
3030
COPY scripts/install_drivers.sh /opt/install_drivers.sh
3131

32+
USER sycl
33+
3234
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2204_build.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null && \
2424
# Add rocm repo
2525
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.1.1 jammy main" \
2626
| tee --append /etc/apt/sources.list.d/rocm.list && \
27-
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | tee /etc/apt/preferences.d/rocm-pin-600 && \
28-
apt update
27+
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | tee /etc/apt/preferences.d/rocm-pin-600
2928
# Install the kernel driver
30-
RUN apt install -yqq rocm-dev && \
29+
RUN apt update && apt install -yqq rocm-dev && \
3130
apt-get clean && \
3231
rm -rf /var/lib/apt/lists/*
3332

@@ -42,5 +41,7 @@ RUN usermod -aG irc sycl
4241

4342
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
4443

44+
USER sycl
45+
4546
ENTRYPOINT ["/docker_entrypoint.sh"]
4647

devops/containers/ubuntu2204_intel_drivers.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ RUN --mount=type=secret,id=github_token \
2525

2626
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2727

28+
USER sycl
29+
2830
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2931

devops/containers/ubuntu2204_preinstalled.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ ADD sycl_linux.tar.gz /opt/sycl/
1010
ENV PATH /opt/sycl/bin:$PATH
1111
ENV LD_LIBRARY_PATH /opt/sycl/lib:$LD_LIBRARY_PATH
1212

13+
# By default Ubuntu sets an arbitrary UID value, that is different from host
14+
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
15+
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
16+
# 1001, that is used as default by GitHub Actions.
17+
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
18+
# Add sycl user to video/irc groups so that it can access GPU
19+
RUN usermod -aG video sycl
20+
RUN usermod -aG irc sycl
21+
22+
USER sycl
23+
1324
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
1425

devops/containers/ubuntu2404_base.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ COPY actions/cleanup /actions/cleanup
2929
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
3030
COPY scripts/install_drivers.sh /opt/install_drivers.sh
3131

32+
USER sycl
33+
3234
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2404_intel_drivers.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ RUN --mount=type=secret,id=github_token \
2525

2626
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2727

28+
USER sycl
29+
2830
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2931

devops/containers/ubuntu2404_intel_drivers_igc_dev.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ RUN --mount=type=secret,id=github_token \
2020

2121
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2222

23+
USER sycl
24+
2325
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2426

devops/scripts/docker_entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash
22

33
if [ -d "$GITHUB_WORKSPACE" ]; then
4-
chown -R sycl:sycl $GITHUB_WORKSPACE
5-
su sycl
4+
sudo chown -R sycl:sycl $GITHUB_WORKSPACE
65
fi
76

87
exec "$@"

0 commit comments

Comments
 (0)