Repository navigation
feat: fixed docker #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,36 +10,51 @@ Postal provides Docker support through a pre-built container image that includes | |||||
|
|
||||||
| ### Using Docker Compose | ||||||
|
|
||||||
| 1. **Build and start the container** | ||||||
| Postal's interface is a full-screen terminal UI, so it needs an attached TTY. | ||||||
| Run it in the foreground rather than detached: | ||||||
|
|
||||||
| ```bash | ||||||
| cd docker | ||||||
| API_KEY="your_openrouter_api_key" docker-compose up -d | ||||||
| API_KEY="your_openrouter_api_key" docker compose run --rm postal | ||||||
| ``` | ||||||
|
|
||||||
| 2. **Connect to your workspace** | ||||||
| The service mounts your current directory (`$POSTAL_WORKSPACE:-..`) as | ||||||
| `/workspace` inside the container. Use `exit` (or Ctrl-C) to leave the UI; the | ||||||
| container is removed afterwards. | ||||||
|
|
||||||
| The container mounts your current directory (`$POSTAL_WORKSPACE:-..`) as `/workspace` inside the container. You can now interact with your code through Postal. | ||||||
| If you already started it detached with `docker compose up -d`, reattach with | ||||||
| `docker attach postal` — the UI is still running and waiting for input. | ||||||
|
|
||||||
| ### Using Docker Image Directly | ||||||
|
|
||||||
| 1. **Build the image** | ||||||
|
|
||||||
| ```bash | ||||||
| docker build -t postal:dev .. | ||||||
| docker build -t postal:dev -f docker/Dockerfile .. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command mixes two working directories. From the repository root,
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: docker/README.md
Line: 33
Comment:
**Docker build paths conflict**
The command mixes two working directories. From the repository root, `docker/Dockerfile` exists, but context `..` makes `COPY pyproject.toml README.md LICENSE /stub/` look outside the repository. From `docker/`, the context is right, but `docker/Dockerfile` does not exist. Use `docker build -t postal:dev -f docker/Dockerfile .` from the repository root.
```suggestion
docker build -t postal:dev -f docker/Dockerfile .
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||||||
| ``` | ||||||
|
|
||||||
| 2. **Run the container** | ||||||
|
|
||||||
| `-it` is required: without a TTY the UI cannot start. | ||||||
|
|
||||||
| ```bash | ||||||
| docker run -d \ | ||||||
| docker run --rm -it \ | ||||||
| --name postal \ | ||||||
| -v "$(pwd):/workspace" \ | ||||||
| -v "$(pwd)/.postal:/config" \ | ||||||
| -v postal-config:/config \ | ||||||
| -e API_KEY="your_openrouter_api_key" \ | ||||||
| postal:dev | ||||||
| ``` | ||||||
|
|
||||||
| For a one-shot prompt instead of the interactive UI, no TTY is needed: | ||||||
|
|
||||||
| ```bash | ||||||
| docker run --rm \ | ||||||
| -v "$(pwd):/workspace" -v postal-config:/config \ | ||||||
| -e API_KEY="your_openrouter_api_key" \ | ||||||
| postal:dev "explain this codebase" | ||||||
| ``` | ||||||
|
|
||||||
| ## Configuration | ||||||
|
|
||||||
| ### Environment Variables | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import asyncio | ||
| import unittest | ||
| from unittest.mock import patch | ||
|
|
||
| from config.config import Config | ||
| from ui.repl.app import Repl | ||
|
|
||
|
|
||
| class ReplTerminalTests(unittest.TestCase): | ||
| def run_repl(self, isatty: bool): | ||
| with patch("ui.repl.app.sys.stdin") as stdin, patch("ui.repl.app.shutil.which") as which: | ||
| stdin.isatty.return_value = isatty | ||
| which.return_value = "/usr/bin/node" | ||
| with patch("ui.repl.app.asyncio.create_subprocess_exec") as spawn: | ||
| with self.assertRaises(RuntimeError) as raised: | ||
| asyncio.run(Repl(Config()).run()) | ||
|
Comment on lines
+10
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a developer has the documented Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/test_repl.py
Line: 10-16
Comment:
**Tests inherit the wrong interface**
If a developer has the documented `POSTAL_UI=textual` setting, `Repl.run()` starts `PostalApp` before reaching the terminal check. These tests then exercise the wrong interface and can fail or wait for input. Clear or override `POSTAL_UI` in `run_repl` so both tests always select the TypeScript interface.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| return raised.exception, which, spawn | ||
|
|
||
| def test_missing_tty_explains_how_to_run_in_docker(self): | ||
| error, which, spawn = self.run_repl(isatty=False) | ||
|
|
||
| message = str(error) | ||
| self.assertIn("needs a terminal", message) | ||
| self.assertIn("docker run -it", message) | ||
| self.assertIn("docker exec -it", message) | ||
| self.assertIn("postal \"your prompt\"", message) | ||
| which.assert_not_called() | ||
| spawn.assert_not_called() | ||
|
|
||
| def test_missing_tty_does_not_require_node(self): | ||
| error, which, _ = self.run_repl(isatty=False) | ||
|
|
||
| self.assertNotIn("Node.js", str(error)) | ||
| which.assert_not_called() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIKTOKEN_CACHE_DIRnow applies only to the test step. The earlier “Cache tokenizer data” step fills the default cache, while the tests use a separate directory and download the same data again. Give both steps the same value, preferably through a job-levelenv, so the tests reuse the downloaded data.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!