Skip to content

Commit b6b4e6d

Browse files
Merge branch 'feat/sql-editor-syntax-highlighting' of https://github.com/mohamadyasser118/pgwatch into feat/sql-editor-syntax-highlighting
2 parents f86c803 + ddeba19 commit b6b4e6d

39 files changed

Lines changed: 1289 additions & 717 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Protobuf files
1616
*.pb.go
1717

18-
# Packages ouput folder
18+
# Packages output folder
1919
dist
2020
docs/godoc
2121
site
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM timescale/timescaledb:latest-pg18
2+
3+
# Install plpython3u
4+
RUN set -ex && apk add --virtual .plpython3-deps --no-cache py3-psutil --repository http://nl.alpinelinux.org/alpine/edge/testing postgresql-plpython3

docker/compose.timescaledb.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
services:
22
postgres:
33
user: postgres
4-
image: &pgimage timescale/timescaledb:latest-pg17
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.timescaledb-plpython3u
7+
# image: &pgimage timescale/timescaledb:latest-pg18
58
container_name: postgres
69
command:
710
- "-cshared_preload_libraries=pg_stat_statements,timescaledb"
811
- "-cpg_stat_statements.track=all"
12+
- "-cpg_stat_statements.track_planning=on"
913
- "-ctrack_io_timing=on"
1014
- "-ctrack_functions=pl"
15+
- "-clog_destination=csvlog"
16+
- "-clogging_collector=on"
1117
ports:
1218
- "5432:5432"
1319
environment:
1420
POSTGRES_HOST_AUTH_METHOD: trust
1521
volumes:
22+
- "pgdata:/var/lib/postgresql/docker"
1623
- "./bootstrap/init_replication.sh:/docker-entrypoint-initdb.d/init_replication.sh"
1724
- "./bootstrap/create_role_db.sql:/docker-entrypoint-initdb.d/create_role_db.sql"
1825
healthcheck:
@@ -23,7 +30,10 @@ services:
2330

2431
postgres-standby:
2532
user: postgres
26-
image: *pgimage
33+
build:
34+
context: .
35+
dockerfile: Dockerfile.timescaledb-plpython3u
36+
# image: *pgimage
2737
container_name: postgres-standby
2838
environment:
2939
POSTGRES_PASSWORD: standbypass
@@ -35,9 +45,37 @@ services:
3545
condition: service_healthy
3646
command: >
3747
bash -c "
38-
rm -rf /var/lib/postgresql/data/* &&
39-
pg_basebackup -h postgres --pgdata=/var/lib/postgresql/data --wal-method=stream --progress --write-recovery-conf --create-slot --slot=standby_slot &&
40-
chmod 0700 /var/lib/postgresql/data &&
41-
postgres"
48+
echo 'Setting up standby server...'
49+
export PGDATA=/var/lib/postgresql/standby
50+
51+
# Check if data directory already exists and is initialized
52+
if [ -f /var/lib/postgresql/standby/PG_VERSION ]; then
53+
echo 'Data directory already exists and is initialized, starting PostgreSQL...'
54+
else
55+
echo 'Initializing new standby server...'
56+
57+
# Create replication slot if it doesn't exist
58+
psql -h postgres -U postgres -c \"SELECT * FROM pg_create_physical_replication_slot('standby_slot');\" 2>/dev/null || true
59+
60+
# Create custom data directory with correct permissions
61+
mkdir -p /var/lib/postgresql/standby
62+
chmod 0700 /var/lib/postgresql/standby
63+
64+
# Remove any existing files to ensure clean backup
65+
rm -rf /var/lib/postgresql/standby/* || true
66+
67+
# Create base backup directly to our custom directory
68+
pg_basebackup -h postgres -U postgres -D /var/lib/postgresql/standby -Xs -P -R -S standby_slot
69+
70+
# Ensure correct permissions after backup
71+
chmod 0700 /var/lib/postgresql/standby
72+
fi
73+
74+
# Start PostgreSQL with custom data directory
75+
exec postgres -D /var/lib/postgresql/standby -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c track_io_timing=on -c track_functions=pl -c log_destination=csvlog -c logging_collector=on
76+
"
4277
links:
4378
- postgres
79+
80+
volumes:
81+
pgdata:

docker/demo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ EXPOSE 9187
120120
# pprof port
121121
EXPOSE 6060
122122

123-
### Volumes for easier updating to newer to newer pgwatch containers
123+
### Volumes for easier updating to newer pgwatch containers
124124
### Backwards compatibility is not 100% guaranteed so a backup
125125
### using traditional means is still recommended before updating - see "Updating to a newer Docker version" from README
126126

0 commit comments

Comments
 (0)