Skip to content

[CI] Add container users to video group #5101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 17 additions & 27 deletions .github/workflows/sycl_containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- sycl
paths:
- 'devops/containers/**'
pull_request:
paths:
- 'devops/containers/**'

jobs:
base_image_ubuntu2004:
Copy link
Contributor

Choose a reason for hiding this comment

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

All three jobs are the same - the only difference is the container name. Can we avoid duplication by applying re-usable workflows or matrix strategy here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is probably as far as I can go simplifying this file. Matrix builds do not support dependencies, and re-usable workflows would still require me to pass input parameters, which would be identical to what I did with actions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was aiming to avoid duplication of "push: ${{ github.event_name != 'pull_request' }}" condition.

Expand All @@ -20,21 +23,16 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- name: Build and Push Container
uses: ./devops/actions/build_container
with:
registry: ghcr.io
push: ${{ github.event_name != 'pull_request' }}
file: ubuntu2004_base
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Container
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository }}/ubuntu2004_base:${{ github.sha }}
ghcr.io/${{ github.repository }}/ubuntu2004_base:latest
context: ${{ github.workspace }}/devops
file: ${{ github.workspace }}/devops/containers/ubuntu2004_base.Dockerfile
build_image_ubuntu2004:
if: github.repository == 'intel/llvm'
name: Build Ubuntu Docker image
Expand All @@ -44,44 +42,36 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- name: Build and Push Container
uses: ./devops/actions/build_container
with:
registry: ghcr.io
push: ${{ github.event_name != 'pull_request' }}
file: ubuntu2004_build
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Container
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository }}/ubuntu2004_build:${{ github.sha }}
ghcr.io/${{ github.repository }}/ubuntu2004_build:latest
context: ${{ github.workspace }}/devops
file: ${{ github.workspace }}/devops/containers/ubuntu2004_build.Dockerfile
# This job produces a Docker container with the latest versions of Intel
# drivers, that can be found on GitHub.
drivers_image_ubuntu2004:
if: github.repository == 'intel/llvm'
name: Intel Drivers Ubuntu 20.04 Docker image
runs-on: ubuntu-latest
needs: base_image_ubuntu2004
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- name: Build and Push Container
uses: ./devops/actions/build_container
with:
registry: ghcr.io
push: ${{ github.event_name != 'pull_request' }}
file: ubuntu2004_intel_drivers
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Container
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository }}/ubuntu2004_intel_drivers:latest-${{ github.sha }}
ghcr.io/${{ github.repository }}/ubuntu2004_intel_drivers:latest
context: ${{ github.workspace }}/devops
file: ${{ github.workspace }}/devops/containers/ubuntu2004_intel_drivers.Dockerfile

42 changes: 42 additions & 0 deletions devops/actions/build_container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Build Docker container'
description: 'Build Docker container in a standard way'

inputs:
build-args:
description: "List of build-time variables"
required: false
tags:
description: "List of tags"
required: true
push:
description: "Whether to push Docker image or not"
required: false
default: false
username:
description: "Registry user name"
required: true
password:
description: "Registry user password"
required: true
file:
description: "Dockerfile"
required: true

runs:
using: "composite"
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: Build and Push Container
uses: docker/build-push-action@v2
with:
push: ${{ inputs.push }}
tags: ${{ inputs.tags }}
build-args: ${{ inputs.build_args }}
context: ${{ github.workspace }}/devops
file: ${{ github.workspace }}/devops/containers/${{ inputs.file }}.Dockerfile

2 changes: 2 additions & 0 deletions devops/containers/ubuntu2004_base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN /install.sh
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
# 1001, that is used as default by GitHub Actions.
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
# Add sycl user to video group so that it can access GPU
RUN usermod -aG video sycl

COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh

Expand Down
2 changes: 2 additions & 0 deletions devops/containers/ubuntu2004_build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RUN apt install -yqq libnuma-dev wget gnupg2 && \
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
# 1001, that is used as default by GitHub Actions.
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
# Add sycl user to video group so that it can access GPU
RUN usermod -aG video sycl

COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh

Expand Down