← AI-Hands-on Cloud deployment · Part 6 of 7Triển khai đám mây · Phần 6/7

An agent that only runs on your laptop is not shipped yetMột agent chỉ chạy trên máy bạn thì chưa phải đã hoàn thành

Every part of this series so far runs on localhost. This walkthrough adds a Vision Agent that can also read images, then containerizes the whole thing with Docker and ships it to Google Cloud Run as a real public endpoint.

Mọi phần trước trong series này đều chạy trên localhost. Video này thêm một Vision Agent biết đọc ảnh, rồi đóng gói toàn bộ bằng Docker và triển khai lên Google Cloud Run thành một địa chỉ công khai thật.

Video demo: build, local container test via curl, then a one-line deploy to a public Cloud Run URL.

Video demo: build, kiểm tra container cục bộ qua curl, rồi triển khai bằng một dòng lệnh lên URL Cloud Run công khai.

English

What problem does this solve?

An agent that works perfectly on the developer's own machine tells you almost nothing about whether it will work anywhere else. Different Python versions, missing system libraries, or an environment variable that only exists locally are exactly the kind of gap that turns "it works for me" into a production incident. This walkthrough continues studying the open-source theailanguage/a2a_samples reference implementation.

How the mechanism works

This part first extends the agent itself: a Vision Agent that accepts a question plus an image path, and has Gemini describe or analyze what's in the picture — proving the same A2A task pattern works for multimodal input, not just text.

Then the whole application — operating system layer, dependencies, and source code — gets packaged into a single Docker image, so it behaves identically wherever it runs. The build is tested locally first: build the image, run the container, and send it a real request over curl before trusting it with anything further. Only after that local check passes does the image get pushed to Google's container registry and deployed to Cloud Run with a single command, returning a real public HTTPS URL.

Trade-offs and alternatives

The benefit is a deployment that is genuinely portable and reproducible — the same image that passed the local curl test is the exact image running in the cloud, not a "close enough" recreation. The trade-off is the extra step of learning Docker and container registries, which is real overhead for a team that has never containerized anything before.

The alternative — deploying source code directly to a platform-specific runtime without a container — can be faster to set up initially, but it reintroduces the "works on my machine" risk the moment that platform's environment drifts even slightly from the developer's.

Conclusion

Local success and production readiness are two different claims. Testing the exact container that will ship — not just the code — is what closes that gap, and it's the same discipline that applies whether the agent is answering text questions or now, images too.

Tiếng Việt

Vấn đề gì đang được giải quyết?

Một agent chạy hoàn hảo trên máy của lập trình viên gần như không nói lên được gì về việc nó có chạy được ở nơi khác hay không. Phiên bản Python khác nhau, thiếu thư viện hệ thống, hay một biến môi trường chỉ tồn tại cục bộ — đó chính xác là loại khoảng cách biến "chạy tốt trên máy tôi" thành sự cố sản xuất. Video này tiếp tục nghiên cứu bản triển khai tham chiếu mã nguồn mở theailanguage/a2a_samples.

Cơ chế hoạt động ra sao?

Phần này trước tiên mở rộng chính agent: một Vision Agent nhận một câu hỏi kèm đường dẫn ảnh, để Gemini mô tả hoặc phân tích nội dung bức ảnh — chứng minh cùng một mẫu tác vụ A2A hoạt động được với đầu vào đa phương tiện, không chỉ văn bản.

Sau đó, toàn bộ ứng dụng — tầng hệ điều hành, thư viện phụ thuộc, và mã nguồn — được đóng gói vào một image Docker duy nhất, để nó hoạt động giống hệt nhau ở bất kỳ đâu chạy nó. Bản build được kiểm tra cục bộ trước: build image, chạy container, rồi gửi một yêu cầu thật qua curl trước khi tin tưởng giao thêm việc gì khác. Chỉ sau khi kiểm tra cục bộ đó qua được, image mới được đẩy lên kho chứa container của Google và triển khai lên Cloud Run bằng một dòng lệnh duy nhất, trả về một địa chỉ HTTPS công khai thật.

Đánh đổi và các hướng khác

Cái được là một bản triển khai thực sự di động và tái tạo được — image đã qua bài kiểm tra curl cục bộ chính là image đang chạy trên đám mây, không phải một bản dựng lại "gần giống". Cái đánh đổi là bước học thêm Docker và kho chứa container, chi phí thật với một đội chưa từng đóng gói container trước đây.

Hướng thay thế — triển khai mã nguồn trực tiếp lên một runtime đặc thù của nền tảng mà không qua container — có thể thiết lập nhanh hơn lúc đầu, nhưng lại đưa trở lại rủi ro "chạy tốt trên máy tôi" ngay khi môi trường của nền tảng đó lệch dù chỉ một chút so với máy lập trình viên.

Kết luận

Thành công cục bộ và sẵn sàng cho sản xuất là hai điều khẳng định khác nhau. Kiểm tra đúng container sẽ được triển khai — chứ không chỉ mã nguồn — là điều thu hẹp khoảng cách đó, và đó cũng là kỷ luật áp dụng dù agent đang trả lời câu hỏi văn bản hay giờ đây là cả hình ảnh.