1- # Copyright 2025 Google LLC
1+ # Copyright 2023-2026 Google LLC
22
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
2828 build_mode :
2929 required : true
3030 type : string
31- dockerfile :
32- required : true
33- type : string
3431 maxtext_sha :
3532 required : true
3633 type : string
37- image_date :
38- required : false
39- type : string
4034 workflow :
4135 required : false
4236 type : string
4539 required : false
4640 type : string
4741 default : ' '
42+ include_test_assets :
43+ required : false
44+ type : boolean
45+ default : false
4846 secrets :
4947 HF_TOKEN :
5048 required : true
@@ -89,48 +87,57 @@ jobs:
8987 echo "workflow: ${{ inputs.workflow }}"
9088 echo "build_mode: ${{ inputs.build_mode }}"
9189 echo "image_name: ${{ inputs.image_name }}"
92- echo "dockerfile: ${{ inputs.dockerfile }}"
9390
94- - name : Checkout MaxText
95- uses : actions/checkout@v5
91+ - name : Configure Docker
92+ run : gcloud auth configure-docker us-docker.pkg.dev,gcr.io -q
9693 if : steps.check.outputs.should_run == 'true'
97- with :
98- # This ensures that every job clones the exact same commit as "setup" job
99- ref : ${{ inputs.maxtext_sha }}
10094
101- - name : Mark git repositories as safe
102- run : git config --global --add safe.directory ${GITHUB_WORKSPACE}
103- if : steps.check.outputs.should_run == 'true'
95+ # - name: Set up Docker BuildX
96+ # uses: docker/setup-buildx-action@v3.11.1
97+ # if: steps.check.outputs.should_run == 'true'
98+ # with:
99+ # driver: remote
100+ # endpoint: tcp://localhost:1234
104101
105- - name : Configure Docker
106- run : gcloud auth configure-docker us-docker.pkg.dev,gcr.io -q
102+ - name : Download MaxText wheel
103+ uses : actions/download-artifact@v4
107104 if : steps.check.outputs.should_run == 'true'
105+ with :
106+ name : maxtext-wheel
108107
109- - name : Set up Docker BuildX
110- uses : docker /setup-buildx-action@v3.11.1
108+ - name : Install uv and set the Python version
109+ uses : astral-sh /setup-uv@v7
111110 if : steps.check.outputs.should_run == 'true'
112111 with :
113- driver : remote
114- endpoint : tcp://localhost:1234
112+ python-version : ' 3.12'
113+ enable-cache : true
114+
115+ - name : Install MaxText wheel
116+ if : steps.check.outputs.should_run == 'true'
117+ shell : bash
118+ run : |
119+ uv venv --seed
120+ source .venv/bin/activate
121+ maxtext_wheel=$(ls maxtext-*-py3-none-any.whl 2>/dev/null)
122+ uv pip install ${maxtext_wheel}[runner] --resolution=lowest
115123
116124 - name : Build and push Docker image
117- uses : docker/build-push-action@v6
118125 if : steps.check.outputs.should_run == 'true'
119- with :
120- push : true
121- context : .
122- file : ${{ inputs.dockerfile }}
123- tags : gcr.io/tpu-prod-env-multipod/${{ inputs.image_name }}:${{ github.run_id }}
124- cache-from : type=gha
125- outputs : type= image,compression=zstd,force-compression=true
126- build-args : |
127- DEVICE=${{ inputs.device }}
128- MODE=${{ inputs.build_mode }}
126+ shell : bash
127+ env :
128+ IMAGE_TAG : " gcr.io/tpu-prod-env-multipod/${{ inputs.image_name }}:${{ github.run_id }} "
129+ INCLUDE_TEST_ASSETS : ${{ inputs.include_test_assets }}
130+ run : |
131+ source .venv/bin/activate
132+ echo "Building MaxText Docker image..."
133+ sudo .venv/bin/python3 -m dependencies.scripts.build_maxtext_docker_image \
134+ DEVICE=${{ inputs.device }} \
135+ MODE=${{ inputs.build_mode }} \
129136 WORKFLOW=${{ inputs.workflow }}
130- PACKAGE_DIR=./src
131- JAX_VERSION=NONE
132- LIBTPU_VERSION=NONE
133- INCLUDE_TEST_ASSETS=true
137+
138+ echo "Pushing MaxText Docker image..."
139+ docker push "${IMAGE_TAG}"
140+ echo "Successfully pushed ${IMAGE_TAG}"
134141
135142 - name : Add tags to Docker image
136143 if : steps.check.outputs.should_run == 'true'
@@ -146,16 +153,16 @@ jobs:
146153 echo "Tagging docker images corresponding to nightly release..."
147154
148155 # Add date tag
149- gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
156+ IMAGE_DATE="$(date +%Y-%m-%d)"
157+ gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:$IMAGE_DATE" --quiet
150158
151159 # Convert date to YYYYMMDD format
152- clean_date=$(echo "${INPUTS_IMAGE_DATE} " | sed 's/[-:]//g' | cut -c1-8)
160+ clean_date=$(echo "$IMAGE_DATE " | sed 's/[-:]//g' | cut -c1-8)
153161
154162 # Add MaxText tag
155163 gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:maxtext_${MAXTEXT_SHA}_${clean_date}" --quiet
156164 fi
157165 env :
158166 INPUTS_IMAGE_NAME : ${{ inputs.image_name }}
159- INPUTS_IMAGE_DATE : ${{ inputs.image_date }}
160167 INPUTS_VERSION_NAME : ${{ inputs.version_name }}
161168 MAXTEXT_SHA : ${{ inputs.maxtext_sha }}
0 commit comments