iCyberon / pg_hashids

Short unique id generator for PostgreSQL, using hashids
MIT License
280 stars 24 forks source link

Struggling to install in a dockerized Postgres 9.6 #27

Closed smileservices closed 3 years ago

smileservices commented 3 years ago

I'm trying to install it to a dockerized Postgres 9.6. The problem is that when running make install command it it does this:

/bin/mkdir -p '/usr/lib/postgresql/13/lib'
/bin/mkdir -p '/usr/share/postgresql/13/extension'
/bin/mkdir -p '/usr/share/postgresql/13/extension'
/usr/bin/install -c -m 755  pg_hashids.so '/usr/lib/postgresql/13/lib/pg_hashids.so'
/usr/bin/install -c -m 644 .//pg_hashids.control '/usr/share/postgresql/13/extension/'
/usr/bin/install -c -m 644 .//pg_hashids--1.3.sql .//pg_hashids--1.2.1--1.3.sql .//pg_hashids--1.2--1.3.sql .//pg_hashids--1.1--1.2.sql .//pg_hashids--1.0--1.1.sql  '/usr/share/postgresql/13/extension/'
/bin/mkdir -p '/usr/lib/postgresql/13/lib/bitcode/pg_hashids'
/bin/mkdir -p '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/
/usr/bin/install -c -m 644 pg_hashids.bc '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/./
/usr/bin/install -c -m 644 hashids.bc '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/./
cd '/usr/lib/postgresql/13/lib/bitcode' && /usr/lib/llvm-6.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o pg_hashids.index.bc pg_hashids/pg_hashids.bc pg_hashids/hashids.bc

When I try creating the pg_hashids from an sql dump it doesn't find the required files in the extension folder:

ziticity-postgresdb    | ERROR:  could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory
ziticity-postgresdb    | STATEMENT:  CREATE EXTENSION IF NOT EXISTS pg_hashids WITH SCHEMA public;
ziticity-postgresdb    | psql:/docker-entrypoint-initdb.d/dump.sql:50: ERROR:  could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory

Probably we are am missing a ./configure command, i'm not sure. Please advise

zdm commented 3 years ago

In your log you can see, that you build it for postgres 13. If you need postgres 9, install it and build for it.

On 22.07.2021 12:02, Vladimir Gorea wrote:

I'm trying to install it to a dockerized Postgres 9.6. The problem is that when running |make install| command it it does this:

|/bin/mkdir -p '/usr/lib/postgresql/13/lib' /bin/mkdir -p '/usr/share/postgresql/13/extension' /bin/mkdir -p '/usr/share/postgresql/13/extension' /usr/bin/install -c -m 755 pg_hashids.so '/usr/lib/postgresql/13/lib/pg_hashids.so' /usr/bin/install -c -m 644 .//pg_hashids.control '/usr/share/postgresql/13/extension/' /usr/bin/install -c -m 644 .//pg_hashids--1.3.sql .//pg_hashids--1.2.1--1.3.sql .//pg_hashids--1.2--1.3.sql .//pg_hashids--1.1--1.2.sql .//pg_hashids--1.0--1.1.sql '/usr/share/postgresql/13/extension/' /bin/mkdir -p '/usr/lib/postgresql/13/lib/bitcode/pg_hashids' /bin/mkdir -p '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/ /usr/bin/install -c -m 644 pg_hashids.bc '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/./ /usr/bin/install -c -m 644 hashids.bc '/usr/lib/postgresql/13/lib/bitcode'/pg_hashids/./ cd '/usr/lib/postgresql/13/lib/bitcode' && /usr/lib/llvm-6.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o pg_hashids.index.bc pg_hashids/pg_hashids.bc pg_hashids/hashids.bc |

When I try creating the pg_hashids from an sql dump it doesn't find the required files in the extension folder:

|ziticity-postgresdb | ERROR: could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory ziticity-postgresdb | STATEMENT: CREATE EXTENSION IF NOT EXISTS pg_hashids WITH SCHEMA public; ziticity-postgresdb | psql:/docker-entrypoint-initdb.d/dump.sql:50: ERROR: could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory |

Probably we are am missing a ./configure command, i'm not sure. Please advise

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iCyberon/pg_hashids/issues/27, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2MSGPSCJFQPILMXPVFSDTY7NDXANCNFSM5AZSJKEA.

smileservices commented 3 years ago

@zdm I have it installed already. This is my dockerfile:

FROM postgres:9.6

LABEL maintainer="PostGIS Project - https://postgis.net"

ENV POSTGIS_MAJOR 3
ENV POSTGIS_VERSION 3.1.2+dfsg-1~exp2.pgdg90+1

RUN apt-get update \
      && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
      && apt-get install -y --no-install-recommends \
           postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
           postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
      && apt-get install -y make \
      && apt-get install -y gcc \
      && apt-get install -y postgresql-server-dev-all
      # && rm -rf /var/lib/apt/lists/*

# install pg_hashids extension
RUN mkdir /pg_hashids
COPY ./pg_hashids/ /pg_hashids/
WORKDIR /pg_hashids
RUN make; make install
# finish pg_hashids install

RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
COPY ./update-postgis.sh /usr/local/bin

I read in an older issue that in the Makefile the PG_CONFIG = pg_config can be changed but I wonder where does it get the postgres 13 version from

zdm commented 3 years ago

You do something incorrect. It builds for pg13. Maybe you silently installs pg13 pg13 as dependency? Check your docker build output and find, why pg13 is installed.

On 22.07.2021 12:20, Vladimir Gorea wrote:

@zdm https://github.com/zdm I have it installed already. This is my dockerfile:

|FROM postgres:9.6 LABEL maintainer="PostGIS Project - https://postgis.net" ENV POSTGIS_MAJOR 3 ENV POSTGIS_VERSION 3.1.2+dfsg-1~exp2.pgdg90+1 RUN apt-get update \ && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \ && apt-get install -y make \ && apt-get install -y gcc \ && apt-get install -y postgresql-server-dev-all # && rm -rf /var/lib/apt/lists/* # install pg_hashids extension RUN mkdir /pg_hashids COPY ./pg_hashids/ /pg_hashids/ WORKDIR /pg_hashids RUN make; make install # finish pg_hashids install RUN mkdir -p /docker-entrypoint-initdb.d COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh COPY ./update-postgis.sh /usr/local/bin |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iCyberon/pg_hashids/issues/27#issuecomment-884771342, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2MSHRVAGIW3F4FVU543TTY7PGHANCNFSM5AZSJKEA.

smileservices commented 3 years ago

It's all part of a docker-compose file. It is sharing the locally cloned repo of pg_hashids with the dockercontainer.

These are the steps i'm taking:

  1. clone iCyberon / pg_hashids
  2. run docker-compose up
  3. it builds the docker file; while inside the container, it runs make; make install commands
  4. runs an sql dump that contains CREATE EXTENSION IF NOT EXISTS pg_hashids WITH SCHEMA public;
  5. Throws the error ERROR: could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory

I really don't know where it gets the postgres 13 version from. Very puzling. I have no idea how to make it use the 9.6 one

zdm commented 3 years ago

Why you need pg 9.6? This is very ancient version. Use pg 13 ;-).

On 22.07.2021 14:20, Vladimir Gorea wrote:

It's all part of a docker-compose file. It is sharing the locally cloned repo of pg_hashids with the dockercontainer.

These are the steps i'm taking:

  1. clone iCyberon / pg_hashids
  2. run |docker-compose up|
  3. it builds the docker file
  4. runs an sql dump that contains |CREATE EXTENSION IF NOT EXISTS pg_hashids WITH SCHEMA public;|
  5. Throws the error |ERROR: could not open extension control file "/usr/share/postgresql/9.6/extension/pg_hashids.control": No such file or directory|

I really don't know where it gets the postgres 13 version from. Very puzling. I have no idea how to make it use the 9.6 one

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iCyberon/pg_hashids/issues/27#issuecomment-884836826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2MSDNR5WOTWY27RG6O7LTY75HHANCNFSM5AZSJKEA.

smileservices commented 3 years ago

Need to replicate production lol Eventually i will go with pg13 if nothing else works

zdm commented 3 years ago

I don;t know, what happens on your side. For me everything works. I just execute simple gmake. My pg version is 13.2. Your problem is definitely in pg 9. Maybe some of your dependencies have pg13 as dependency and installs it.

On 22.07.2021 14:26, Vladimir Gorea wrote:

Need to replicate production lol Eventually i will go with pg13 if nothing else works

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iCyberon/pg_hashids/issues/27#issuecomment-884840267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2MSF5UYNDHG5G37HNH3TTY756XANCNFSM5AZSJKEA.

smileservices commented 3 years ago

Can you try with a different version of pg? Maybe for you it works because you have pg13 lol

zdm commented 3 years ago

for me it is cimpiled without errors

root@4ba5c7835cbe:/pg_hashids-master# make install
/bin/mkdir -p '/usr/lib/postgresql/9.6/lib'
/bin/mkdir -p '/usr/share/postgresql/9.6/extension'
/bin/mkdir -p '/usr/share/postgresql/9.6/extension'
/usr/bin/install -c -m 755  pg_hashids.so '/usr/lib/postgresql/9.6/lib/pg_hashids.so'
/usr/bin/install -c -m 644 .//pg_hashids.control '/usr/share/postgresql/9.6/extension/'
/usr/bin/install -c -m 644 .//pg_hashids--1.3.sql .//pg_hashids--1.2.1--1.3.sql .//pg_hashids--1.2--1.3.sql .//pg_hashids--1.1--1.2.sql .//pg_hashids--1.0--1.1.sql  '/usr/share/postgresql/9.6/extension/'
root@4ba5c7835cbe:/pg_hashids-master#

Remember, that you need to install apt install postgresql-server-dev-9.6

smileservices commented 3 years ago

Oh, now i see! Thanks a lot!

smileservices commented 3 years ago

fixed the issue by installing postgresql-server-dev-9.6 instead of postgresql-server-dev-all