From 0c23713899c99b68c96f28ae1965e5b55bf5d518 Mon Sep 17 00:00:00 2001 From: Gormery Kombo Wanjiru Date: Tue, 27 Feb 2024 20:24:04 +0100 Subject: [PATCH] s --- .github/workflows/azure-webapps-python.yml | 86 ---------------------- .github/workflows/deploy.yml | 35 +++++++++ .github/workflows/main_ollama-docker.yml | 67 ----------------- .github/workflows/ollama-docker.yaml | 2 + setup.sh | 4 +- 5 files changed, 39 insertions(+), 155 deletions(-) delete mode 100644 .github/workflows/azure-webapps-python.yml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/main_ollama-docker.yml diff --git a/.github/workflows/azure-webapps-python.yml b/.github/workflows/azure-webapps-python.yml deleted file mode 100644 index 83000e3..0000000 --- a/.github/workflows/azure-webapps-python.yml +++ /dev/null @@ -1,86 +0,0 @@ -# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch. -# -# This workflow assumes you have already created the target Azure App Service web app. -# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask -# -# To configure this workflow: -# -# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. -# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials -# -# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. -# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret -# -# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below. -# -# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions -# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples - -name: Build and deploy Python app to Azure Web App - -env: - AZURE_WEBAPP_NAME: ollama-docker # set this to the name of your Azure Web App - PYTHON_VERSION: '3.8' # set this to the Python version to use - -on: - push: - branches: [ "main" ] - workflow_dispatch: - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python version - uses: actions/setup-python@v3.0.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - cache: 'pip' - - - name: Create and start virtual environment - run: | - python -m venv venv - source venv/bin/activate - - - name: Install dependencies - run: pip install -r requirements.txt - - # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - - - name: Upload artifact for deployment jobs - uses: actions/upload-artifact@v3 - with: - name: python-app - path: | - . - !venv/ - - deploy: - permissions: - contents: none - runs-on: ubuntu-latest - needs: build - environment: - name: 'Development' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Download artifact from build job - uses: actions/download-artifact@v3 - with: - name: python-app - path: . - - - name: 'Deploy to Azure Web App' - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: ${{ env.AZURE_WEBAPP_NAME }} - publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8f41e10 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: test-and-deploy + +on: + workflow_dispatch: + workflow_run: + workflows: ["ollama-docker"] # This triggers the deployment after ollama-docker workflow completes + types: + - completed + +permissions: + id-token: write + contents: read + +jobs: + deploy-azure: + runs-on: ubuntu-latest + steps: + - name: 'Az CLI login' + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: 'Run Azure CLI commands' + run: | + az containerapp up \ + --name my-container-app \ + --resource-group my-container-apps \ + --location centralus \ + --environment 'my-container-apps' \ + --image ${{ secrets.DOCKER_HUB_USERNAME }}/ollama-docker:latest \ # Ensure this matches your Docker Hub repo + --target-port 80 \ + --ingress external \ + --query properties.configuration.ingress.fqdn diff --git a/.github/workflows/main_ollama-docker.yml b/.github/workflows/main_ollama-docker.yml deleted file mode 100644 index 99eaace..0000000 --- a/.github/workflows/main_ollama-docker.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions -# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions - -name: Build and deploy Python app to Azure Web App - ollama-docker - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python version - uses: actions/setup-python@v1 - with: - python-version: '3.8' - - - name: Create and start virtual environment - run: | - python -m venv venv - source venv/bin/activate - - - name: Install dependencies - run: pip install -r requirements.txt - - # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - - name: Zip artifact for deployment - run: zip release.zip ./* -r - - - name: Upload artifact for deployment jobs - uses: actions/upload-artifact@v3 - with: - name: python-app - path: | - release.zip - !venv/ - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'Production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Download artifact from build job - uses: actions/download-artifact@v3 - with: - name: python-app - - - name: Unzip artifact for deployment - run: unzip release.zip - - - name: 'Deploy to Azure Web App' - uses: azure/webapps-deploy@v2 - id: deploy-to-webapp - with: - app-name: 'ollama-docker' - slot-name: 'Production' - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_3CABAB9C43C6414B8F45297710A243A4 }} diff --git a/.github/workflows/ollama-docker.yaml b/.github/workflows/ollama-docker.yaml index 342d758..789a44d 100644 --- a/.github/workflows/ollama-docker.yaml +++ b/.github/workflows/ollama-docker.yaml @@ -16,6 +16,8 @@ on: schedule: - cron: '0 0 * * 0' workflow_dispatch: + workflow_call: # Added to allow this workflow to be called by other workflows + jobs: build-and-push-images: diff --git a/setup.sh b/setup.sh index 83883f2..f2afa9d 100644 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,6 @@ # run using docker -docker build -t ollama-docker-image . -docker run --name ollama-docker-container -d -p 11434:11434 -p 8000:8000 -v $(pwd):/code ollama-docker-image +docker build -t valiantlynx/ollama-docker . +docker run --name ollama-docker-container -d -p 8000:8000 -v $(pwd):/code valiantlynx/ollama-docker:latest #connect to turborepo git subtree add --prefix=apps/ollama-docker https://github.com/valiantlynx/ollama-docker.git main --squash