Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG BASE_TAG
ARG DEBIAN_RELEASE
ARG PGVECTOR_VERSION
FROM postgres:${BASE_TAG}-${DEBIAN_RELEASE} AS builder

RUN apt-get update && \
apt-get install -y unzip build-essential git wget libbrotli-dev
apt-get install -y unzip build-essential git wget libbrotli-dev postgresql-server-dev-$PG_MAJOR

# Install Golang
RUN wget https://go.dev/dl/go1.19.1.linux-amd64.tar.gz && \
Expand Down Expand Up @@ -33,6 +33,16 @@ RUN git checkout v2.0.1 && \
RUN ./main/pg/wal-g --version && \
cp ./main/pg/wal-g /wal-g-v2.0.1

# Build pgvector extension
WORKDIR /tmp
RUN wget https://github.com/pgvector/pgvector/archive/refs/tags/v${PGVECTOR_VERSION}.tar.gz && \
tar -xzf v${PGVECTOR_VERSION}.tar.gz && \
rm v${PGVECTOR_VERSION}.tar.gz && \
mv pgvector-${PGVECTOR_VERSION} pgvector

WORKDIR /tmp/pgvector
RUN make && make DESTDIR=/pgvector_install install

ARG BASE_TAG
ARG DEBIAN_RELEASE
FROM postgres:${BASE_TAG}-${DEBIAN_RELEASE}
Expand All @@ -57,6 +67,7 @@ RUN apt-get update && apt-get upgrade -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /pgvector_install /
COPY --from=builder /wal-g-v1.1 /usr/local/bin/wal-g-v1.1
COPY --from=builder /wal-g-v2.0.1 /usr/local/bin/wal-g-v2.0.1

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
space := $(subst ,, )
PGHOST := $(shell ip -json addr|jq -r '.[] | select(.ifname | test("^docker0$$")) | .addr_info[] | select(.family | test("^inet$$")) | .local')

PGVECTOR_VERSION := 0.8.1

define build-image
@echo Base tag $1
@echo Postgis versions $2
@echo Debian release $3
docker build --pull --no-cache --build-arg BASE_TAG=${1} --build-arg POSTGIS_VERSIONS=${2} --build-arg DEBIAN_RELEASE=${3} -t camptocamp/postgres:${1}-postgis-$(subst $(space),-,${2}) .
docker build --pull --no-cache --build-arg BASE_TAG=${1} --build-arg POSTGIS_VERSIONS=${2} --build-arg DEBIAN_RELEASE=${3} --build-arg PGVECTOR_VERSION=${PGVECTOR_VERSION} -t camptocamp/postgres:${1}-postgis-$(subst $(space),-,${2}) .

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, syntax seems to be:

Suggested change
docker build --pull --no-cache --build-arg BASE_TAG=${1} --build-arg POSTGIS_VERSIONS=${2} --build-arg DEBIAN_RELEASE=${3} --build-arg PGVECTOR_VERSION=${PGVECTOR_VERSION} -t camptocamp/postgres:${1}-postgis-$(subst $(space),-,${2}) .
docker build --pull --no-cache --build-arg BASE_TAG=${1} --build-arg POSTGIS_VERSIONS=${2} --build-arg DEBIAN_RELEASE=${3} --build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) -t camptocamp/postgres:${1}-postgis-$(subst $(space),-,${2}) .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for the suggestion. The ${} syntax is used to fetch argument to the build-image function/macro. So if you would like to use a global variable you need to use this syntax : $()
I also push another fix in 94f6a19 to be able to use the PGVECTOR_VERSION in the Dockerfile.
ARG before FROM can only be used in the FROM line, if you need to use a variable in the body (other Dockerfile statement) you need to declare variable with ARG just after the FROM.

docker stop db || true
docker run --rm --name=db --detach --publish=5432:5432 --env=POSTGRES_USER=www-data --env=POSTGRES_PASSWORD=www-data --env=POSTGRES_DB=test camptocamp/postgres:${1}-postgis-$(subst $(space),-,${2})
sleep 10
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This image extends the [official PostgreSQL image](https://hub.docker.com/_/post
- [pgRouting](http://pgrouting.org/)
- [PostgreSQL contrib package](https://packages.debian.org/sid/postgresql-contrib-9.6)
- [Wal-g backup tools](https://github.com/wal-g/wal-g)
- [pgvector 0.8.1](https://github.com/pgvector/pgvector)

See the PostgreSQL image documentation for more details:
https://hub.docker.com/_/postgres/
Loading