2023-02-15 02:53:35 +01:00
|
|
|
name: dockerize
|
2022-01-29 22:31:27 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2023-02-15 02:53:35 +01:00
|
|
|
tags:
|
|
|
|
- "*"
|
2022-01-29 22:31:27 +01:00
|
|
|
branches:
|
|
|
|
- master
|
2022-08-01 01:30:23 +02:00
|
|
|
paths:
|
2023-02-14 21:50:51 +01:00
|
|
|
- src/khoj/**
|
2024-06-22 16:42:41 +02:00
|
|
|
- src/interface/web/**
|
2023-02-16 10:12:04 +01:00
|
|
|
- pyproject.toml
|
2022-08-01 01:30:23 +02:00
|
|
|
- Dockerfile
|
2023-12-22 11:52:42 +01:00
|
|
|
- prod.Dockerfile
|
2022-08-01 01:30:23 +02:00
|
|
|
- docker-compose.yml
|
2023-02-15 02:53:35 +01:00
|
|
|
- .github/workflows/dockerize.yml
|
2022-09-15 19:28:41 +02:00
|
|
|
workflow_dispatch:
|
2023-12-22 11:52:42 +01: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 19:28:41 +02:00
|
|
|
|
|
|
|
env:
|
2023-12-22 11:52:42 +01:00
|
|
|
# Tag Image with tag name on release
|
|
|
|
# else with user specified tag (default 'dev') if triggered via workflow
|
2024-06-22 16:42:41 +02:00
|
|
|
# else with run_id if triggered via a pull request
|
2023-12-22 11:52:42 +01:00
|
|
|
# else with 'pre' (if push to master)
|
2024-06-22 17:41:25 +02:00
|
|
|
DOCKER_IMAGE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || github.event_name == 'workflow_dispatch' && github.event.inputs.tag || 'pre' }}
|
2022-01-29 22:31:27 +01:00
|
|
|
|
|
|
|
jobs:
|
2022-01-29 23:48:52 +01:00
|
|
|
build:
|
2023-12-22 11:52:42 +01:00
|
|
|
name: Publish Khoj Docker Images
|
2022-01-29 22:31:27 +01:00
|
|
|
runs-on: ubuntu-latest
|
2023-12-22 11:52:42 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
image:
|
|
|
|
- 'local'
|
|
|
|
- 'cloud'
|
2022-01-29 22:31:27 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
2023-02-18 01:14:46 +01:00
|
|
|
uses: actions/checkout@v3
|
2023-12-22 11:52:42 +01:00
|
|
|
with:
|
|
|
|
# Get all history to correctly infer Khoj version using hatch
|
|
|
|
fetch-depth: 0
|
2022-01-29 22:31:27 +01:00
|
|
|
|
2024-09-29 09:27:37 +02:00
|
|
|
- name: 🧹 Delete huge unnecessary tools folder
|
|
|
|
run: rm -rf /opt/hostedtoolcache
|
|
|
|
|
2022-01-29 22:31:27 +01:00
|
|
|
- name: Set up Docker Buildx
|
2023-02-18 01:14:46 +01:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-01-29 22:31:27 +01:00
|
|
|
|
|
|
|
- name: Login to GitHub Container Registry
|
2023-02-18 01:14:46 +01:00
|
|
|
uses: docker/login-action@v2
|
2022-01-29 22:31:27 +01:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.PAT }}
|
|
|
|
|
2023-12-21 12:46:05 +01:00
|
|
|
- name: Get App Version
|
|
|
|
id: hatch
|
|
|
|
run: echo "version=$(pipx run hatch version)" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-06 19:07:51 +01:00
|
|
|
- name: 🧹 Delete huge unnecessary tools folder
|
|
|
|
run: rm -rf /opt/hostedtoolcache
|
|
|
|
|
2023-03-01 17:56:39 +01:00
|
|
|
- name: 📦 Build and Push Docker Image
|
2022-01-29 22:31:27 +01:00
|
|
|
uses: docker/build-push-action@v2
|
2023-12-22 11:52:42 +01: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 22:31:27 +01:00
|
|
|
with:
|
|
|
|
context: .
|
2022-07-04 20:01:59 +02:00
|
|
|
file: Dockerfile
|
2023-09-09 02:07:26 +02:00
|
|
|
platforms: linux/amd64, linux/arm64
|
2022-01-29 22:31:27 +01:00
|
|
|
push: true
|
2023-12-21 12:59:37 +01:00
|
|
|
tags: |
|
|
|
|
ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }}
|
2023-12-22 11:52:42 +01:00
|
|
|
${{ github.ref_type == 'tag' && format('ghcr.io/{0}:latest', github.repository) || '' }}
|
|
|
|
build-args: |
|
|
|
|
VERSION=${{ steps.hatch.outputs.version }}
|
|
|
|
PORT=42110
|
|
|
|
|
|
|
|
- name: 📦️⛅️ Build and Push Cloud Docker Image
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
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
|
2024-09-10 22:52:04 +02:00
|
|
|
platforms: linux/amd64, linux/arm64
|
2023-12-22 11:52:42 +01:00
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}
|
|
|
|
${{ github.ref_type == 'tag' && format('ghcr.io/{0}-cloud:latest', github.repository) || '' }}
|
2022-01-30 00:04:28 +01:00
|
|
|
build-args: |
|
2023-12-21 12:46:05 +01:00
|
|
|
VERSION=${{ steps.hatch.outputs.version }}
|
2023-07-11 05:16:25 +02:00
|
|
|
PORT=42110
|