Skip to content

Commit cd722fc

Browse files
authored
[CI] Add container users to video group (#5101)
Accessing `/dev/dri` device (GPU) requires user to be in `video` group. Change containers to include `sycl` user into the group. Also change workflow to build containers in pre-commit without pushing to the registry to make sure containers are still buildable.
1 parent b0f0f0b commit cd722fc

File tree

4 files changed

+63
-27
lines changed

4 files changed

+63
-27
lines changed

.github/workflows/sycl_containers.yaml

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- sycl
1010
paths:
1111
- 'devops/containers/**'
12+
pull_request:
13+
paths:
14+
- 'devops/containers/**'
1215

1316
jobs:
1417
base_image_ubuntu2004:
@@ -20,21 +23,16 @@ jobs:
2023
uses: actions/checkout@v2
2124
with:
2225
fetch-depth: 2
23-
- name: Login to GitHub Container Registry
24-
uses: docker/login-action@v1
26+
- name: Build and Push Container
27+
uses: ./devops/actions/build_container
2528
with:
26-
registry: ghcr.io
29+
push: ${{ github.event_name != 'pull_request' }}
30+
file: ubuntu2004_base
2731
username: ${{ github.repository_owner }}
2832
password: ${{ secrets.GITHUB_TOKEN }}
29-
- name: Build and Push Container
30-
uses: docker/build-push-action@v2
31-
with:
32-
push: true
3333
tags: |
3434
ghcr.io/${{ github.repository }}/ubuntu2004_base:${{ github.sha }}
3535
ghcr.io/${{ github.repository }}/ubuntu2004_base:latest
36-
context: ${{ github.workspace }}/devops
37-
file: ${{ github.workspace }}/devops/containers/ubuntu2004_base.Dockerfile
3836
build_image_ubuntu2004:
3937
if: github.repository == 'intel/llvm'
4038
name: Build Ubuntu Docker image
@@ -44,44 +42,36 @@ jobs:
4442
uses: actions/checkout@v2
4543
with:
4644
fetch-depth: 2
47-
- name: Login to GitHub Container Registry
48-
uses: docker/login-action@v1
45+
- name: Build and Push Container
46+
uses: ./devops/actions/build_container
4947
with:
50-
registry: ghcr.io
48+
push: ${{ github.event_name != 'pull_request' }}
49+
file: ubuntu2004_build
5150
username: ${{ github.repository_owner }}
5251
password: ${{ secrets.GITHUB_TOKEN }}
53-
- name: Build and Push Container
54-
uses: docker/build-push-action@v2
55-
with:
56-
push: true
5752
tags: |
5853
ghcr.io/${{ github.repository }}/ubuntu2004_build:${{ github.sha }}
5954
ghcr.io/${{ github.repository }}/ubuntu2004_build:latest
60-
context: ${{ github.workspace }}/devops
61-
file: ${{ github.workspace }}/devops/containers/ubuntu2004_build.Dockerfile
6255
# This job produces a Docker container with the latest versions of Intel
6356
# drivers, that can be found on GitHub.
6457
drivers_image_ubuntu2004:
6558
if: github.repository == 'intel/llvm'
6659
name: Intel Drivers Ubuntu 20.04 Docker image
6760
runs-on: ubuntu-latest
61+
needs: base_image_ubuntu2004
6862
steps:
6963
- name: Checkout
7064
uses: actions/checkout@v2
7165
with:
7266
fetch-depth: 2
73-
- name: Login to GitHub Container Registry
74-
uses: docker/login-action@v1
67+
- name: Build and Push Container
68+
uses: ./devops/actions/build_container
7569
with:
76-
registry: ghcr.io
70+
push: ${{ github.event_name != 'pull_request' }}
71+
file: ubuntu2004_intel_drivers
7772
username: ${{ github.repository_owner }}
7873
password: ${{ secrets.GITHUB_TOKEN }}
79-
- name: Build and Push Container
80-
uses: docker/build-push-action@v2
81-
with:
82-
push: true
8374
tags: |
8475
ghcr.io/${{ github.repository }}/ubuntu2004_intel_drivers:latest-${{ github.sha }}
8576
ghcr.io/${{ github.repository }}/ubuntu2004_intel_drivers:latest
86-
context: ${{ github.workspace }}/devops
87-
file: ${{ github.workspace }}/devops/containers/ubuntu2004_intel_drivers.Dockerfile
77+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Build Docker container'
2+
description: 'Build Docker container in a standard way'
3+
4+
inputs:
5+
build-args:
6+
description: "List of build-time variables"
7+
required: false
8+
tags:
9+
description: "List of tags"
10+
required: true
11+
push:
12+
description: "Whether to push Docker image or not"
13+
required: false
14+
default: false
15+
username:
16+
description: "Registry user name"
17+
required: true
18+
password:
19+
description: "Registry user password"
20+
required: true
21+
file:
22+
description: "Dockerfile"
23+
required: true
24+
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Login to GitHub Container Registry
29+
uses: docker/login-action@v1
30+
with:
31+
registry: ghcr.io
32+
username: ${{ inputs.username }}
33+
password: ${{ inputs.password }}
34+
- name: Build and Push Container
35+
uses: docker/build-push-action@v2
36+
with:
37+
push: ${{ inputs.push }}
38+
tags: ${{ inputs.tags }}
39+
build-args: ${{ inputs.build_args }}
40+
context: ${{ github.workspace }}/devops
41+
file: ${{ github.workspace }}/devops/containers/${{ inputs.file }}.Dockerfile
42+

devops/containers/ubuntu2004_base.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN /install.sh
1313
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
1414
# 1001, that is used as default by GitHub Actions.
1515
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
16+
# Add sycl user to video group so that it can access GPU
17+
RUN usermod -aG video sycl
1618

1719
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
1820

devops/containers/ubuntu2004_build.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ RUN apt install -yqq libnuma-dev wget gnupg2 && \
2222
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
2323
# 1001, that is used as default by GitHub Actions.
2424
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
25+
# Add sycl user to video group so that it can access GPU
26+
RUN usermod -aG video sycl
2527

2628
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
2729

0 commit comments

Comments
 (0)