(resource_name: str)
| 1137 | ) |
| 1138 | |
| 1139 | def create_dockerfile_for_agent_engine(resource_name: str): |
| 1140 | requirements_txt_path = os.path.join(agent_src_path, 'requirements.txt') |
| 1141 | install_agent_deps = ( |
| 1142 | f'RUN pip install -r "/app/agents/{app_name}/requirements.txt"' |
| 1143 | if os.path.exists(requirements_txt_path) |
| 1144 | else '# No requirements.txt found.' |
| 1145 | ) |
| 1146 | trigger_sources_option = ( |
| 1147 | f'--trigger_sources={trigger_sources}' if trigger_sources else '' |
| 1148 | ) |
| 1149 | agent_engine_uri = f'agentengine://{resource_name}' |
| 1150 | dockerfile_content = _DOCKERFILE_TEMPLATE.format( |
| 1151 | gcp_project_id=project, |
| 1152 | gcp_region=region, |
| 1153 | app_name=app_name, |
| 1154 | port=8080, |
| 1155 | command='api_server', |
| 1156 | install_agent_deps=install_agent_deps, |
| 1157 | service_option=_get_service_option_by_adk_version( |
| 1158 | adk_version, |
| 1159 | session_service_uri or agent_engine_uri, |
| 1160 | artifact_service_uri, |
| 1161 | memory_service_uri or agent_engine_uri, |
| 1162 | False, # use_local_storage |
| 1163 | ), |
| 1164 | trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '', |
| 1165 | otel_to_cloud_option='--otel_to_cloud' if otel_to_cloud else '', |
| 1166 | allow_origins_option='', # Not supported for now. |
| 1167 | adk_version=adk_version, |
| 1168 | host_option='--host=0.0.0.0', |
| 1169 | a2a_option='--a2a', |
| 1170 | trigger_sources_option=trigger_sources_option, |
| 1171 | gemini_enterprise_option=f'--gemini_enterprise_app_name={app_name}', |
| 1172 | express_mode_option=( |
| 1173 | ' --express_mode' if api_key and not project else '' |
| 1174 | ), |
| 1175 | ) |
| 1176 | with open('Dockerfile', 'w', encoding='utf-8') as f: |
| 1177 | f.write(dockerfile_content) |
| 1178 | |
| 1179 | if absolutize_imports: |
| 1180 | warnings.warn( |
no test coverage detected