From a8b5e2fc56b447a46ce6f32b7623f3f5e67c3e8c Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Fri, 15 Nov 2024 08:59:54 +0200 Subject: [PATCH 1/5] Add docker stuff --- .dockerignore | 7 +++++++ Dockerfile | 19 +++++++++++++++++++ Makefile | 23 +++++++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..63ae811 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/.git/ +/dist/ +/results/ +/tmp_check/ +regression.* +*.o +*.so \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..75f159b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +ARG PG_MAJOR=17 +FROM postgres:$PG_MAJOR +ARG PG_MAJOR + +COPY . /tmp/pgpdf + +RUN apt-get update && \ + apt-mark hold locales && \ + apt-get install -y --no-install-recommends libpoppler-glib-dev pkg-config wget build-essential postgresql-server-dev-$PG_MAJOR && \ + cd /tmp/pgpdf && \ + make clean && \ + make install && \ + mkdir /usr/share/doc/pgpdf && \ + cp LICENSE README.md /usr/share/doc/pgpdf && \ + rm -r /tmp/pgpdf && \ + apt-get remove -y pkg-config wget build-essential postgresql-server-dev-$PG_MAJOR && \ + apt-get autoremove -y && \ + apt-mark unhold locales && \ + rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/Makefile b/Makefile index cc3062b..0a7f7e4 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PG_CONFIG = pg_config PKG_CONFIG = pkg-config EXTENSION = pgpdf - +EXTVERSION = 0.1.0 MODULE_big = $(EXTENSION) OBJS = pgpdf.o @@ -32,4 +32,23 @@ EXTRA_CLEAN = $(TEST_FILES) PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) -dev: clean all install installcheck \ No newline at end of file +dev: clean all install installcheck + +.PHONY: dist + +dist: + mkdir -p dist + git archive --format zip --prefix=$(EXTENSION)-$(EXTVERSION)/ --output dist/$(EXTENSION)-$(EXTVERSION).zip main + +# for Docker +PG_MAJOR ?= 17 + +.PHONY: docker + +docker: + docker build --pull --no-cache --build-arg PG_MAJOR=$(PG_MAJOR) -t florents/pgpdf:pg$(PG_MAJOR) -t florents/pgpdf:$(EXTVERSION)-pg$(PG_MAJOR) . + +.PHONY: docker-release + +docker-release: + docker buildx build --push --pull --no-cache --platform linux/amd64,linux/arm64 --build-arg PG_MAJOR=$(PG_MAJOR) -t florents/pgpdf:pg$(PG_MAJOR) -t florents/pgpdf:$(EXTVERSION)-pg$(PG_MAJOR) . \ No newline at end of file From 98ad8f911fbfd7dcbc782049b7a24036454887fd Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Fri, 15 Nov 2024 09:13:34 +0200 Subject: [PATCH 2/5] docker --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6d84a9..1e02b76 100644 --- a/README.md +++ b/README.md @@ -260,21 +260,43 @@ SELECT pdf_version('/tmp/pgintro.pdf'); ## Installation +Install [poppler](https://poppler.freedesktop.org) dependencies + +**Linux** ``` sudo apt install -y libpoppler-glib-dev pkg-config ``` + +**Homebrew/MacOS** + +``` +brew install poppler pkgconf +``` + ``` cd /tmp git clone https://github.com/Florents-Tselai/pgpdf.git cd pgpdf make -make install +make install # may need sudo ``` +After the installation, in a session: + ```tsql CREATE EXTENSION pgpdf; ``` +### Docker + +Get the [Docker image](https://hub.docker.com/r/florents/pgpdf) with: + +```sh +docker pull florents/pgpdf:pg17 +``` + +This adds pgpdf to the [Postgres image](https://hub.docker.com/_/postgres) (replace `17` with your Postgres server version, and run it the same way). + > [!WARNING] > Reading arbitrary binary data (PDF) into your database can pose security risks. > Only use this for files you trust. From 522811a87c0b911855a6913570bc0e114e93f6d5 Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Fri, 15 Nov 2024 09:15:07 +0200 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1e02b76..3cd4060 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![build](https://github.com/Florents-Tselai/pgpdf/actions/workflows/build.yml/badge.svg)](https://github.com/Florents-Tselai/pgpdf/actions/workflows/build.yml) ![GitHub Repo stars](https://img.shields.io/github/stars/Florents-Tselai/pgpdf) +![Docker Pulls](https://img.shields.io/docker/pulls/florents/pgpdf) This extension for PostgreSQL provides a `pdf` data type and assorted functions. From 5da5592493c01495a46adfc0a0b1335118083e3b Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Fri, 15 Nov 2024 09:16:35 +0200 Subject: [PATCH 4/5] docker --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0a7f7e4..dbe4b6a 100644 --- a/Makefile +++ b/Makefile @@ -43,9 +43,9 @@ dist: # for Docker PG_MAJOR ?= 17 -.PHONY: docker +.PHONY: docker-build -docker: +docker-build: docker build --pull --no-cache --build-arg PG_MAJOR=$(PG_MAJOR) -t florents/pgpdf:pg$(PG_MAJOR) -t florents/pgpdf:$(EXTVERSION)-pg$(PG_MAJOR) . .PHONY: docker-release From dabc99260fd72ff04af8d84290c73b026b086c30 Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Fri, 15 Nov 2024 09:52:54 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 3cd4060..06296e3 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,18 @@ docker pull florents/pgpdf:pg17 This adds pgpdf to the [Postgres image](https://hub.docker.com/_/postgres) (replace `17` with your Postgres server version, and run it the same way). +Run the image in a container. + +```sh +docker run --name pgpdf -p 5432:5432 -e POSTGRES_PASSWORD=pass florents/pgpdf:0.1.0-pg17 +``` + +Through another terminal, connect to the running server (container). + +```sh +PGPASSWORD=pass psql -h localhost -p 5432 -U postgres +``` + > [!WARNING] > Reading arbitrary binary data (PDF) into your database can pose security risks. > Only use this for files you trust.