-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gyanesh Mishra
authored and
Gyanesh Mishra
committed
Dec 5, 2023
1 parent
c30c3b5
commit a41264e
Showing
2 changed files
with
51 additions
and
33 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 |
---|---|---|
|
@@ -35,7 +35,7 @@ jobs: | |
haskell: true | ||
large-packages: false | ||
swap-storage: true | ||
|
||
- name: Install soci | ||
uses: lerentis/[email protected] | ||
with: | ||
|
@@ -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 | ||
|
@@ -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: | ||
|
@@ -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 | ||
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 |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||