File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed
projects/code-gen automation Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.11-slim
2+
3+ WORKDIR /app
4+
5+ ENV PYTHONDONTWRITEBYTECODE=1 \
6+ PYTHONUNBUFFERED=1
7+
8+ # Ensure certs for TLS
9+ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
10+ && rm -rf /var/lib/apt/lists/*
11+
12+ # Install deps
13+ COPY requirements.txt ./
14+ RUN pip install --no-cache-dir -r requirements.txt
15+
16+ # App code
17+ COPY code_generator.py ./
18+ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
19+ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
20+
21+ # Create output directory (secret.txt is mounted at runtime)
22+ RUN mkdir -p /app/output
23+
24+ # Optionally allow passing token at runtime: -e GITHUB_TOKEN=...
25+ ENV GITHUB_TOKEN=""
26+
27+ ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh" ]
28+
Original file line number Diff line number Diff line change @@ -49,6 +49,47 @@ python code_generator.py "Two Sum" python --debug-connect --log-level DEBUG
4949- Endpoint: ` https://models.github.ai/inference `
5050- Model: ` openai/gpt-4o-mini `
5151
52+ ## Docker
53+
54+ Build the image:
55+ ``` bash
56+ docker build -t code-gen-cli:latest .
57+ ```
58+
59+ Run with token via env var (no volume needed):
60+ - PowerShell:
61+ ``` powershell
62+ docker run --rm -it ^
63+ -e GITHUB_TOKEN=ghp_xxx ^
64+ code-gen-cli:latest "Two Sum" python
65+ ```
66+ - bash:
67+ ``` bash
68+ docker run --rm -it \
69+ -e GITHUB_TOKEN=ghp_xxx \
70+ code-gen-cli:latest " Two Sum" python
71+ ```
72+
73+ Run with mounted ` secret.txt ` and persisted ` output/ ` :
74+ - PowerShell:
75+ ``` powershell
76+ docker run --rm -it ^
77+ -v "${PWD}\secret.txt:/app/secret.txt:ro" ^
78+ -v "${PWD}\output:/app/output" ^
79+ code-gen-cli:latest "Two Sum" python
80+ ```
81+ - bash:
82+ ``` bash
83+ docker run --rm -it \
84+ -v " $( pwd) /secret.txt:/app/secret.txt:ro" \
85+ -v " $( pwd) /output:/app/output" \
86+ code-gen-cli:latest " Two Sum" python
87+ ```
88+
89+ Notes:
90+ - If both env var and ` secret.txt ` are provided, ` secret.txt ` takes precedence (file is used).
91+ - Generated files are saved in ` /app/output ` ; mount it to keep results on the host.
92+
5293## How others can use this tool
53941 ) Fork this repository on GitHub
5495
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+ set -e
3+
4+ # If secret.txt is not present but GITHUB_TOKEN is set, create it
5+ if [ ! -f /app/secret.txt ] && [ -n " $GITHUB_TOKEN " ]; then
6+ echo " Writing token from GITHUB_TOKEN to /app/secret.txt"
7+ # Avoid trailing newline issues
8+ printf " %s" " $GITHUB_TOKEN " > /app/secret.txt
9+ fi
10+
11+ # Ensure output directory exists
12+ mkdir -p /app/output
13+
14+ exec python code_generator.py " $@ "
15+
16+
You can’t perform that action at this time.
0 commit comments