Skip to content

Commit c6bb8a5

Browse files
committed
Standardize on GOTENBERG_API_URL; fix devcontainer build
- Remove Yarn repo before apt-get in devcontainer (expired GPG key) - Consolidate to GOTENBERG_API_URL only (remove GOTENBERG_URL usage) - Use service name in docker-compose (gotenberg:3000) - Generalize utils.get_env() for any variable - Add Swarm deployment note for gotenberg.web hostname
1 parent f6419a2 commit c6bb8a5

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye
22

3+
# Remove Yarn repo (expired GPG key breaks apt-get update in base image)
4+
RUN rm -f /etc/apt/sources.list.d/yarn.list 2>/dev/null || true
5+
36
# Install system dependencies for document processing
47
RUN apt-get update && apt-get install -y \
58
libreoffice \

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ WORKDIR /code
44

55
# RUN python -m venv venv
66
# ENV PATH="venv/bin:$PATH"
7+
# Default for standalone runs; override in deployment (e.g. GOTENBERG_API_URL=http://gotenberg.web:3000 for Swarm)
78
ENV GOTENBERG_API_URL=http://host.docker.internal:3000
89

910
COPY ./requirements.txt /code/requirements.txt

TESTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ For CI/CD integration:
290290
run: |
291291
./run_tests.sh --skip-services
292292
env:
293-
GOTENBERG_URL: http://gotenberg:3000
293+
GOTENBERG_API_URL: http://gotenberg:3000
294294
DOCUMENT_SERVICE_URL: http://localhost:8000
295295
```
296296

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ services:
1616
ports:
1717
- "8000:8000"
1818
environment:
19-
- GOTENBERG_API_URL=http://gotenberg-service:3000
19+
- GOTENBERG_API_URL=http://gotenberg:3000
2020
- UNDEFINED_BEHAVIOR=debug

docs/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ This optimized image reduces cold start times and resource usage.
135135
|----------|-------------|---------|----------|
136136
| `GOTENBERG_API_URL` | URL to Gotenberg service | `http://host.docker.internal:3000` | Yes |
137137

138+
**Note:** Only `GOTENBERG_API_URL` is used. For Docker Swarm, use the service DNS name, e.g. `http://gotenberg.web:3000` when the Gotenberg service is in the `web` stack.
139+
138140
## Verification
139141

140142
After installation, verify everything is working:

tests/test_error_handling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Test configuration
2626
BASE_URL = "http://localhost:8000"
27-
GOTENBERG_URL = "http://localhost:3000"
27+
GOTENBERG_API_URL = "http://localhost:3000"
2828
TEST_FILES_DIR = Path("test_files")
2929

3030
# Ensure test files directory exists
@@ -47,7 +47,7 @@ def wait_for_services(timeout: int = 60):
4747
"""Wait for both services to be ready"""
4848
services = [
4949
(BASE_URL, "Document service"),
50-
(GOTENBERG_URL, "Gotenberg service")
50+
(GOTENBERG_API_URL, "Gotenberg service")
5151
]
5252

5353
for url, name in services:
@@ -202,7 +202,7 @@ def create_docx_from_html(html_content: str, output_path: Path):
202202
}
203203

204204
response = requests.post(
205-
f"{GOTENBERG_URL}/forms/libreoffice/convert",
205+
f"{GOTENBERG_API_URL}/forms/libreoffice/convert",
206206
files=files,
207207
timeout=30
208208
)

utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
env = dotenv_values('./.env')
55

66
def get_env(var_name: str) -> str:
7-
if 'GOTENBERG_API_URL' in os.environ:
8-
return os.environ['GOTENBERG_API_URL']
9-
return env[var_name]
7+
return os.environ.get(var_name) or env.get(var_name, "")
108

119
def remove_file(filename: str):
1210
file_path = 'temp/{}'.format(filename)

0 commit comments

Comments
 (0)