From f034303d02af2d963ccff8972b27429fcf2357cf Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Wed, 6 Nov 2024 18:19:31 +0530 Subject: [PATCH 1/2] Moving to common workflows --- .github/workflows/build-and-push-image.yaml | 157 +++----------------- 1 file changed, 21 insertions(+), 136 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 94108f3..cfc68d2 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -19,141 +19,26 @@ env: jobs: build_image: - name: Build Image - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: false - swap-storage: false - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set version tags - run: | - echo "Ref name is ${{ github.ref_name }}" - echo "TAG_PREFIX is ${{ env.TAG_PREFIX }}" - - REF_NAME=${{ github.ref_name }} - TAG_PREFIX=${{ env.TAG_PREFIX }} - VERSION_TAG=$(echo $REF_NAME | cut -d $TAG_PREFIX -f 2-) - echo "Setting VERSION_TAG equal to $VERSION_TAG" - echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV - - ALT_VERSION_TAG=$(echo $VERSION_TAG | awk -F- '{print $1}')-${GITHUB_SHA::7} - echo "Setting ALT_VERSION_TAG equal to $ALT_VERSION_TAG" - echo "ALT_VERSION_TAG=$ALT_VERSION_TAG" >> $GITHUB_ENV - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.PUBLIC_ECR_IAM_ROLE_ARN }} - aws-region: us-east-1 - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - with: - registry-type: public - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set repo uri - env: - REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REGISTRY_ALIAS: truefoundrycloud - REPOSITORY: llm-finetune - run: | - REPOSITORY_URI=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }} - echo "Setting REPOSITORY_URI equal to $REPOSITORY_URI" - echo "REPOSITORY_URI=$REPOSITORY_URI" >> $GITHUB_ENV - - - name: Build and push image - uses: docker/build-push-action@v5 - env: - IMAGE_TAG_1: ${{ env.REPOSITORY_URI }}:${{ env.GITHUB_SHA }} - IMAGE_TAG_2: ${{ env.REPOSITORY_URI }}:${{ env.VERSION_TAG }} - IMAGE_TAG_3: ${{ env.REPOSITORY_URI }}:${{ env.ALT_VERSION_TAG }} - with: - context: . - file: Dockerfile - platforms: linux/amd64 - push: true - tags: ${{ env.IMAGE_TAG_1 }},${{ env.IMAGE_TAG_2 }},${{ env.IMAGE_TAG_3 }} - cache-from: type=registry,ref=${{ env.REPOSITORY_URI }}:buildcache - cache-to: mode=max,image-manifest=true,type=registry,ref=${{ env.REPOSITORY_URI }}:buildcache + name: Build + uses: truefoundry/github-workflows-public/.github/workflows/build.yml@v0.1.2 + with: + image_tag: "v${{ github.sha }}" + image_artifact_name: llm-finetune + artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }} + artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }} + secrets: + artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }} + artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }} build_notebook_image: - name: Build Notebook Image - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - docker-images: false - swap-storage: false - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set version tags - run: | - echo "Ref name is ${{ github.ref_name }}" - echo "TAG_PREFIX is ${{ env.TAG_PREFIX }}" - - REF_NAME=${{ github.ref_name }} - TAG_PREFIX=${{ env.TAG_PREFIX }} - VERSION_TAG=$(echo $REF_NAME | cut -d $TAG_PREFIX -f 2-)-jupyter - echo "Setting VERSION_TAG equal to $VERSION_TAG" - echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.PUBLIC_ECR_IAM_ROLE_ARN }} - aws-region: us-east-1 - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - with: - registry-type: public - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set repo uri - env: - REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REGISTRY_ALIAS: truefoundrycloud - REPOSITORY: llm-finetune - run: | - REPOSITORY_URI=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }} - echo "Setting REPOSITORY_URI equal to $REPOSITORY_URI" - echo "REPOSITORY_URI=$REPOSITORY_URI" >> $GITHUB_ENV - - - name: Build and push image - uses: docker/build-push-action@v5 - env: - IMAGE_TAG_1: ${{ env.REPOSITORY_URI }}:${{ env.VERSION_TAG }} - with: - context: . - file: Dockerfile-notebook - platforms: linux/amd64 - push: true - tags: ${{ env.IMAGE_TAG_1 }} - cache-from: type=registry,ref=${{ env.REPOSITORY_URI }}:jupyter-buildcache - cache-to: mode=max,image-manifest=true,type=registry,ref=${{ env.REPOSITORY_URI }}:jupyter-buildcache + name: Build + uses: truefoundry/github-workflows-public/.github/workflows/build.yml@v0.1.2 + with: + image_tag: "v${{ github.sha }}" + image_artifact_name: llm-finetune-notebook + artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }} + artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }} + dockerfile_path: Dockerfile-notebook + secrets: + artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }} + artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }} \ No newline at end of file From 73752c59c9f7ac7579a4764107b1e84f7ca361b1 Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Wed, 6 Nov 2024 18:34:35 +0530 Subject: [PATCH 2/2] added free disk space --- .github/workflows/build-and-push-image.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index cfc68d2..e5b61e7 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -26,6 +26,7 @@ jobs: image_artifact_name: llm-finetune artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }} artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }} + free_disk_space: true secrets: artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }} artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }} @@ -39,6 +40,7 @@ jobs: artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }} artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }} dockerfile_path: Dockerfile-notebook + free_disk_space: true secrets: artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }} artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }} \ No newline at end of file