Skip to content

Commit d6182cf

Browse files
fix: update emulator configuration to use consistent environment variables
Co-Authored-By: Rushil Srivastava <[email protected]>
1 parent 7da0787 commit d6182cf

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

Dockerfile.emulator

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM ghcr.io/aertje/cloud-tasks-emulator:latest
2+
RUN apk add --no-cache wget

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3'
2+
services:
3+
cloud-tasks-emulator:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.emulator
7+
command: /emulator -host 0.0.0.0 -port 8123 -grpc_port 8124
8+
ports:
9+
- "8123:8123"
10+
- "8124:8124"
11+
healthcheck:
12+
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8123/v1/projects/test-project/locations/us-central1/queues"]
13+
interval: 1s
14+
timeout: 3s
15+
retries: 30
16+
tests:
17+
image: python:3.11
18+
depends_on:
19+
cloud-tasks-emulator:
20+
condition: service_healthy
21+
volumes:
22+
- .:/app
23+
working_dir: /app
24+
environment:
25+
- IS_LOCAL=true
26+
- CLOUD_TASKS_EMULATOR_HOST=cloud-tasks-emulator:8124
27+
- CLOUD_TASKS_EMULATOR_URL=cloud-tasks-emulator:8124
28+
- TASK_LISTENER_BASE_URL=http://localhost:8000
29+
- TASK_PROJECT_ID=test-project
30+
- TASK_LOCATION=us-central1
31+
- TASK_QUEUE=test-queue
32+
command: >
33+
bash -c "pip install poetry &&
34+
poetry install &&
35+
poetry run pytest tests/ -v"

examples/full/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
SCHEDULED_LOCATION = os.getenv("SCHEDULED_LOCATION", default="us-central1")
2020
TASK_QUEUE = os.getenv("TASK_QUEUE", default="test-queue")
2121

22-
CLOUD_TASKS_EMULATOR_URL = os.getenv("CLOUD_TASKS_EMULATOR_URL", "localhost:8123")
22+
CLOUD_TASKS_EMULATOR_HOST = os.getenv("CLOUD_TASKS_EMULATOR_HOST", "localhost:8124")
2323

2424
TASK_SERVICE_ACCOUNT = os.getenv(
2525
"TASK_SERVICE_ACCOUNT",

examples/full/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
delayed_client = None
3838
if IS_LOCAL:
39-
delayed_client = emulator_client(host=CLOUD_TASKS_EMULATOR_URL)
39+
delayed_client = emulator_client()
4040

4141
DelayedRoute = DelayedRouteBuilder(
4242
client=delayed_client,

0 commit comments

Comments
 (0)