Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create docker-image.yml #4

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Docker image

on:
workflow_dispatch:
push:
branches:
- master

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider using major version numbers for GitHub Actions

Using major version numbers (e.g., @v4 instead of @v4.x.x) allows for automatic updates to patch versions, which often include important bug fixes and security patches. This applies to all action versions in the workflow.


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.6.1

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider adding a date to the cache key

Adding a date (e.g., $(date +%Y-%m-%d)) to the cache key ensures periodic cache invalidation, preventing issues with stale caches while maintaining performance benefits.

          key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ steps.date.outputs.date }}

restore-keys: |
${{ runner.os }}-buildx-

- name: Log in to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/ml-buildkit:latest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using a more specific tagging strategy

Using only the 'latest' tag can lead to issues with reproducibility and versioning. Consider incorporating the git SHA (e.g., ${GITHUB_SHA::8}) or a semantic version in addition to or instead of 'latest'.

Suggested change
tags: ${{ secrets.DOCKER_USERNAME }}/ml-buildkit:latest
tags: |
${{ secrets.DOCKER_USERNAME }}/ml-buildkit:latest
${{ secrets.DOCKER_USERNAME }}/ml-buildkit:${{ github.sha }}

cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
Loading