Skip to content

Commit

Permalink
Add workflow to publish container image to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0d committed Oct 28, 2024
1 parent f64851e commit 7204e21
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/ghcr-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow will perform a test whenever there
# is some change in code done to ensure that the changes
# are not buggy and we are getting the desired output.
name: Push to GHCR
on:
push:
branches: [main, push-to-ghcr]
workflow_dispatch:

env:
IMAGE_NAME: ${{ github.event.repository.name }}
IMAGE_TAGS: latest ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
REDHAT_IMAGE_REGISTRY: registry.redhat.io

jobs:
push-ghcr:
name: Build and push image
runs-on: ubuntu-22.04
strategy:
fail-fast: false

steps:
# Checkout push-to-registry action github repository
- name: Checkout Push to Registry action
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Python version
run: python --version

- name: Install podman
run: |
sudo apt-get install podman -y
- name: Log in to ${{ env.REDHAT_IMAGE_REGISTRY }}
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: ${{ env.REDHAT_IMAGE_REGISTRY }}

# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
oci: true
containerfiles: |
./Containerfile
# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ COPY --from=lightspeed-rag-content /rag/embeddings_model ./embeddings_model

# Add explicit files and directories
# (avoid accidental inclusion of local directories or env files or credentials)
COPY runner.py requirements.txt ./
COPY runner.py pyproject.toml LICENSE README.md ./

RUN pip3.11 install --no-cache-dir -r requirements.txt
RUN pip3.11 install --no-cache-dir .

COPY ols ./ols

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SUITE_ID := $(if $(SUITE_ID),$(SUITE_ID),"nosuite")
PROVIDER := $(if $(PROVIDER),$(PROVIDER),"openai")
MODEL := $(if $(MODEL),$(MODEL),"gpt-3.5-turbo")

images: requirements.txt ## Build container images
images: ## Build container images
scripts/build-container.sh

install-tools: install-woke ## Install required utilities/tools
Expand Down Expand Up @@ -113,6 +113,7 @@ schema: ## Generate OpenAPI schema file

requirements.txt: pyproject.toml pdm.lock ## Generate requirements.txt file containing hashes for all non-devel packages
pdm export --prod --format requirements --output requirements.txt
./scripts/generate_packages_to_prefetch.py

verify-packages-completeness: requirements.txt ## Verify that requirements.txt file contains complete list of packages
pip download -d /tmp/ --use-pep517 --verbose -r requirements.txt
Expand All @@ -124,6 +125,7 @@ get-rag: ## Download a copy of the RAG embedding model and vector database
podman cp tmp-rag-container:/rag/embeddings_model embeddings_model
podman rm tmp-rag-container


help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dev = [
"reportportal-client==5.5.6",
"pytest-reportportal==5.4.1",
"pytest-benchmark[histogram]>=4.0.0",
"pip-tools==7.4.1"
]

# The following section is needed only for torch[cpu] variant on Linux,
Expand Down

0 comments on commit 7204e21

Please sign in to comment.