Skip to content

Commit e202c75

Browse files
committed
fix: pg-vector crashing on Apple macbooks when using gh actions image
1 parent 092938c commit e202c75

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ARG PG_VECTOR_VERSION=0.8.0
44
FROM imresamu/postgis:$PG_MAJOR-3.5-bookworm
55
ARG PG_MAJOR
66
ARG PG_VECTOR_VERSION
7+
ARG TARGETARCH
78

89
LABEL org.opencontainers.image.title="postgis-vector" \
910
org.opencontainers.image.description="postgresql+postgis container with pgvector added" \
@@ -25,8 +26,15 @@ RUN apt-get update \
2526
pgxnclient \
2627
postgresql-server-dev-$PG_MAJOR \
2728
&& git clone --branch v"${PG_VECTOR_VERSION}" https://github.com/pgvector/pgvector.git /tmp/pgvector \
29+
# Portable fast flags for ARM (the default flags crash on Apple m1 macbooks if image built in GitHub CI); native for AMD64
2830
&& cd /tmp/pgvector \
29-
&& make && make install \
31+
&& if [ "$TARGETARCH" = "arm64" ]; then \
32+
echo "Building pgvector for ARM64 (portable)"; \
33+
make OPTFLAGS="-O3 -march=armv8-a -mtune=generic" && make install; \
34+
else \
35+
echo "Building pgvector for AMD64 (native)"; \
36+
make OPTFLAGS="-O3 -march=native" && make install; \
37+
fi \
3038
&& cd / \
3139
&& rm -rf /tmp/pgvector \
3240
&& apt-get remove -y build-essential clang-13 llvm-13 llvm-13-dev postgresql-server-dev-$PG_MAJOR \

0 commit comments

Comments
 (0)