2023-02-15 01:53:35 +00:00
|
|
|
name: dockerize
|
2022-01-29 21:31:27 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2023-02-15 01:53:35 +00:00
|
|
|
tags:
|
|
|
|
- "*"
|
2022-01-29 21:31:27 +00:00
|
|
|
branches:
|
|
|
|
- master
|
2022-07-31 23:30:23 +00:00
|
|
|
paths:
|
2023-02-14 20:50:51 +00:00
|
|
|
- src/khoj/**
|
2024-06-22 14:42:41 +00:00
|
|
|
- src/interface/web/**
|
2023-02-16 09:12:04 +00:00
|
|
|
- pyproject.toml
|
2022-07-31 23:30:23 +00:00
|
|
|
- Dockerfile
|
2023-12-22 10:52:42 +00:00
|
|
|
- prod.Dockerfile
|
2022-07-31 23:30:23 +00:00
|
|
|
- docker-compose.yml
|
2023-02-15 01:53:35 +00:00
|
|
|
- .github/workflows/dockerize.yml
|
2022-09-15 17:28:41 +00:00
|
|
|
workflow_dispatch:
|
2023-12-22 10:52:42 +00:00
|
|
|
inputs:
|
|
|
|
tag:
|
|
|
|
description: 'Docker image tag'
|
|
|
|
default: 'dev'
|
|
|
|
khoj:
|
|
|
|
description: 'Build Khoj docker image'
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
khoj-cloud:
|
|
|
|
description: 'Build Khoj cloud docker image'
|
|
|
|
type: boolean
|
|
|
|
default: true
|
2022-09-15 17:28:41 +00:00
|
|
|
|
|
|
|
env:
|
2023-12-22 10:52:42 +00:00
|
|
|
# Tag Image with tag name on release
|
|
|
|
# else with user specified tag (default 'dev') if triggered via workflow
|
2024-06-22 14:42:41 +00:00
|
|
|
# else with run_id if triggered via a pull request
|
2023-12-22 10:52:42 +00:00
|
|
|
# else with 'pre' (if push to master)
|
2024-06-22 15:41:25 +00:00
|
|
|
DOCKER_IMAGE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || github.event_name == 'workflow_dispatch' && github.event.inputs.tag || 'pre' }}
|
2022-01-29 21:31:27 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-01-29 22:48:52 +00:00
|
|
|
build:
|
2023-12-22 10:52:42 +00:00
|
|
|
name: Publish Khoj Docker Images
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-11-29 03:31:34 +00:00
|
|
|
include:
|
|
|
|
- image: 'local'
|
|
|
|
platform: linux/amd64
|
|
|
|
runner: ubuntu-latest
|
|
|
|
- image: 'local'
|
|
|
|
platform: linux/arm64
|
|
|
|
runner: ubuntu-linux-arm64
|
|
|
|
- image: 'cloud'
|
|
|
|
platform: linux/amd64
|
|
|
|
runner: ubuntu-latest
|
2024-12-11 05:07:18 +00:00
|
|
|
- image: 'cloud'
|
|
|
|
platform: linux/arm64
|
|
|
|
runner: ubuntu-linux-arm64
|
2024-11-29 03:31:34 +00:00
|
|
|
runs-on: ${{ matrix.runner }}
|
2022-01-29 21:31:27 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
2023-02-18 00:14:46 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-12-22 10:52:42 +00:00
|
|
|
with:
|
|
|
|
# Get all history to correctly infer Khoj version using hatch
|
|
|
|
fetch-depth: 0
|
2022-01-29 21:31:27 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2023-02-18 00:14:46 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-01-29 21:31:27 +00:00
|
|
|
|
|
|
|
- name: Login to GitHub Container Registry
|
2023-02-18 00:14:46 +00:00
|
|
|
uses: docker/login-action@v2
|
2022-01-29 21:31:27 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.PAT }}
|
|
|
|
|
2023-12-21 11:46:05 +00:00
|
|
|
- name: Get App Version
|
|
|
|
id: hatch
|
|
|
|
run: echo "version=$(pipx run hatch version)" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-06 18:07:51 +00:00
|
|
|
- name: 🧹 Delete huge unnecessary tools folder
|
|
|
|
run: rm -rf /opt/hostedtoolcache
|
|
|
|
|
2023-03-01 16:56:39 +00:00
|
|
|
- name: 📦 Build and Push Docker Image
|
2024-11-24 21:10:17 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2023-12-22 10:52:42 +00:00
|
|
|
if: (matrix.image == 'local' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj == 'true' || (matrix.image == 'local' && github.event_name == 'push')
|
2022-01-29 21:31:27 +00:00
|
|
|
with:
|
|
|
|
context: .
|
2022-07-04 18:01:59 +00:00
|
|
|
file: Dockerfile
|
2022-01-29 21:31:27 +00:00
|
|
|
push: true
|
2023-12-21 11:59:37 +00:00
|
|
|
tags: |
|
2024-12-11 06:55:33 +00:00
|
|
|
ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
|
2023-12-22 10:52:42 +00:00
|
|
|
build-args: |
|
|
|
|
VERSION=${{ steps.hatch.outputs.version }}
|
|
|
|
PORT=42110
|
2024-11-25 06:44:41 +00:00
|
|
|
cache-from: type=gha,scope=${{ matrix.image }}-${{ matrix.platform }}
|
|
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.image }}-${{ matrix.platform}}
|
2024-11-29 03:14:06 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.description=Khoj AI - Your second brain powered by LLMs and Neural Search
|
|
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
2023-12-22 10:52:42 +00:00
|
|
|
|
|
|
|
- name: 📦️⛅️ Build and Push Cloud Docker Image
|
2024-11-24 21:10:17 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2023-12-22 10:52:42 +00:00
|
|
|
if: (matrix.image == 'cloud' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj-cloud == 'true' || (matrix.image == 'cloud' && github.event_name == 'push')
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: prod.Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: |
|
2024-12-11 06:55:33 +00:00
|
|
|
ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
|
2022-01-29 23:04:28 +00:00
|
|
|
build-args: |
|
2023-12-21 11:46:05 +00:00
|
|
|
VERSION=${{ steps.hatch.outputs.version }}
|
2023-07-11 03:16:25 +00:00
|
|
|
PORT=42110
|
2024-11-25 06:44:41 +00:00
|
|
|
cache-from: type=gha,scope=${{ matrix.image }}-${{ matrix.platform }}
|
|
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.image }}-${{ matrix.platform}}
|
2024-11-29 03:14:06 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.description=Khoj AI Cloud - Your second brain powered by LLMs and Neural Search
|
|
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
2024-12-11 05:07:18 +00:00
|
|
|
|
|
|
|
manifest:
|
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
steps:
|
2024-12-11 08:21:29 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
2024-12-11 05:07:18 +00:00
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.PAT }}
|
2024-12-11 07:16:36 +00:00
|
|
|
|
2024-12-11 05:07:18 +00:00
|
|
|
- name: Create and Push Local Manifest
|
|
|
|
if: github.event.inputs.khoj == 'true' || github.event_name == 'push'
|
|
|
|
run: |
|
2024-12-11 08:21:29 +00:00
|
|
|
docker buildx imagetools create \
|
|
|
|
-t ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }} \
|
2024-12-11 06:55:33 +00:00
|
|
|
ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }}-amd64 \
|
|
|
|
ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }}-arm64
|
2024-12-11 05:07:18 +00:00
|
|
|
|
|
|
|
- name: Create and Push Cloud Manifest
|
|
|
|
if: github.event.inputs.khoj-cloud == 'true' || github.event_name == 'push'
|
|
|
|
run: |
|
2024-12-11 08:21:29 +00:00
|
|
|
docker buildx imagetools create \
|
|
|
|
-t ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }} \
|
2024-12-11 06:55:33 +00:00
|
|
|
ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}-amd64 \
|
|
|
|
ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}-arm64
|