Skip to content

Commit 8082cff

Browse files
authored
Merge pull request #20 from ilyas829/final
Final
2 parents bdf5635 + 0a19d66 commit 8082cff

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+

projects/code-gen automation/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff 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
5394
1) Fork this repository on GitHub
5495

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+

0 commit comments

Comments
 (0)