Skip to content

Commit 0e27f26

Browse files
committed
Added CockroachDB Docker Compose setup for Simple Pongo sample
1 parent ca81e7f commit 0e27f26

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM haproxy:lts-bullseye
2+
3+
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
4+
5+
EXPOSE 26257
6+
EXPOSE 8080
7+
EXPOSE 8081
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
global
2+
log stdout format raw local0 info
3+
maxconn 20000
4+
5+
defaults
6+
log global
7+
timeout connect 10m
8+
timeout client 30m
9+
timeout server 30m
10+
option clitcpka
11+
option tcplog
12+
13+
listen cockroach-jdbc
14+
bind :26000
15+
mode tcp
16+
balance leastconn
17+
option httpchk GET /health?ready=1
18+
server roach-0 roach-0:26257 check port 8080
19+
server roach-1 roach-1:26257 check port 8080
20+
server roach-2 roach-2:26257 check port 8080
21+
22+
listen cockroach-ui
23+
bind :8080
24+
mode tcp
25+
balance leastconn
26+
option httpchk GET /health
27+
server roach-0 roach-0:8080 check port 8080
28+
server roach-1 roach-1:8080 check port 8080
29+
server roach-2 roach-2:8080 check port 8080
30+
31+
listen stats
32+
bind :8081
33+
mode http
34+
stats enable
35+
stats hide-version
36+
stats realm Haproxy\ Statistics
37+
stats uri /
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
version: '3.9'
2+
3+
# Took from: https://github.com/dbist/cockroach-docker
4+
# Connect to db console with: docker exec -it roach-0 ./cockroach sql --host=roach-0:26257 --insecure
5+
6+
services:
7+
roach-0:
8+
container_name: roach-0
9+
hostname: roach-0
10+
image: cockroachdb/cockroach-unstable:v23.2.0-beta.1
11+
command: start --insecure --join=roach-0,roach-1,roach-2 --listen-addr=roach-0:26257 --advertise-addr=roach-0:26257 --max-sql-memory=.25 --cache=.25
12+
environment:
13+
- 'ALLOW_EMPTY_PASSWORD=yes'
14+
- 'COCKROACH_USER=postgres'
15+
- 'COCKROACH_PASSWORD=postgres'
16+
- 'COCKROACH_DATABASE=postgres'
17+
18+
roach-1:
19+
container_name: roach-1
20+
hostname: roach-1
21+
image: cockroachdb/cockroach-unstable:v23.2.0-beta.1
22+
command: start --insecure --join=roach-0,roach-1,roach-2 --listen-addr=roach-1:26257 --advertise-addr=roach-1:26257 --max-sql-memory=.25 --cache=.25
23+
environment:
24+
- 'ALLOW_EMPTY_PASSWORD=yes'
25+
- 'COCKROACH_USER=postgres'
26+
- 'COCKROACH_PASSWORD=postgres'
27+
- 'COCKROACH_DATABASE=postgres'
28+
29+
roach-2:
30+
container_name: roach-2
31+
hostname: roach-2
32+
image: cockroachdb/cockroach-unstable:v23.2.0-beta.1
33+
command: start --insecure --join=roach-0,roach-1,roach-2 --listen-addr=roach-2:26257 --advertise-addr=roach-2:26257 --max-sql-memory=.25 --cache=.25
34+
environment:
35+
- 'ALLOW_EMPTY_PASSWORD=yes'
36+
- 'COCKROACH_USER=postgres'
37+
- 'COCKROACH_PASSWORD=postgres'
38+
- 'COCKROACH_DATABASE=postgres'
39+
40+
init:
41+
container_name: init
42+
image: cockroachdb/cockroach-unstable:v23.2.0-beta.1
43+
command: init --host=roach-0 --insecure
44+
environment:
45+
- 'ALLOW_EMPTY_PASSWORD=yes'
46+
- 'COCKROACH_USER=postgres'
47+
- 'COCKROACH_PASSWORD=postgres'
48+
- 'COCKROACH_DATABASE=postgres'
49+
depends_on:
50+
- roach-0
51+
52+
lb:
53+
container_name: lb
54+
hostname: lb
55+
build: cockroachdb/haproxy
56+
ports:
57+
- '5432:26000'
58+
- '8080:8080'
59+
- '8081:8081'
60+
depends_on:
61+
- roach-0
62+
- roach-1
63+
- roach-2
64+
65+
client:
66+
container_name: client
67+
hostname: client
68+
image: cockroachdb/cockroach-unstable:v23.2.0-beta.1
69+
entrypoint: ['/usr/bin/tail', '-f', '/dev/null']

samples/simple-ts/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type User = { _id?: string; name: string; age: number };
55

66
const connectionString =
77
'postgresql://postgres:postgres@localhost:5432/postgres';
8+
// 'postgresql://root@localhost:26000/defaultdb?sslmode=disable'; // cockroachdb
89

910
const pongo = pongoClient(connectionString);
1011
const pongoDb = pongo.db();

samples/simple-ts/src/shim.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type User = { name: string; age: number };
44

55
const connectionString =
66
'postgresql://postgres:postgres@localhost:5432/postgres';
7+
// 'postgresql://root@localhost:26000/defaultdb?sslmode=disable'; // cockroachdb
78

89
const pongoClient = new MongoClient(connectionString);
910
const pongoDb = pongoClient.db('postgres');

samples/simple-ts/src/typedClient.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import config from './pongo.config';
44

55
const connectionString =
66
'postgresql://postgres:postgres@localhost:5432/postgres';
7+
// 'postgresql://root@localhost:26000/defaultdb?sslmode=disable'; // cockroachdb
78

89
const pongo = pongoClient(connectionString, {
910
schema: { definition: config.schema, autoMigration: 'None' },

0 commit comments

Comments
 (0)