- Streamlit: https://huggingface.co/spaces/DockerTemplates/streamlit-docker-example
- Gradio: https://huggingface.co/spaces/sayakpaul/demo-docker-gradio
- HTTP w GO: https://huggingface.co/spaces/XciD/test-docker-go?q=Adrien
- Secrets: https://huggingface.co/spaces/DockerTemplates/secret-example
- Fast API: https://huggingface.co/spaces/DockerTemplates/fastapi_t5
π Create a Dockerfile for Gradio deployment π
1οΈβ£ Start by specifying the base image for your container. For Python:
FROM python:3.8-slim-buster
2οΈβ£ Set the working directory for the container and copy the necessary files:
WORKDIR /app COPY . /app
3οΈβ£ Install the necessary dependencies, including Gradio:
RUN pip install --upgrade pip &&
pip install gradio
4οΈβ£ Specify the command to run when the container starts:
CMD ["python", "app.py"]
π Build and push your container image to Azure Container Registry π
π Set up a GitHub Actions workflow for deployment π
Use azure/login action for Azure authentication and azure/container-apps-deploy-action for deployment. Provide necessary inputs like container app name, Azure Container Registry name, and container image tag.
Here's an example GitHub Actions workflow: name: Deploy to Azure Container Apps
on: push: branches: - main
env: AZURE_CONTAINER_APP_NAME: AZURE_CONTAINER_REGISTRY_NAME: IMAGE_TAG: ${{ github.sha }}
jobs: deploy: runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v2
-
name: Login to Azure uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }}
-
name: Deploy to Azure Container Apps uses: azure/container-apps-deploy-action@v1 with: containerAppName:
{{ env.AZURE_CONTAINER_REGISTRY_NAME }}.azurecr.io/myimage:${{ env.IMAGE_TAG }}
5οΈβ£ Commit and push your changes π
Once you've made all necessary changes to your Dockerfile and GitHub Actions workflow file, commit and push them to your repository.
git add .
git commit -m "Setup Dockerfile and GitHub Actions workflow"
git push origin main
6οΈβ£ Watch your GitHub Actions workflow π
Go to the "Actions" tab in your GitHub repository to see your workflow in action. If everything is set up correctly, you should see your workflow running and completing without errors.
7οΈβ£ Check your app on Azure Container Apps π
Once the GitHub Actions workflow has completed, your app should be deployed to Azure Container Apps. You can check the status of your app in the Azure portal.
8οΈβ£ Enjoy your Gradio app running smoothly on Azure Container Apps π
You've successfully deployed your Gradio app to Azure Container Apps using a Docker container and GitHub Actions!