Deploying a Docker Container on AWS Amplify

0

I'm trying to deploy a gradio app using Docker on AWS Amplify. I'm not sure if I'm hitting a weird quirk of Amplify or if it's just not possible with the service. When in the Amplify web console General settings of the app I'm unable to change the Platform from Web to Web_Compute. The app is linked to my github repo and I have a minimal gradio app with a standard Dockerfile. I'm using port 7860 as the gradio port exposed. During the build process it's searching for index.html, completely ignoring the Dockerfile. Do I need to include something in my amplify.yml to point at my Docker build? Why am I not able to change the platform from the Amplify console?

asked 2 months ago175 views
2 Answers
0
Accepted Answer

Unfortunately, it appears that deploying a Docker container directly on AWS Amplify is not currently possible. Amplify is primarily designed for hosting static websites and serverless web applications, not for running containerized applications like your Gradio app.

The reason you're unable to change the platform from Web to Web_Compute in the Amplify console is that Amplify doesn't support Docker-based deployments. The platform is looking for static web assets like index.html, which is why it's ignoring your Dockerfile.

Amplify's build process is not designed to build or run Docker containers. Including instructions in the amplify.yml file to point to a Docker build won't help in this case, as Amplify doesn't have the capability to execute Docker commands or manage containers.

For your Gradio app in a Docker container, you would need to consider alternative AWS services that are better suited for container deployments. Some options you might want to explore include:

  1. AWS App Runner: This service is designed for containerized web applications and APIs, and it can deploy directly from a container image.

  2. Amazon ECS (Elastic Container Service) or EKS (Elastic Kubernetes Service): These services are specifically for running and managing Docker containers.

  3. AWS Fargate: This is a serverless compute engine for containers that works with both ECS and EKS.

If you still want to use Amplify, you would need to restructure your application to fit Amplify's serverless model, which might involve separating the frontend and backend components and using other AWS services to host the Gradio backend.
Sources
Amplify build machines cannot install docker or build docker images | AWS re:Post
AWS Amplify FAQs | Front-End Web & Mobile | Amazon Web Services
Key considerations when using AWS for web hosting - Web Application Hosting in the AWS Cloud

profile picture
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • App Runner is the solution.

0

Hello.

As of March 2025, it seems that it is not possible to change the platform from the management console, so how about setting the platform using AWS CLI or similar as shown below?
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/amplify/update-app.html

aws amplify update-app --app-id your-appID --platform 'WEB_COMPUTE' --region ap-northeast-1
profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • I appreciate the quick answer. In the end, Amplify felt like a square peg round hole solution. Switched to App Runner and everything is silky. All the best.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions