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