Spaces:
Sleeping
Sleeping
File size: 1,483 Bytes
907a68d 7f28ec8 f049c71 907a68d 7f28ec8 9e109e0 7f28ec8 907a68d 9e109e0 907a68d 7f28ec8 78e641c 9e109e0 78e641c f049c71 907a68d 78e641c 907a68d f049c71 907a68d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import gradio as gr
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
model="Qwen/Qwen2.5-72B-Instruct",
token=os.environ.get("HF_TOKEN")
)
def generate_dockerfile(description, base_os, app_type):
response = client.chat_completion(
messages=[
{
"role": "system",
"content": "You are a DevOps expert. Return ONLY Dockerfile content, no explanation, no markdown backticks."
},
{
"role": "user",
"content": f"""Generate a production-ready Dockerfile for:
Description: {description}
Base OS: {base_os}
App Type: {app_type}
Include:
- Multi-stage build if applicable
- Non-root user for security
- Health check
- Clear comments"""
}
],
max_tokens=800,
temperature=0.3
)
return response.choices[0].message.content
demo = gr.Interface(
fn=generate_dockerfile,
inputs=[
gr.Textbox(label="App Description", placeholder="e.g. A FastAPI app with PostgreSQL"),
gr.Dropdown(["ubuntu:22.04", "debian:slim", "alpine:3.18", "python:3.11-slim"], label="Base OS"),
gr.Dropdown(["Python/FastAPI", "Node.js", "Java/Spring", "Go", "React"], label="App Type")
],
outputs=gr.Code(language="dockerfile", label="Generated Dockerfile"),
title="🐳 DevOps Dockerfile Generator",
description="Generate production-ready Dockerfiles using FREE AI!"
)
demo.launch()
|