Skip to content

Commit

Permalink
Add simple pipeline to install dependencies and build a docker
Browse files Browse the repository at this point in the history
image for Nvidia and Intel HW.
  • Loading branch information
sobomax committed Jul 18, 2024
1 parent 0898cf6 commit 328d809
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This is a basic workflow to help you get started with Actions

name: Build & Publush

# Controls when the action will run.
on:
# Triggers the workflow on all push or pull request events
push:
pull_request:

release:
types: [created]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

schedule:
- cron: "0 0 * * *"

# added using https://github.com/step-security/secure-repo
permissions:
contents: read

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Docker:
name: Build&Push to DockerHub
if: (github.event_name == 'push' || github.event_name == 'pull_request')
runs-on: ubuntu-latest
env:
DOCKER_REPO: 'sippylabs/infernos'
BASE_IMAGE: 'ubuntu:24.10'
PYTHON_VER: '3.11'
CONDA_MAINENV: 'Infernos'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
PYTHON_VER=${{ env.PYTHON_VER }}
CONDA_MAINENV=${{ env.CONDA_MAINENV }}
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
25 changes: 25 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG BASE_IMAGE=ubuntu:24.10
FROM $BASE_IMAGE AS build
LABEL maintainer="Maksym Sobolyev <[email protected]>"

USER root

ARG PYTHON_VER
ARG CONDA_MAINENV

# Set Environment Variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_VER=${PYTHON_VER}
ENV CONDA_MAINENV=${CONDA_MAINENV}

# Build & install everything
WORKDIR /tmp
RUN apt-get update
RUN apt-get install --no-install-recommends -y git lsb-release ca-certificates && apt-get clean
COPY docker/install_conda.sh .
RUN ./install_conda.sh
COPY docker/install_requirements.sh requirements.txt .
RUN ./install_requirements.sh

COPY --link --exclude=.git --exclude=.github . /Infernos
WORKDIR /Infernos
15 changes: 15 additions & 0 deletions docker/install_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e
set -x

apt-get install --no-install-recommends -y curl gpg
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > /tmp/conda.gpg
install -o root -g root -m 644 /tmp/conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg
rm /tmp/conda.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list

apt update
apt-get install --no-install-recommends -y conda
apt-get clean
19 changes: 19 additions & 0 deletions docker/install_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -e
set -x

PYTHON_CMD="python${PYTHON_VER}"
DEV_PKGS="gcc g++ libc6-dev cmake pkg-config make"

apt-get install --no-install-recommends -y ${DEV_PKGS}
. /opt/conda/etc/profile.d/conda.sh
conda create -y --name "${CONDA_MAINENV}" python=${PYTHON_VER}
conda activate "${CONDA_MAINENV}"
conda install -y pip
${PYTHON_CMD} -m pip install -U -r requirements.txt
apt-get remove -y ${DEV_PKGS}
apt-get autoremove -y
apt-get clean
rm -r ~/.cache
mkdir ~/.cache

0 comments on commit 328d809

Please sign in to comment.