Docker build update #4 (cache and cleanup)
This commit is contained in:
40
.github/workflows/docker-image.yml
vendored
40
.github/workflows/docker-image.yml
vendored
@@ -22,6 +22,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
|
|
||||||
|
- name: Cache Node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.npm
|
||||||
|
frontend/node_modules
|
||||||
|
key: ${{ runner.os }}-node-modules-${{ hashFiles('frontend/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-modules-
|
||||||
|
|
||||||
- name: Install Dependencies and Build Frontend
|
- name: Install Dependencies and Build Frontend
|
||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
@@ -53,7 +63,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image with Cache
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -61,32 +71,20 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ghcr.io/${{ env.REPO_OWNER }}/ssh-project:${{ env.IMAGE_TAG }}
|
tags: ghcr.io/${{ env.REPO_OWNER }}/ssh-project:${{ env.IMAGE_TAG }}
|
||||||
labels: org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
labels: org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Notify via ntfy
|
- name: Notify via ntfy
|
||||||
run: |
|
run: |
|
||||||
curl -d "Docker image build and push completed successfully for tag: ${{ env.IMAGE_TAG }}" \
|
curl -d "Docker image build and push completed successfully for tag: ${{ env.IMAGE_TAG }}" \
|
||||||
https://ntfy.karmaashomepage.online/ssh-project-build
|
https://ntfy.karmaashomepage.online/ssh-project-build
|
||||||
|
|
||||||
- name: Cleanup Docker Images on GHCR
|
- uses: quartx-analytics/ghcr-cleaner@v1
|
||||||
run: |
|
with:
|
||||||
# Get the list of images from ghcr.io
|
owner-type: user
|
||||||
images=$(curl -s -H "Authorization: Bearer ${{ secrets.GHCR_TOKEN }}" \
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
"https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/ssh-project/versions")
|
repository_owner: ${{ github.repository_owner }}
|
||||||
|
delete-untagged: true
|
||||||
# Check the response (for debugging)
|
|
||||||
echo "Response from GHCR: $images"
|
|
||||||
|
|
||||||
# List image tags and delete older versions (keep the latest 10)
|
|
||||||
count=0
|
|
||||||
max_images=10
|
|
||||||
for image in $(echo "$images" | jq -r '.[] | .id'); do
|
|
||||||
if [ $count -ge $max_images ]; then
|
|
||||||
echo "Deleting image $image"
|
|
||||||
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GHCR_TOKEN }}" \
|
|
||||||
"https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/ssh-project/versions/$image"
|
|
||||||
fi
|
|
||||||
count=$((count + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Cleanup Docker Images Locally
|
- name: Cleanup Docker Images Locally
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
26
.idea/workspace.xml
generated
26
.idea/workspace.xml
generated
@@ -4,7 +4,7 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="8497df64-d86b-4c98-ac58-c157d9d3fb1e" name="Changes" comment="Docker build update">
|
<list default="true" id="8497df64-d86b-4c98-ac58-c157d9d3fb1e" name="Changes" comment="Docker build update #3">
|
||||||
<change beforePath="$PROJECT_DIR$/.github/workflows/docker-image.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.github/workflows/docker-image.yml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.github/workflows/docker-image.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.github/workflows/docker-image.yml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
<updated>1733439468142</updated>
|
<updated>1733439468142</updated>
|
||||||
<workItem from="1733439479708" duration="5489000" />
|
<workItem from="1733439479708" duration="5489000" />
|
||||||
<workItem from="1733448523969" duration="3535000" />
|
<workItem from="1733448523969" duration="3535000" />
|
||||||
<workItem from="1733549186397" duration="6074000" />
|
<workItem from="1733549186397" duration="6475000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Nano zoom fix #11">
|
<task id="LOCAL-00001" summary="Nano zoom fix #11">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -229,7 +229,23 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1733555933987</updated>
|
<updated>1733555933987</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="15" />
|
<task id="LOCAL-00015" summary="Docker build update #2">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1733556269270</created>
|
||||||
|
<option name="number" value="00015" />
|
||||||
|
<option name="presentableId" value="LOCAL-00015" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1733556269270</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00016" summary="Docker build update #3">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1733556428424</created>
|
||||||
|
<option name="number" value="00016" />
|
||||||
|
<option name="presentableId" value="LOCAL-00016" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1733556428424</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="17" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -269,6 +285,8 @@
|
|||||||
<MESSAGE value="Silent resize cmds & Auto resize terminal #1" />
|
<MESSAGE value="Silent resize cmds & Auto resize terminal #1" />
|
||||||
<MESSAGE value="Silent resize cmds & Auto resize terminal #2" />
|
<MESSAGE value="Silent resize cmds & Auto resize terminal #2" />
|
||||||
<MESSAGE value="Docker build update" />
|
<MESSAGE value="Docker build update" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Docker build update" />
|
<MESSAGE value="Docker build update #2" />
|
||||||
|
<MESSAGE value="Docker build update #3" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Docker build update #3" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Reference in New Issue
Block a user