-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Added Docker push workflow, Dockerfile updates, and build scr…
…ipt (#807) * ✨ feat: Added Docker push workflow, Dockerfile updates, and build script add Docker Push workflow and stages for building and pushing Docker images with different variants for autoraghq/autorag, including handling production image tagging and updating Docker Hub description. * ♻️ refactor: remove unnecessary tags and pull request configuration from Docker Push workflow --------- Co-authored-by: Jeffrey (Dongkyu) Kim <[email protected]>
- Loading branch information
Showing
4 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Docker Push | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
env: | ||
DOCKER_REPO: "autoraghq/autorag" | ||
|
||
jobs: | ||
check-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed: ${{ steps.version_changed.outputs.changed }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/[email protected] | ||
|
||
- name: Check for VERSION file change | ||
id: version_changed | ||
env: | ||
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | ||
run: | | ||
echo "changed=false" >> $GITHUB_OUTPUT | ||
if echo "${ALL_CHANGED_FILES}" | grep -q 'VERSION'; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
fi | ||
build-and-push: | ||
needs: check-version | ||
if: needs.check-version.outputs.changed == 'true' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
variant: [all] # [all, ko, dev, parsing] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Read VERSION file | ||
run: echo "VERSION=$(cat autorag/VERSION)" >> $GITHUB_ENV | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.DOCKER_REPO }} | ||
tags: | | ||
type=raw,value=${{ env.VERSION }}-${{ matrix.variant }} | ||
type=raw,value=${{ matrix.variant }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
type=raw,value=latest-${{ matrix.variant }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
# push: ${{ github.event_name != 'pull_request' && matrix.variant != 'test' }} | ||
tags: ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
TARGET_STAGE=${{ matrix.variant }} | ||
- name: Tag and push 'all' for production | ||
run: | | ||
docker pull ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} | ||
docker tag ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} ${{ env.DOCKER_REPO }}:latest | ||
docker push ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} | ||
docker push ${{ env.DOCKER_REPO }}:latest | ||
# - name: Update Docker Hub description | ||
# uses: peter-evans/dockerhub-description@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
# password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
# repository: ${{ env.DOCKER_REPO }} | ||
# short-description: ${{ github.event.repository.description }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3.3 | ||
0.3.3-rc16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Check if version is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <version>" | ||
exit 1 | ||
fi | ||
|
||
VERSION=$1 | ||
DOCKER_REPO="autoraghq/autorag" | ||
|
||
# Array of variants | ||
variants=("all" "ko" "dev" "parsing" "test") | ||
|
||
# Build and push for each variant | ||
for variant in "${variants[@]}" | ||
do | ||
echo "Building $DOCKER_REPO:$VERSION-$variant" | ||
docker build --build-arg TARGET_STAGE=$variant -t $DOCKER_REPO:$VERSION-$variant -f Dockerfile . | ||
|
||
echo "Pushing $DOCKER_REPO:$VERSION-$variant" | ||
docker push $DOCKER_REPO:$VERSION-$variant | ||
|
||
# If it's a release build, also tag and push as latest for that variant | ||
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Tagging and pushing $DOCKER_REPO:$variant" | ||
docker tag $DOCKER_REPO:$VERSION-$variant $DOCKER_REPO:$variant | ||
docker push $DOCKER_REPO:$variant | ||
fi | ||
done | ||
|
||
# Special handling for 'production' as 'all' | ||
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Tagging and pushing $DOCKER_REPO:all" | ||
docker tag $DOCKER_REPO:$VERSION-production $DOCKER_REPO:all | ||
docker push $DOCKER_REPO:all | ||
fi | ||
|
||
echo "Build and push complete for all variants" |