From a1dbcc67f7f8e4a59cb5e82a6aa0561f3118cd8c Mon Sep 17 00:00:00 2001 From: Evan Harvey Date: Wed, 13 Mar 2024 08:23:44 -0600 Subject: [PATCH] .github/workflows: Added ubi8.yml and docker.yml - Updated Dockerfile --- .github/workflows/docker.yml | 33 +++++++++++++++++++ .github/workflows/ubi8.yml | 64 ++++++++++++++++++++++++++++++++++++ Dockerfile | 12 +++++-- docker/centos8.repo | 6 ++++ 4 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/ubi8.yml create mode 100644 docker/centos8.repo diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..60a96fa00 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,33 @@ +name: github-DOCKER + +on: + push: + branches: + - main + + +permissions: + contents: none + +env: + UBI8_IMAGE: "ghcr.io/sandialabs/opencsp:latest-ubi8" + +jobs: + ubi8-image: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Build image + run: echo UBI8_IMAGE=$UBI8_IMAGE && docker build . --file Dockerfile --tag $UBI8_IMAGE --label "runnumber=${GITHUB_RUN_ID}" + + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Push image + run: | + echo UBI8_IMAGE=$UBI8_IMAGE + docker push $UBI8_IMAGE \ No newline at end of file diff --git a/.github/workflows/ubi8.yml b/.github/workflows/ubi8.yml new file mode 100644 index 000000000..ddf24306f --- /dev/null +++ b/.github/workflows/ubi8.yml @@ -0,0 +1,64 @@ +name: github-UBI8 + +on: + pull_request: + paths-ignore: + - '**/*.rst' + - '**/*.md' + - 'doc/**' + types: [ opened, reopened, synchronize ] + +permissions: + contents: none + +# Cancels any in progress 'workflow' associated with this PR +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + UBI8_IMAGE: "ghcr.io/sandialabs/opencsp:latest-ubi8" + +jobs: + ubi8-image: + runs-on: ubuntu-latest + permissions: write-all + steps: + - uses: actions/checkout@v4 + + - name: Build image + run: echo UBI8_IMAGE=$UBI8_IMAGE && docker build . --file Dockerfile --tag $UBI8_IMAGE --label "runnumber=${GITHUB_RUN_ID}" + + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Push image + run: | + echo UBI8_IMAGE=$UBI8_IMAGE + docker push $UBI8_IMAGE + + ubi8-ci: + needs: ubi8-image + name: ubi8-ci + runs-on: [ubuntu-latest] + permissions: + packages: read + contents: read + container: + image: ghcr.io/sandialabs/opencsp:latest-ubi8 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - name: checkout + uses: actions/checkout@v4 + with: + path: OpenCSP + + - name: pytest-cov + working-directory: OpenCSP/opencsp + run: | + python3 -m pip install -r ../requirements.txt + export PYTHONPATH=$PWD/../ + pytest --color=yes -rs -vv --cov=. --cov-report term --cov-config=.coveragerc \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 267409490..18c9f00b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,17 @@ ARG BASE_IMAGE_ARG=registry.access.redhat.com/ubi8:latest FROM ${BASE_IMAGE_ARG} +ADD docker/centos8.repo /etc/yum.repos/d/centos8.repo + +RUN rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official && yum search xvfb + RUN yum -y install python3.11 \ + python3.11-devel \ python3.11-pip \ mesa-libGL \ python3.11-tkinter \ - python3-xvfbwrapper \ - xz + xz \ + gcc # Installing ffmpeg via relies on the rpmfusion repo and SDL2 # The SDL2 yum package is not currently available in ubi8 @@ -21,4 +26,5 @@ RUN tar -xf ffmpeg-*-amd64-static.tar.xz && \ ENV PYTHONPATH=/code COPY requirements.txt /code/ -RUN python3 -m pip install -r requirements.txt \ No newline at end of file +RUN python3 -m pip install -r requirements.txt +ENV PATH=$HOME/.local/bin:$PATH \ No newline at end of file diff --git a/docker/centos8.repo b/docker/centos8.repo new file mode 100644 index 000000000..fbdf6816e --- /dev/null +++ b/docker/centos8.repo @@ -0,0 +1,6 @@ +[CentOS-8] +name=CentOS-8 +baseurl=http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/ +enabled=1 +gpgcheck=1 +gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official \ No newline at end of file