Skip to content

Commit

Permalink
fix sha path
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyanesh Mishra authored and Gyanesh Mishra committed Dec 5, 2023
1 parent c30c3b5 commit a41264e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 33 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/build-soci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
haskell: true
large-packages: false
swap-storage: true

- name: Install soci
uses: lerentis/[email protected]
with:
Expand All @@ -62,13 +62,6 @@ jobs:
type=sha,prefix=,suffix=,format=short
type=raw,value=latest
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}

- name: Set output
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
Expand All @@ -78,19 +71,25 @@ jobs:
with:
context: .
file: ./Dockerfile # Path to your Dockerfile
push: false # Export to local only
push: false
tags: ${{ steps.meta.outputs.tags }}
outputs: type=oci,dest=/tmp/lorax-${{ steps.vars.outputs.sha_short }}.tar

- name: Import image in containerd
env:
tags: ${{ steps.meta.outputs.tags }}
short_sha: ${{ steps.vars.outputs.sha_short }}
sha_short: ${{ steps.vars.outputs.sha_short }}
run: |
echo "Importing $sha_short to GHCR"
sudo ctr i import --digests /tmp/lorax-$short_sha.tar
sudo ctr i import --digests /tmp/lorax-$sha_short.tar
# Delete the on disk copy
rm -rf /tmp/lorax-$short_sha.tar
rm -rf /tmp/lorax-$sha_short.tar
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}

- name: Push image with containerd
env:
Expand All @@ -117,11 +116,12 @@ jobs:
- name: Prune older images
env:
short_sha: ${{ steps.vars.outputs.sha_short }}
sha_short: ${{ steps.vars.outputs.sha_short }}
run: |
# Delete images older than a day from docker store
docker image prune -a --filter "until=24h"
# Delete the SHA image from containerd store
# Leave the latest around for faster import next time
sudo ctr i rm ghcr.io/predibase/lorax:$short_sha
sudo ctr i rm ghcr.io/predibase/lorax:$sha_short
52 changes: 35 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ jobs:
large-packages: false
swap-storage: true

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Set up containerd for ubuntu
uses: crazy-max/[email protected]

- name: Install soci
uses: lerentis/[email protected]
with:
soci-release: 'v0.4.0'

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Set up containerd for ubuntu
uses: crazy-max/[email protected]

- name: Docker meta
id: meta
Expand All @@ -64,25 +64,27 @@ jobs:
type=sha,prefix=,suffix=,format=short
type=raw,value=latest
- name: Set output
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile # Path to your Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
outputs: type=oci,dest=/tmp/lorax-${{ steps.meta.outputs.version }}.tar
outputs: type=oci,dest=/tmp/lorax-${{ steps.vars.outputs.sha_short }}.tar

- name: Import image in containerd
env:
tags: ${{ steps.meta.outputs.tags }}
sha_short: ${{ steps.vars.outputs.sha_short }}
run: |
echo $tags
for tag in $tags
do
sudo ctr i import --base-name $tag --digests /tmp/lorax-${{ steps.meta.outputs.version }}.tar
done
rm -rf /tmp/lorax-${{ steps.meta.outputs.version }}.tar
echo "Importing $sha_short to GHCR"
sudo ctr i import --digests /tmp/lorax-$sha_short.tar
# Delete the on disk copy
rm -rf /tmp/lorax-$sha_short.tar
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
Expand All @@ -97,15 +99,31 @@ jobs:
run: |
for tag in $tags
do
echo "Pushing $tag to GHCR"
sudo ctr i push --user "${{ github.repository_owner }}:${{ secrets.GHCR_PAT }}" $tag
done
- name: Create and push soci index
env:
tags: ${{ steps.meta.outputs.tags }}
run: |
export SOCI_PATH=$HOME/.soci/soci
for tag in $tags
do
sudo soci create $tag
sudo soci push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag
done
echo "Creating soci index for $tag"
sudo $SOCI_PATH create $tag
echo "Pushing soci index for $tag"
sudo $SOCI_PATH push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag
done
- name: Prune older images
env:
sha_short: ${{ steps.vars.outputs.sha_short }}
run: |
# Delete images older than a day from docker store
docker image prune -a --filter "until=24h"
# Delete the SHA image from containerd store
# Leave the latest around for faster import next time
sudo ctr i rm ghcr.io/predibase/lorax:$sha_short

0 comments on commit a41264e

Please sign in to comment.