Skip to content

Commit 9badd06

Browse files
committed
Add example compose files
1 parent b0826af commit 9badd06

File tree

8 files changed

+206
-54
lines changed

8 files changed

+206
-54
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY internal ./internal
1010

1111
RUN CGO_ENABLED=0 GOOS=linux go build -o /app
1212

13-
FROM alpine:3.20 as runner
13+
FROM alpine:3.20 AS runner
1414

1515
COPY --from=builder /app /app
1616

examples/.env.example.factorial

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/distributed/compose.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sets up a distributed Tobey instance that uses Redis for coordination.
2+
#
3+
# Use the following command to start up two tobey instances:
4+
# docker compose up
5+
#
6+
# Then hit the loadbalancer:
7+
# curl http://localhost:8080/ -X POST -d 'https://example.com'
8+
#
9+
# Now:
10+
# You should see a response from one of the tobey instances. If a crawl
11+
# request is made, than both instance will process the request.
12+
services:
13+
loadbalancer:
14+
image: nginx:latest
15+
ports:
16+
- "8080:80"
17+
volumes:
18+
- ./nginx.conf:/etc/nginx/nginx.conf
19+
20+
tobey-1:
21+
build:
22+
context: ../../
23+
environment:
24+
- TOBEY_REDIS_URL=redis://redis:6379
25+
- TOBEY_RESULT_REPORTER_DSN=disk:///tmp/tobey
26+
volumes:
27+
- tobey-cache:/cache
28+
29+
tobey-2:
30+
build:
31+
context: ../../
32+
environment:
33+
- TOBEY_REDIS_URL=redis://redis:6379
34+
- TOBEY_RESULT_REPORTER_DSN=disk:///tmp/tobey
35+
volumes:
36+
- tobey-cache:/cache
37+
38+
redis:
39+
image: redis:latest
40+
ports:
41+
- "6379:6379"
42+
43+
volumes:
44+
tobey-cache:

examples/distributed/nginx.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
upstream backend {
2+
server tobey-1:8080;
3+
server tobey-2:8080;
4+
}
5+
6+
server {
7+
listen 80;
8+
9+
include /etc/nginx/mime.types;
10+
11+
location / {
12+
proxy_pass http://backend;
13+
}
14+
}

examples/factorial/compose.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Sets up a tobey instance, similar to how we use it at Factorial.
2+
#
3+
# Use the following command:
4+
# docker compose up
5+
#
6+
# Then hit the tobey instance:
7+
# curl http://localhost:8080/ -X POST --header "Content-Type: application/json" -d '{
8+
# "url": "https://example.org",
9+
# "result_reporter_dsn": "webhook://webhook-catcher:8081/incoming"
10+
# }'
11+
#
12+
# Now:
13+
# - Access the Jaeger UI at http://localhost:16686/
14+
# - Access the Progress UI at http://localhost:9090/
15+
# - Access the Webhook Catcher UI at http://localhost:8081/
16+
17+
services:
18+
tobey:
19+
ports:
20+
- "8080:8080"
21+
build:
22+
context: ../../
23+
environment:
24+
- TOBEY_RESULT_REPORTER_DSN=disk:///tmp/tobey
25+
- TOBEY_DYNAMIC_CONFIG=true
26+
- TOBEY_USER_AGENT="WebsiteStandardsBot/1.0"
27+
- TOBEY_TELEMETRY="traces"
28+
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
29+
# - TOBEY_PROGRESS_DSN=factorial://progress:8080
30+
volumes:
31+
- tobey-cache:/cache
32+
33+
# progress:
34+
# image: wsd/progress:latest
35+
# environment:
36+
# - PROGRESS_DATABASE_URL=mysql://db:db@mysql:3306/progress
37+
# - OTEL_SERVICE_NAME=progress
38+
# - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
39+
# ports:
40+
# - "9090:8080"
41+
42+
mysql:
43+
image: mariadb
44+
environment:
45+
- MYSQL_USER=db
46+
- MYSQL_PASSWORD=db
47+
- MYSQL_ROOT_PASSWORD=root
48+
ports:
49+
- '3306:3306'
50+
expose:
51+
- '3306'
52+
volumes:
53+
- ./mysql/init:/docker-entrypoint-initdb.d
54+
- mysql-data:/var/lib/mysql
55+
jaeger:
56+
image: jaegertracing/all-in-one:latest
57+
ports:
58+
- "16686:16686"
59+
- "4318:4318"
60+
61+
webhook-catcher:
62+
image: tarampampam/webhook-tester:latest
63+
ports:
64+
- "8081:8080"
65+
environment:
66+
- STORAGE_DRIVER=memory
67+
- LOG_LEVEL=debug
68+
69+
70+
71+
volumes:
72+
tobey-cache:
73+
mysql-data:
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
# A docker compose file that sets up a Tobey instance that is instrumented and
22
# exposes metrics to Prometheus via /metrics endpoint. The metrics are then
33
# scraped by prometheus. Grafana is used to visualize the metrics scraped by
4-
# Prometheus. It also configures Redis for coordination.
4+
# Prometheus.
5+
#
6+
# Use the following command:
7+
# docker compose up
8+
#
9+
# Then hit the tobey instance:
10+
# curl http://localhost:8080/ -X POST -d 'https://example.com'
11+
#
12+
# Now:
13+
# - Access the Jaeger UI at http://localhost:16686/
14+
# - Access the Grafana UI at http://localhost:3000/ (admin/admin)
515

616
services:
717
tobey:
818
ports:
919
- "8080:8080"
1020
build:
11-
context: .
21+
context: ../../
1222
environment:
13-
- TOBEY_TELEMETRY=metrics
14-
- TOBEY_REDIS_URL=redis://redis:6379
15-
- TOBEY_RESULTS_URL=disk:///tmp/tobey
23+
- TOBEY_TELEMETRY="metrics traces"
24+
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
25+
- TOBEY_RESULT_REPORTER_DSN=disk:///tmp/tobey
1626
volumes:
1727
- tobey-cache:/cache
18-
# Optional healthcheck.
19-
healthcheck:
20-
test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
21-
interval: 30s
22-
timeout: 10s
23-
retries: 3
24-
start_period: 40s
25-
26-
redis:
27-
image: redis:latest
28-
ports:
29-
- "6379:6379"
3028

3129
prometheus:
3230
image: prom/prometheus
@@ -44,6 +42,13 @@ services:
4442
volumes:
4543
- grafana-data:/var/lib/grafana
4644

45+
jaeger:
46+
image: jaegertracing/all-in-one:latest
47+
ports:
48+
- "16686:16686"
49+
- "4318:4318"
50+
51+
4752
volumes:
4853
tobey-cache:
4954
grafana-data:

examples/pipelined/compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Sets up a tobey instance that is configured to serve requests within
2+
# a pipeline.
3+
#
4+
# Use the following command:
5+
# curl http://localhost:8080/ -X POST --header "Content-Type: application/json" -d '{
6+
# "url": "https://example.org",
7+
# "result_reporter_dsn": "webhook://webhook-catcher/incoming"
8+
# }'
9+
#
10+
# Now:
11+
# - Access the Webhook Catcher UI at http://localhost:8081/
12+
13+
services:
14+
tobey:
15+
ports:
16+
- "8080:8080"
17+
build:
18+
context: ../../
19+
environment:
20+
- TOBEY_DYNAMIC_CONFIG=true
21+
- TOBEY_RESULT_REPORTER_DSN=noop://
22+
volumes:
23+
- tobey-cache:/cache
24+
25+
webhook-catcher:
26+
image: tarampampam/webhook-tester:latest
27+
ports:
28+
- "8081:8080"
29+
environment:
30+
- STORAGE_DRIVER=memory
31+
- LOG_LEVEL=debug
32+
33+
volumes:
34+
tobey-cache:

examples/simple/compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Use the following command to start up two tobey instances:
2+
# docker compose up
3+
#
4+
# Then hit the tobey instance:
5+
# curl http://localhost:8080/ -X POST -d 'https://example.com'
6+
services:
7+
tobey:
8+
ports:
9+
- "8080:8080"
10+
build:
11+
context: ../../
12+
environment:
13+
- TOBEY_RESULT_REPORTER_DSN=disk:///tmp/tobey
14+
volumes:
15+
- tobey-cache:/cache
16+
17+
volumes:
18+
tobey-cache:

0 commit comments

Comments
 (0)