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_empty_repo.httprr b/dockerimg/testdata/testcreatedockerfile_empty_repo.httprr
index 5a4643f..b7e43a6 100644
--- a/dockerimg/testdata/testcreatedockerfile_empty_repo.httprr
+++ b/dockerimg/testdata/testcreatedockerfile_empty_repo.httprr
@@ -1,9 +1,9 @@
httprr trace v1
-3767 1928
+3814 2302
POST https://api.anthropic.com/v1/messages HTTP/1.1
Host: api.anthropic.com
User-Agent: Go-http-client/1.1
-Content-Length: 3570
+Content-Length: 3617
Anthropic-Version: 2023-06-01
Content-Type: application/json
@@ -40,7 +40,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."
}
}
}
@@ -50,24 +50,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:08Z
+Anthropic-Ratelimit-Input-Tokens-Reset: 2025-05-12T22:11:34Z
Anthropic-Ratelimit-Output-Tokens-Limit: 80000
Anthropic-Ratelimit-Output-Tokens-Remaining: 80000
-Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-06T03:31:10Z
+Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-12T22:11:38Z
Anthropic-Ratelimit-Requests-Limit: 4000
Anthropic-Ratelimit-Requests-Remaining: 3999
-Anthropic-Ratelimit-Requests-Reset: 2025-05-06T03:31:07Z
+Anthropic-Ratelimit-Requests-Reset: 2025-05-12T22:11:34Z
Anthropic-Ratelimit-Tokens-Limit: 280000
Anthropic-Ratelimit-Tokens-Remaining: 280000
-Anthropic-Ratelimit-Tokens-Reset: 2025-05-06T03:31:08Z
+Anthropic-Ratelimit-Tokens-Reset: 2025-05-12T22:11:34Z
Cf-Cache-Status: DYNAMIC
-Cf-Ray: 93b56723daa0ce9c-SJC
+Cf-Ray: 93ed40aa2a0a15f1-SJC
Content-Type: application/json
-Date: Tue, 06 May 2025 03:31:11 GMT
-Request-Id: req_011CNqa2AVC9m56dtxX5MqbJ
+Date: Mon, 12 May 2025 22:11:38 GMT
+Request-Id: req_011CP4QKDoEASpcodpKxqnmc
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
X-Robots-Tag: none
-{"id":"msg_01UEUtJaKVQygbeUjy9apyfW","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"I'll call the dockerfile tool to create a Dockerfile for your Go project. Based on the template provided, I'll add minimal but useful extra commands."},{"type":"tool_use","id":"toolu_01GSRQTjFTpsavcRqaZCKaRP","name":"dockerfile","input":{"extra_cmds":"# Install any Go tools specific to development\nRUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest || true\n\n# Install any Python dependencies if needed (allow failures)\nRUN if [ -f requirements.txt ]; then pip3 install -r requirements.txt || true; fi\n\n# Pre-compile the project if possible\nRUN if [ -f go.mod ]; then go build -v ./... || true; fi"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":1277,"cache_read_input_tokens":0,"output_tokens":195}}
\ No newline at end of file
+{"id":"msg_01CqJZHCyfadjtubpXjTZQax","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"I'll help you create a Dockerfile using the provided template. Based on your instructions, I need to create a minimal set of extra commands for a Go project, ensuring Python setup commands don't stop the build if they fail, and add safety measures to apt-get commands."},{"type":"tool_use","id":"toolu_01R7nDPwC4q2mK9em7o6zqja","name":"dockerfile","input":{"extra_cmds":"RUN go mod tidy || true\n\n# Install any Python dependencies if a requirements.txt exists, but continue on failure\nRUN if [ -f requirements.txt ]; then pip3 install -r requirements.txt || true; fi\n\n# Install any npm dependencies if package.json exists\nRUN if [ -f package.json ]; then npm install || true; fi\n\n# Install additional tools that might be useful for Go development\nRUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest || true\n\n# Install any additional needed packages\nRUN apt-get update && apt-get install -y --no-install-recommends \\\n make \\\n protobuf-compiler \\\n || true"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":1286,"cache_read_input_tokens":0,"output_tokens":278}}
\ No newline at end of file