Updated Dockerfiles - Public Artifacts #37
This file contains hidden or 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
| name: Build Neuron vLLM Inference DLC | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'vllm/inference/**' | |
| - 'common/**' | |
| - '.github/workflows/build-neuron-vllm-inference-dlc.yaml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'vllm/inference/**' | |
| - 'common/**' | |
| workflow_dispatch: | |
| inputs: | |
| vllm_versions: | |
| description: 'vLLM versions to build (comma-separated, e.g., "0.9.1,0.7.2")' | |
| required: false | |
| default: '0.9.1' | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.changes.outputs.matrix }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed versions | |
| id: changes | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| VLLM_VERSIONS: ${{ github.event.inputs.vllm_versions }} | |
| BASE_REF: ${{ github.base_ref }} | |
| SHA: ${{ github.sha }} | |
| run: | | |
| if [ "$EVENT_NAME" = "workflow_dispatch" ]; then | |
| # Use manual input versions with validation | |
| matrix_json="[]" | |
| IFS=',' read -ra VERSION_ARRAY <<< "$VLLM_VERSIONS" | |
| for version in "${VERSION_ARRAY[@]}"; do | |
| version=$(echo "$version" | xargs) # trim whitespace | |
| # Validate version format (only allow alphanumeric, dots, and hyphens) | |
| if [[ "$version" =~ ^[a-zA-Z0-9.-]+$ ]]; then | |
| path="vllm/inference/$version" | |
| if [ -f "$path/Dockerfile.neuronx" ]; then | |
| matrix_json=$(echo "$matrix_json" | jq --arg v "$version" --arg p "$path" '. + [{"version": $v, "path": $p}]') | |
| fi | |
| fi | |
| done | |
| else | |
| # Detect changed Dockerfile paths | |
| changed_paths=$(git diff --name-only "origin/$BASE_REF" "$SHA" \ | |
| | grep '^vllm/inference/.*/Dockerfile.neuronx$' \ | |
| | xargs -n1 dirname \ | |
| | sort -u) | |
| matrix_json="[]" | |
| for path in $changed_paths; do | |
| version=$(basename "$path") | |
| matrix_json=$(echo "$matrix_json" | jq --arg v "$version" --arg p "$path" '. + [{"version": $v, "path": $p}]') | |
| done | |
| fi | |
| matrix_compact=$(echo "$matrix_json" | jq -c .) | |
| echo "Matrix JSON: $matrix_compact" | |
| echo "matrix=$matrix_compact" >> $GITHUB_OUTPUT | |
| build: | |
| needs: detect-changes | |
| if: ${{ needs.detect-changes.outputs.matrix != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: ${{ fromJson(needs.detect-changes.outputs.matrix) }} | |
| steps: | |
| - name: Free up runner space | |
| run: | | |
| sudo rm -rf /opt/hostedtoolcache | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/az | |
| docker system prune -af | |
| df -h | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Copy common files next to Dockerfile | |
| env: | |
| MATRIX_PATH: ${{ matrix.path }} | |
| run: | | |
| cp -r common/* "$MATRIX_PATH"/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ matrix.path }} | |
| file: ${{ matrix.path }}/Dockerfile.neuronx | |
| platforms: linux/amd64 | |
| tags: neuron-vllm-inference-dlc:${{ matrix.version }}-${{ github.sha }} | |
| push: false |