dockerimg: more exacting prompt for building a dockerfile
This morning's claude moving target has forgotten how a Dockerfile
works, and it tries injecting direct shell into the file. Tell it
everything should start with RUN.
For #83
For #85
diff --git a/dockerimg/testdata/testcreatedockerfile_python_misery.httprr b/dockerimg/testdata/testcreatedockerfile_python_misery.httprr
index 7124d60..6884221 100644
--- a/dockerimg/testdata/testcreatedockerfile_python_misery.httprr
+++ b/dockerimg/testdata/testcreatedockerfile_python_misery.httprr
@@ -1,9 +1,9 @@
httprr trace v1
-4052 2258
+4099 2020
POST https://api.anthropic.com/v1/messages HTTP/1.1
Host: api.anthropic.com
User-Agent: Go-http-client/1.1
-Content-Length: 3855
+Content-Length: 3902
Anthropic-Version: 2023-06-01
Content-Type: application/json
@@ -44,7 +44,7 @@
"properties": {
"extra_cmds": {
"type": "string",
- "description": "Extra commands to add to the dockerfile."
+ "description": "Extra dockerfile commands to add to the dockerfile. Each command should start with RUN."
}
}
}
@@ -54,24 +54,24 @@
Anthropic-Organization-Id: 3c473a21-7208-450a-a9f8-80aebda45c1b
Anthropic-Ratelimit-Input-Tokens-Limit: 200000
Anthropic-Ratelimit-Input-Tokens-Remaining: 200000
-Anthropic-Ratelimit-Input-Tokens-Reset: 2025-05-06T03:31:12Z
+Anthropic-Ratelimit-Input-Tokens-Reset: 2025-05-12T22:11:40Z
Anthropic-Ratelimit-Output-Tokens-Limit: 80000
Anthropic-Ratelimit-Output-Tokens-Remaining: 80000
-Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-06T03:31:16Z
+Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-12T22:11:43Z
Anthropic-Ratelimit-Requests-Limit: 4000
Anthropic-Ratelimit-Requests-Remaining: 3999
-Anthropic-Ratelimit-Requests-Reset: 2025-05-06T03:31:11Z
+Anthropic-Ratelimit-Requests-Reset: 2025-05-12T22:11:39Z
Anthropic-Ratelimit-Tokens-Limit: 280000
Anthropic-Ratelimit-Tokens-Remaining: 280000
-Anthropic-Ratelimit-Tokens-Reset: 2025-05-06T03:31:12Z
+Anthropic-Ratelimit-Tokens-Reset: 2025-05-12T22:11:40Z
Cf-Cache-Status: DYNAMIC
-Cf-Ray: 93b5673b6e3bce9c-SJC
+Cf-Ray: 93ed40c9d92215f1-SJC
Content-Type: application/json
-Date: Tue, 06 May 2025 03:31:16 GMT
-Request-Id: req_011CNqa2SbZGPRZ3VpTEzQeT
+Date: Mon, 12 May 2025 22:11:43 GMT
+Request-Id: req_011CP4QKbQFMdeMmEXsHZu1o
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
X-Robots-Tag: none
-{"id":"msg_01G7Rd33sjrAA319QvFpukeZ","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"Based on the README.md file, I can see that this project requires Python 3.11 and the DVC tool. I'll create a Dockerfile with appropriate extra commands to set up these requirements."},{"type":"tool_use","id":"toolu_01MQ46ddwZ7x3VerhB9uRJiR","name":"dockerfile","input":{"extra_cmds":"# Install Python 3.11 (attempt to continue on failure)\nRUN apt-get update && apt-get install -y --no-install-recommends python3.11 python3.11-venv python3.11-dev python3-pip || true\n\n# Set up Python 3.11 as default Python\nRUN if command -v python3.11 &> /dev/null; then \\\n update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 || true; \\\n fi\n\n# Install DVC tool\nRUN pip3 install dvc || true\n\n# Create and activate Python virtual environment if needed\nRUN if [ -f requirements.txt ]; then \\\n python3 -m venv .venv || true; \\\n source .venv/bin/activate || true; \\\n pip install -r requirements.txt || true; \\\n fi"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":1333,"cache_read_input_tokens":0,"output_tokens":317}}
\ No newline at end of file
+{"id":"msg_01LMhqAUGGGDV2JNbuY8YFha","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"I'll help you create a Dockerfile for this project by calling the dockerfile tool.\n\nBased on the README.md, I can see this project requires Python 3.11 and the dvc tool, which is a data version control tool often used in machine learning projects. While it's primarily a Go project (as you mentioned), it has Python dependencies that need to be set up carefully."},{"type":"tool_use","id":"toolu_01JGHWVxJLVratSmRX6pALHc","name":"dockerfile","input":{"extra_cmds":"RUN apt-get update && apt-get install -y python3.11 python3-pip || true\n\n# Install DVC (Data Version Control)\nRUN pip3 install --no-cache-dir dvc || true\n\n# Clean up apt cache to keep image smaller\nRUN apt-get clean && rm -rf /var/lib/apt/lists/*"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":1342,"cache_read_input_tokens":0,"output_tokens":216}}
\ No newline at end of file