Skip to content

Commit a3b8833

Browse files
committed
fix: dockerfile build for postgres (use prebuilt binaries)
1 parent 94f5c26 commit a3b8833

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

Dockerfile

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
11
ARG PG_VERSION=16
2-
3-
# Stage 1: Build the extension
4-
FROM rust:latest AS builder
5-
6-
ARG PG_VERSION=16
7-
8-
RUN apt-get update && apt-get install -y \
9-
wget \
10-
gnupg \
11-
lsb-release \
12-
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
13-
&& echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
14-
&& apt-get update \
15-
&& apt-get install -y postgresql-${PG_VERSION} postgresql-server-dev-${PG_VERSION}
16-
17-
WORKDIR /usr/src/typeid
18-
19-
COPY . .
20-
21-
RUN cargo install cargo-pgrx \
22-
&& cargo pgrx init --pg${PG_VERSION} /usr/lib/postgresql/${PG_VERSION}/bin/pg_config \
23-
&& cargo pgrx package --pg-config /usr/lib/postgresql/${PG_VERSION}/bin/pg_config
24-
25-
RUN ls -R /usr/src/typeid/target/release/
26-
27-
# Stage 2: Create the final Postgres image with the extension
282
FROM postgres:${PG_VERSION}
293

304
ARG PG_VERSION=16
315

32-
# Copy the built extension files from the builder stage
33-
# Copy the built extension files
34-
COPY --from=builder /usr/src/typeid/target/release/typeid-pg${PG_VERSION}/usr/lib/postgresql/${PG_VERSION}/lib/typeid.so /usr/lib/postgresql/${PG_VERSION}/lib/
35-
COPY --from=builder /usr/src/typeid/target/release/typeid-pg${PG_VERSION}/usr/share/postgresql/${PG_VERSION}/extension/typeid.control /usr/share/postgresql/${PG_VERSION}/extension/
36-
COPY --from=builder /usr/src/typeid/target/release/typeid-pg${PG_VERSION}/usr/share/postgresql/${PG_VERSION}/extension/typeid--0.1.0.sql /usr/share/postgresql/${PG_VERSION}/extension/
6+
RUN apt update && apt install -y curl
7+
RUN curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/main/install.sh | bash
378

389
# Enable the extension
3910
RUN echo "shared_preload_libraries = 'typeid'" >> /usr/share/postgresql/postgresql.conf.sample

install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ LIB_DIR=$("$PG_CONFIG" --pkglibdir)
5656

5757
# Install files
5858
echo "Installing TypeID extension..."
59-
sudo cp "$TMP_DIR"/usr/share/postgresql/*/extension/typeid.control "$EXTENSION_DIR"
60-
sudo cp "$TMP_DIR"/usr/share/postgresql/*/extension/typeid--*.sql "$EXTENSION_DIR"
61-
sudo cp "$TMP_DIR"/usr/lib/postgresql/*/lib/typeid.so "$LIB_DIR"
59+
cp "$TMP_DIR"/usr/share/postgresql/*/extension/typeid.control "$EXTENSION_DIR"
60+
cp "$TMP_DIR"/usr/share/postgresql/*/extension/typeid--*.sql "$EXTENSION_DIR"
61+
cp "$TMP_DIR"/usr/lib/postgresql/*/lib/typeid.so "$LIB_DIR"
6262

6363
# Clean up
6464
rm -rf "$TMP_DIR"

0 commit comments

Comments
 (0)