| name: docker | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - "**/*.py" | |
| - "requirements.txt" | |
| - "docker/**" | |
| - ".github/workflows/*.yml" | |
| pull_request: | |
| branches: | |
| - "main" | |
| paths: | |
| - "**/*.py" | |
| - "requirements.txt" | |
| - "docker/**" | |
| - ".github/workflows/*.yml" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| environment: | |
| name: docker | |
| url: https://hub.docker.com/r/hiyouga/llamafactory | |
| steps: | |
| - name: Free up disk space | |
| run: | | |
| df -h | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache | |
| df -h | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.9" | |
| - name: Get llamafactory version | |
| id: version | |
| run: | | |
| echo "tag=$(python setup.py --version | sed 's/\.dev0//')" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./docker/docker-cuda/Dockerfile | |
| build-args: | | |
| EXTRAS=metrics,deepspeed,liger-kernel | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| docker.io/hiyouga/llamafactory:latest | |
| docker.io/hiyouga/llamafactory:${{ steps.version.outputs.tag }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |