Upshivam commited on
Commit
907a68d
·
1 Parent(s): 9d6f023

Add Dockerfile Generator Space

Browse files
Files changed (3) hide show
  1. README.md +7 -7
  2. app.py +38 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
- title: My Devops Space
3
- emoji: 📚
4
- colorFrom: green
5
- colorTo: green
6
  sdk: gradio
7
- sdk_version: 6.14.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: DevOps Dockerfile Generator
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: cyan
6
  sdk: gradio
7
+ sdk_version: 4.44.0
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
12
+ # 🐳 DevOps Dockerfile Generator
13
+ Generate production-ready Dockerfiles using AI!
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import anthropic
3
+
4
+ client = anthropic.Anthropic()
5
+
6
+ def generate_dockerfile(description, base_os, app_type):
7
+ prompt = f"""You are a DevOps expert. Generate a production-ready Dockerfile for:
8
+ Description: {description}
9
+ Base OS: {base_os}
10
+ App Type: {app_type}
11
+
12
+ Include:
13
+ - Multi-stage build if applicable
14
+ - Non-root user for security
15
+ - Health check
16
+ - Clear comments
17
+ Only return the Dockerfile content, nothing else."""
18
+
19
+ message = client.messages.create(
20
+ model="claude-opus-4-5",
21
+ max_tokens=1024,
22
+ messages=[{"role": "user", "content": prompt}]
23
+ )
24
+ return message.content[0].text
25
+
26
+ demo = gr.Interface(
27
+ fn=generate_dockerfile,
28
+ inputs=[
29
+ gr.Textbox(label="App Description", placeholder="e.g. A FastAPI app with PostgreSQL"),
30
+ gr.Dropdown(["ubuntu:22.04", "debian:slim", "alpine:3.18", "python:3.11-slim"], label="Base OS"),
31
+ gr.Dropdown(["Python/FastAPI", "Node.js", "Java/Spring", "Go", "React"], label="App Type")
32
+ ],
33
+ outputs=gr.Code(language="dockerfile", label="Generated Dockerfile"),
34
+ title="🐳 DevOps Dockerfile Generator",
35
+ description="Generate production-ready Dockerfiles instantly!"
36
+ )
37
+
38
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ anthropic