-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (50 loc) · 1.74 KB
/
Dockerfile
File metadata and controls
62 lines (50 loc) · 1.74 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
# Dockerfile for PostgreSQL 17 with pgraft extension
# Using Debian-based image for better CGO/Go shared library compatibility
FROM postgres:17
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
make \
libc6-dev \
postgresql-server-dev-17 \
golang-go \
git \
libjson-c-dev \
&& rm -rf /var/lib/apt/lists/*
# Set up build environment
WORKDIR /build
# Copy pgraft source code
COPY . /build/pgraft/
# Build pgraft extension
WORKDIR /build/pgraft
# Set CGO and Go build flags for optimal shared library compatibility
# CGO_ENABLED=1: Enable CGO for C interop
# CGO_CFLAGS: Optimization flags for C code
# CGO_LDFLAGS: Linker flags with proper soname
# GOFLAGS: Use netgo for pure Go networking (avoids glibc DNS issues)
ENV CGO_ENABLED=1
ENV CGO_CFLAGS="-g -O2"
ENV CGO_LDFLAGS="-Wl,-soname,pgraft_go.so"
ENV GOFLAGS="-tags=netgo"
RUN make clean && \
make all && \
cp pgraft.so /usr/lib/postgresql/17/lib/ && \
cp src/pgraft_go.so /usr/lib/postgresql/17/lib/ && \
cp pgraft.control /usr/share/postgresql/17/extension/ && \
cp pgraft--1.0.sql /usr/share/postgresql/17/extension/ && \
ls -lh /usr/lib/postgresql/17/lib/pgraft*.so && \
echo "✅ pgraft extension installed successfully"
# Clean up build dependencies (optional, keeps image smaller)
# Uncomment to reduce image size after build
# RUN apt-get purge -y gcc make libc6-dev postgresql-server-dev-17 golang-go git && \
# apt-get autoremove -y && \
# rm -rf /var/lib/apt/lists/*
# Reset working directory
WORKDIR /
# Set default PostgreSQL data directory
ENV PGDATA=/var/lib/postgresql/data
# Expose PostgreSQL port
EXPOSE 5432
# Use the default PostgreSQL entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["postgres"]