1+ name : Build Neuron vLLM Inference DLC
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths :
7+ - ' docker/vllm/inference/**'
8+ - ' docker/common/**'
9+ - ' .github/workflows/build-neuron-vllm-inference-dlc.yaml'
10+ pull_request :
11+ branches : [ main ]
12+ paths :
13+ - ' docker/vllm/inference/**'
14+ - ' docker/common/**'
15+ workflow_dispatch :
16+ inputs :
17+ vllm_versions :
18+ description : ' vLLM versions to build (comma-separated, e.g., "0.9.1,0.7.2")'
19+ required : false
20+ default : ' 0.9.1'
21+
22+ jobs :
23+ detect-changes :
24+ runs-on : ubuntu-latest
25+ outputs :
26+ matrix : ${{ steps.changes.outputs.matrix }}
27+ steps :
28+ - name : Check out repository
29+ uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 0
32+
33+ - name : Detect changed versions
34+ id : changes
35+ run : |
36+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
37+ # Use manual input versions
38+ versions="${{ github.event.inputs.vllm_versions }}"
39+ matrix_json="[]"
40+ IFS=',' read -ra VERSION_ARRAY <<< "$versions"
41+ for version in "${VERSION_ARRAY[@]}"; do
42+ version=$(echo "$version" | xargs) # trim whitespace
43+ path="docker/vllm/inference/$version"
44+ if [ -f "$path/Dockerfile.neuronx" ]; then
45+ matrix_json=$(echo "$matrix_json" | jq ". + [{\"version\": \"$version\", \"path\": \"$path\"}]")
46+ fi
47+ done
48+ else
49+ # Detect changed Dockerfile paths
50+ changed_paths=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} \
51+ | grep '^docker/vllm/inference/.*/Dockerfile.neuronx$' \
52+ | xargs -n1 dirname \
53+ | sort -u)
54+
55+ matrix_json="[]"
56+ for path in $changed_paths; do
57+ version=$(basename "$path")
58+ matrix_json=$(echo "$matrix_json" | jq ". + [{\"version\": \"$version\", \"path\": \"$path\"}]")
59+ done
60+ fi
61+
62+ matrix_compact=$(echo "$matrix_json" | jq -c .)
63+ echo "Matrix JSON: $matrix_compact"
64+ echo "matrix=$matrix_compact" >> $GITHUB_OUTPUT
65+
66+ build :
67+ needs : detect-changes
68+ if : ${{ needs.detect-changes.outputs.matrix != '[]' }}
69+ runs-on : ubuntu-latest
70+ strategy :
71+ matrix :
72+ include : ${{ fromJson(needs.detect-changes.outputs.matrix) }}
73+
74+ steps :
75+ - name : Delete unnecessary tools folder to free runner space
76+ run : rm -rf /opt/hostedtoolcache
77+
78+ - name : Check out repository
79+ uses : actions/checkout@v4
80+
81+ - name : Copy common files next to Dockerfile
82+ run : |
83+ cp -r docker/common/* ${{ matrix.path }}/
84+
85+ - name : Set up Docker Buildx
86+ uses : docker/setup-buildx-action@v3
87+
88+ - name : Build Docker image
89+ uses : docker/build-push-action@v6
90+ with :
91+ context : ${{ matrix.path }}
92+ file : ${{ matrix.path }}/Dockerfile.neuronx
93+ platforms : linux/amd64
94+ tags : neuron-vllm-inference-dlc:${{ matrix.version }}-${{ github.sha }}
95+ push : false
0 commit comments