forked from sqliteai/sqlite-sync
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.debug
More file actions
97 lines (84 loc) · 3.8 KB
/
Dockerfile.debug
File metadata and controls
97 lines (84 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# PostgreSQL Docker image with CloudSync extension (debug build)
FROM postgres:17
# Enable ASAN build flags when requested (used by docker-compose.asan.yml).
ARG ENABLE_ASAN=0
# Install build dependencies and debug symbols
RUN apt-get update && apt-get install -y \
ca-certificates \
gnupg \
wget \
&& . /etc/os-release \
&& echo "deb http://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& echo "deb-src http://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" > /etc/apt/sources.list.d/pgdg-src.list \
&& wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
&& echo "deb http://deb.debian.org/debian-debug ${VERSION_CODENAME}-debug main" > /etc/apt/sources.list.d/debian-debug.list \
&& echo "deb-src http://deb.debian.org/debian ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/debian-src.list \
&& apt-get update && apt-get install -y \
build-essential \
bison \
dpkg-dev \
flex \
gdb \
libicu-dev \
libreadline-dev \
libasan8 \
libssl-dev \
postgresql-server-dev-17 \
postgresql-17-dbgsym \
git \
make \
zlib1g-dev \
&& apt-get source postgresql-17 \
&& mkdir -p /usr/src/postgresql-17 \
&& srcdir="$(find . -maxdepth 1 -type d -name 'postgresql-17*' | head -n 1)" \
&& if [ -n "$srcdir" ]; then cp -a "$srcdir"/. /usr/src/postgresql-17/; fi \
&& rm -rf /var/lib/apt/lists/*
# Create directory for extension source
WORKDIR /tmp/cloudsync
# Build PostgreSQL from source without optimizations for better gdb visibility
RUN set -eux; \
cd /usr/src/postgresql-17; \
./configure --enable-debug --enable-cassert --without-icu CFLAGS="-O0 -g3 -fno-omit-frame-pointer"; \
make -j"$(nproc)"; \
make install
ENV PATH="/usr/local/pgsql/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/pgsql/lib:${LD_LIBRARY_PATH}"
# Copy entire source tree (needed for includes and makefiles)
COPY src/ ./src/
COPY modules/ ./modules/
COPY docker/ ./docker/
COPY Makefile .
# Build and install the CloudSync extension with debug flags
RUN set -eux; \
ASAN_CFLAGS=""; \
ASAN_LDFLAGS=""; \
if [ "${ENABLE_ASAN}" = "1" ]; then \
ASAN_CFLAGS="-fsanitize=address"; \
ASAN_LDFLAGS="-fsanitize=address"; \
fi; \
make postgres-build PG_DEBUG=1 \
PG_CFLAGS="-fPIC -Wall -Wextra -Wno-unused-parameter -std=c11 -g -O0 -fno-omit-frame-pointer ${ASAN_CFLAGS}" \
PG_LDFLAGS="-shared ${ASAN_LDFLAGS}" \
PG_CPPFLAGS="-I$(pg_config --includedir-server) -Isrc -Isrc/postgresql -Imodules/fractional-indexing -DCLOUDSYNC_POSTGRESQL_BUILD -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE" && \
make postgres-install PG_DEBUG=1 \
PG_CFLAGS="-fPIC -Wall -Wextra -Wno-unused-parameter -std=c11 -g -O0 -fno-omit-frame-pointer ${ASAN_CFLAGS}" \
PG_LDFLAGS="-shared ${ASAN_LDFLAGS}" \
PG_CPPFLAGS="-I$(pg_config --includedir-server) -Isrc -Isrc/postgresql -Imodules/fractional-indexing -DCLOUDSYNC_POSTGRESQL_BUILD -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE" && \
make postgres-clean
# Verify installation
RUN echo "Verifying CloudSync extension installation..." && \
ls -la $(pg_config --pkglibdir)/cloudsync.so && \
ls -la $(pg_config --sharedir)/extension/cloudsync* && \
echo "CloudSync extension installed successfully"
# Set default PostgreSQL credentials
ENV POSTGRES_PASSWORD=postgres
ENV POSTGRES_DB=cloudsync_test
# Expose PostgreSQL port
EXPOSE 5432
# Copy initialization script (creates CloudSync metadata tables)
COPY docker/postgresql/init.sql /docker-entrypoint-initdb.d/
# Return to root directory
WORKDIR /
# Add label with extension version
LABEL org.sqliteai.cloudsync.version="1.0" \
org.sqliteai.cloudsync.description="PostgreSQL with CloudSync CRDT extension (debug)"