Skip to content

Commit 32dbb25

Browse files
author
Stephen Gutekanst
authored
add codeinsights-db deployment (#259)
* pure-docker: add codeinsights-db * test: add codeinsights-db permissions Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com> * prometheus: add codeinsights-db (optional) Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com> * docker-compose: add codeinsights-db Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com> * test: update expected # of containers Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
1 parent 8ba1cd7 commit 32dbb25

File tree

9 files changed

+66
-4
lines changed

9 files changed

+66
-4
lines changed

deploy-codeinsights-db.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Description: TimescaleDB time-series database for code insights data.
5+
#
6+
# Disk: 128GB / persistent SSD
7+
# Network: 1Gbps
8+
# Liveness probe: 5432/TCP
9+
# Ports exposed to other Sourcegraph services: 5432/TCP 9187/TCP
10+
# Ports exposed to the public internet: none
11+
#
12+
VOLUME="$HOME/sourcegraph-docker/codeinsights-db-disk"
13+
./ensure-volume.sh $VOLUME 999
14+
docker run --detach \
15+
--name=codeinsights-db \
16+
--network=sourcegraph \
17+
--restart=always \
18+
--cpus=4 \
19+
--memory=2g \
20+
-e POSTGRES_PASSWORD=password \
21+
-e PGDATA=/var/lib/postgresql/data/pgdata \
22+
-v $VOLUME:/var/lib/postgresql/data/ \
23+
index.docker.io/sourcegraph/codeinsights-db:insiders@sha256:f985af2fef860cc48be40ded864df025b8794b02b86e66cbc6c55bfe3c418831
24+
25+
# Note: You should deploy this as a container, do not try to connect it to your external
26+
# Postgres deployment (TimescaleDB is a bit special and most hosted Postgres deployments
27+
# do not support TimescaleDB, the data here is akin to gitserver's data, where losing it
28+
# would be bad but it can be rebuilt given enough time.)
29+
30+
echo "Deployed codeinsights-db service"

deploy-frontend-internal.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ docker run --detach \
2222
-e GOMAXPROCS=4 \
2323
-e PGHOST=pgsql \
2424
-e CODEINTEL_PGHOST=codeintel-db \
25+
-e CODEINSIGHTS_PGDATASOURCE=postgres://postgres:password@codeinsights-db:5432/postgres \
2526
-e SRC_GIT_SERVERS="$(addresses "gitserver-" $NUM_GITSERVER ":3178")" \
2627
-e SRC_SYNTECT_SERVER=http://syntect-server:9238 \
2728
-e SEARCHER_URL="$(addresses "http://searcher-" $NUM_SEARCHER ":3181")" \

deploy-frontend.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ docker run --detach \
2323
-e JAEGER_AGENT_HOST=jaeger \
2424
-e PGHOST=pgsql \
2525
-e CODEINTEL_PGHOST=codeintel-db \
26+
-e CODEINSIGHTS_PGDATASOURCE=postgres://postgres:password@codeinsights-db:5432/postgres \
2627
-e SRC_GIT_SERVERS="$(addresses "gitserver-" $NUM_GITSERVER ":3178")" \
2728
-e SRC_SYNTECT_SERVER=http://syntect-server:9238 \
2829
-e SEARCHER_URL="$(addresses "http://searcher-" $NUM_SEARCHER ":3181")" \

deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ for i in $(seq 0 $(($NUM_GITSERVER - 1))); do ./deploy-gitserver.sh $i; done
1414
./deploy-precise-code-intel-worker.sh
1515
./deploy-pgsql.sh
1616
./deploy-codeintel-db.sh
17+
./deploy-codeinsights-db.sh
1718
./deploy-minio.sh
1819
./deploy-prometheus.sh
1920
./deploy-query-runner.sh

docker-compose/docker-compose.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ services:
7878
- JAEGER_AGENT_HOST=jaeger
7979
- PGHOST=pgsql
8080
- CODEINTEL_PGHOST=codeintel-db
81+
- CODEINSIGHTS_PGDATASOURCE=postgres://postgres:password@codeinsights-db:5432/postgres
8182
- 'SRC_GIT_SERVERS=gitserver-0:3178'
8283
- 'SRC_SYNTECT_SERVER=http://syntect-server:9238'
8384
- 'SEARCHER_URL=http://searcher-0:3181'
@@ -117,6 +118,7 @@ services:
117118
- GOMAXPROCS=4
118119
- PGHOST=pgsql
119120
- CODEINTEL_PGHOST=codeintel-db
121+
- CODEINSIGHTS_PGDATASOURCE=postgres://postgres:password@codeinsights-db:5432/postgres
120122
- 'SRC_GIT_SERVERS=gitserver-0:3178'
121123
- 'SRC_SYNTECT_SERVER=http://syntect-server:9238'
122124
- 'SEARCHER_URL=http://searcher-0:3181'
@@ -510,6 +512,30 @@ services:
510512
- sourcegraph
511513
restart: always
512514

515+
# Description: TimescaleDB time-series database for code insights data.
516+
#
517+
# Disk: 128GB / persistent SSD
518+
# Network: 1Gbps
519+
# Ports exposed to other Sourcegraph services: 5432/TCP 9187/TCP
520+
# Ports exposed to the public internet: none
521+
#
522+
# Note: You should deploy this as a container, do not try to connect it to your external
523+
# Postgres deployment (TimescaleDB is a bit special and most hosted Postgres deployments
524+
# do not support TimescaleDB, the data here is akin to gitserver's data, where losing it
525+
# would be bad but it can be rebuilt given enough time.)
526+
codeinsights-db:
527+
container_name: codeinsights-db
528+
image: "index.docker.io/sourcegraph/codeinsights-db:insiders@sha256:f985af2fef860cc48be40ded864df025b8794b02b86e66cbc6c55bfe3c418831"
529+
cpus: 4
530+
mem_limit: "2g"
531+
environment:
532+
- POSTGRES_PASSWORD=password
533+
volumes:
534+
- "codeinsights-db:/data/"
535+
networks:
536+
- sourcegraph
537+
restart: always
538+
513539
# Description: MinIO for storing LSIF uploads.
514540
#
515541
# Disk: 128GB / persistent SSD
@@ -577,6 +603,7 @@ volumes:
577603
grafana:
578604
pgsql:
579605
codeintel-db:
606+
codeinsights-db:
580607
minio:
581608
prometheus-v2:
582609
redis-cache:

prometheus/prometheus_targets.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Uncomment these if you want to monitor PostgreSQL / Redis via Prometheus.
66
#- pgsql:9187
77
#- codeintel-db:9187
8+
#- codeinsights-db:9187
89
#- redis-cache:9121
910
#- redis-store:9121
1011
- labels:

teardown.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ docker rm -f jaeger &> /dev/null || true
1313
docker rm -f precise-code-intel-worker &> /dev/null || true
1414
docker rm -f pgsql &> /dev/null || true &
1515
docker rm -f codeintel-db &> /dev/null || true &
16+
docker rm -f codeinsights-db &> /dev/null || true &
1617
docker rm -f minio &> /dev/null || true &
1718
docker rm -f prometheus &> /dev/null || true
1819
docker rm -f query-runner &> /dev/null || true &

test/smoke-test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ deploy_sourcegraph() {
1010

1111
if [[ "$GIT_BRANCH" == *"customer-replica"* ]]; then
1212
# Expected number of containers on e.g. 3.18-customer-replica branch.
13-
expect_containers="59"
13+
expect_containers="60"
1414
else
1515
# Expected number of containers on `master` branch.
16-
expect_containers="24"
16+
expect_containers="25"
1717
fi
1818
elif [[ "$TEST_TYPE" == "docker-compose-test" ]]; then
1919
docker-compose --file docker-compose/docker-compose.yaml up -d
20-
expect_containers="22"
20+
expect_containers="23"
2121
fi
2222

2323
echo "Giving containers 30s to start..."

test/volume-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ pushd ~/sourcegraph-docker
2121
chown -R 100:101 gitserver* prometheus-v2* repo-updater* searcher* sourcegraph-frontend* symbols* zoekt* minio-disk
2222
chown -R 999:1000 redis-store-disk redis-cache-disk
2323
chown -R 472:472 grafana-disk
24-
chown -R 999:999 pgsql-disk codeintel-db-disk
24+
chown -R 999:999 pgsql-disk codeintel-db-disk codeinsights-db-disk
2525
popd
2626
echo "Ready to deploy"

0 commit comments

Comments
 (0)