Skip to content

[FIX] fix alpine dependencies for pg_vector compilation#34

Open
Auneor wants to merge 1 commit intoTecnativa:masterfrom
Auneor:FIX_pg_vector_build
Open

[FIX] fix alpine dependencies for pg_vector compilation#34
Auneor wants to merge 1 commit intoTecnativa:masterfrom
Auneor:FIX_pg_vector_build

Conversation

@Auneor
Copy link

@Auneor Auneor commented Mar 3, 2026

I had errors when building image, leaving the image without pg_vector enabled.
This fix the build errors

@josep-tecnativa
Copy link
Contributor

Could you show what errors do you have please?

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

clang-19 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-format-truncation -O2 -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -flto=thin -emit-llvm -c -o src/bitutils.bc src/bitutils.c
make: clang-19: No such file or directory
make: *** [/usr/local/lib/postgresql/pgxs/src/makefiles/../../src/Makefile.global:1093: src/bitutils.bc] Error 127
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/community/x86_64/APKINDEX.tar.gz: No such file or directory
( 1/21) Purging .pgvector-build (20260303.105839)
( 2/21) Purging build-base (0.5-r3)

@josep-tecnativa
Copy link
Contributor

Which version are you trying to build? And how?

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

simon@ ~/git/docker-postgres-autoconf (master_tecnativa) $ git remote -v
origin https://github.com/Tecnativa/docker-postgres-autoconf (fetch)
origin https://github.com/Tecnativa/docker-postgres-autoconf (push)

simon@ ~/git/docker-postgres-autoconf (master_tecnativa) $ git status
Sur la branche master_tecnativa
Votre branche est à jour avec 'origin/master'.

Modifications qui ne seront pas validées :
(utilisez "git add ..." pour mettre à jour ce qui sera validé)
(utilisez "git restore ..." pour annuler les modifications dans le répertoire de travail)
modifié : Dockerfile

simon@ ~/git/docker-postgres-autoconf (master_tecnativa) $ git rev-parse HEAD
313f179

simon@ ~/git/docker-postgres-autoconf (master_tecnativa) $ git diff
diff --git a/Dockerfile b/Dockerfile
index f24e48d..2e5a5a4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
-ARG BASE_TAG
-FROM docker.io/postgres:${BASE_TAG}
+FROM docker.io/postgres:18-alpine
ENTRYPOINT [ "/autoconf-entrypoint" ]
CMD []
ARG PGVECTOR_VERSION=0.8.1

simon@ ~/git/docker-postgres-autoconf (master_tecnativa) $ docker build -t test-pgvector:1.0 .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/

Sending build context to Docker daemon 18.94kB
Step 1/10 : FROM docker.io/postgres:18-alpine
---> ff4a089dadda
Step 2/10 : ENTRYPOINT [ "/autoconf-entrypoint" ]
---> Using cache
---> a546397efd3b
Step 3/10 : CMD []
---> Using cache

SNIP

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wmissing-variable-declarations -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -march=native -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibility=hidden -shared -o vector.so src/bitutils.o src/bitvec.o src/halfutils.o src/halfvec.o src/hnsw.o src/hnswbuild.o src/hnswinsert.o src/hnswscan.o src/hnswutils.o src/hnswvacuum.o src/ivfbuild.o src/ivfflat.o src/ivfinsert.o src/ivfkmeans.o src/ivfscan.o src/ivfutils.o src/ivfvacuum.o src/sparsevec.o src/vector.o -L/usr/local/lib -L/usr/local/lib -Wl,--as-needed -fvisibility=hidden
cp sql/vector.sql sql/vector--0.8.1.sql
clang-19 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-format-truncation -O2 -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -flto=thin -emit-llvm -c -o src/bitutils.bc src/bitutils.c
make: clang-19: No such file or directory
make: *** [/usr/local/lib/postgresql/pgxs/src/makefiles/../../src/Makefile.global:1104: src/bitutils.bc] Error 127
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/community/x86_64/APKINDEX.tar.gz: No such file or directory
( 1/21) Purging .pgvector-build (20260303.130237)
( 2/21) Purging build-base (0.5-r3)
( 3/21) Purging file (5.46-r2)
( 4/21) Purging g++ (15.2.0-r2)
( 5/21) Purging libstdc++-dev (15.2.0-r2)
( 6/21) Purging gcc (15.2.0-r2)
( 7/21) Purging binutils (2.45.1-r0)
( 8/21) Purging libatomic (15.2.0-r2)
( 9/21) Purging libgomp (15.2.0-r2)
(10/21) Purging make (4.4.1-r3)
(11/21) Purging fortify-headers (1.1-r5)
(12/21) Purging patch (2.8-r0)
(13/21) Purging linux-headers (6.16.12-r0)
(14/21) Purging ca-certificates (20251003-r0)
Executing ca-certificates-20251003-r0.post-deinstall
(15/21) Purging isl26 (0.26-r1)
(16/21) Purging jansson (2.14.1-r0)
(17/21) Purging libmagic (5.46-r2)
(18/21) Purging mpc1 (1.3.1-r1)
(19/21) Purging mpfr4 (4.2.2-r0)
(20/21) Purging musl-dev (1.2.5-r21)
(21/21) Purging gmp (6.3.0-r4)
Executing busybox-1.37.0-r30.trigger
OK: 246.8 MiB in 64 packages
---> Removed intermediate container 4dfaa74f6e65

@josep-tecnativa
Copy link
Contributor

I can build v18 using this command:
docker build --build-arg BASE_TAG=18-alpine -t docker-postgres-autoconf:local .

And i have no problems. Could you try?

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

if i do your command with --no-cache i have the error:
docker build --build-arg BASE_TAG=18-alpine -t docker-postgres-autoconf:local .

cp sql/vector.sql sql/vector--0.8.1.sql
clang-19 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-format-truncation -O2 -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -flto=thin -emit-llvm -c -o src/bitutils.bc src/bitutils.c
make: clang-19: No such file or directory
make: *** [/usr/local/lib/postgresql/pgxs/src/makefiles/../../src/Makefile.global:1104: src/bitutils.bc] Error 127
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.23/community/x86_64/APKINDEX.tar.gz: No such file or directory
( 1/21) Purging .pgvector-build (20260303.141104)
( 2/21) Purging build-base (0.5-r3)
( 3/21) Purging file (5.46-r2)

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

docker build --build-arg BASE_TAG=18-alpine -t docker-postgres-autoconf:local . --no-cache

@josep-tecnativa
Copy link
Contributor

I can’t reproduce it: with BASE_TAG=18-alpine the build completes and I don’t see any clang-19 ... -emit-llvm step.
In your logs it does try to compile LLVM bitcode (*.bc) and fails because clang-19 is missing.

Could you paste the output of:

docker version
docker info | sed -n '1,120p'
docker buildx version || true
docker buildx ls || true
uname -m

and try forcing amd64:

DOCKER_BUILDKIT=1 docker build --no-cache --pull --platform=linux/amd64 \
  --build-arg BASE_TAG=18-alpine \
  -t docker-postgres-autoconf:local .

Also, are you on an ARM machine (Apple Silicon / ARM64 Linux) or using emulation (--platform / QEMU)? The base image and toolchain can differ between amd64 and arm64, which could explain why you hit the clang-19/LLVM bitcode path.

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

i'm on amd64:
simon@ ~ () $ docker version

docker info | sed -n '1,120p'
docker buildx version || true
docker buildx ls || true
uname -m
Client:
 Version:           28.2.2
 API version:       1.50
 Go version:        go1.23.1
 Git commit:        28.2.2-0ubuntu1~24.04.1
 Built:             Wed Sep 10 14:16:39 2025
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          28.2.2
  API version:      1.50 (minimum version 1.24)
  Go version:       go1.23.1
  Git commit:       28.2.2-0ubuntu1~24.04.1
  Built:            Wed Sep 10 14:16:39 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.28
  GitCommit:        
 runc:
  Version:          1.3.3-0ubuntu1~24.04.3
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        
Client:
 Version:    28.2.2
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  2.37.1+ds1-0ubuntu2~24.04.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 13
  Running: 12
  Paused: 0
  Stopped: 1
 Images: 140
 Server Version: 28.2.2
 Storage Driver: overlay2
  Backing Filesystem: zfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-94-generic
 Operating System: Ubuntu 24.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.23GiB
 Name: simon-Latitude-5510
 ID: 510650b3-aa82-45c1-be13-bc891b39d274
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

docker: unknown command: docker buildx

Run 'docker --help' for more information
docker: unknown command: docker buildx

Run 'docker --help' for more information
x86_64
simon@ ~ () $ 

@josep-tecnativa
Copy link
Contributor

Nice,

I can see that you don't have buildx installed.

I recomend you to install it. On Ubuntu 24.04 you can usually do:

sudo apt update
sudo apt install docker-buildx-plugin

Then, you will be able to build, for example, using this command:

DOCKER_BUILDKIT=1 docker build --no-cache --pull  --build-arg BASE_TAG=18-alpine  -t docker-postgres-autoconf:local .

Let me know if this works for you.

@Auneor
Copy link
Author

Auneor commented Mar 3, 2026

Hello Josep,
Upgrading my docker install and installing buildx it worked.
Thank you a lot.
But maybe check your image building infrastructure, because
ghcr.io/tecnativa/postgres-autoconf:18-alpine
Does not have pg_vector enabled that may be a bug on build?
(Or maybe i'm just misusing the images i would be very sorry if it would be the case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants