Skip to content

Commit

Permalink
Merge pull request #79 from r0x0d/push-to-ghcr
Browse files Browse the repository at this point in the history
Add workflow to publish container image to ghcr
  • Loading branch information
tisnik authored Jan 16, 2025
2 parents a3b0b05 + a6f6b8c commit b89e0d3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ghcr-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Push to GHCR
on:
push:
branches: [main]
workflow_dispatch:

env:
IMAGE_NAME: ${{ github.event.repository.name }}
IMAGE_TAGS: latest ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}

jobs:
push-ghcr:
name: Build and push image
runs-on: ubuntu-22.04
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

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

- name: Install podman
run: |
sudo apt-get install podman -y
# 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: ${{ github.actor }}
password: ${{ github.token }}

- name: Wait before retrying
if: steps.push.outcome == 'failure'
run: sleep 1m

# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push_second_attempt
if: steps.push.outcome == 'failure'
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ COPY --from=lightspeed-rag-embeddings /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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MODEL := $(if $(MODEL),$(MODEL),"gpt-4o-mini")
PYTHON_REGISTRY = testpypi


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

install-tools: install-woke ## Install required utilities/tools
Expand Down

0 comments on commit b89e0d3

Please sign in to comment.