laurenz / oracle_fdw

PostgreSQL Foreign Data Wrapper for Oracle
http://laurenz.github.io/oracle_fdw/
Other
496 stars 156 forks source link

Add a sample Docker file to build a container with PostgreSQL and oracle_fdw #644

Open thiagosegato opened 10 months ago

thiagosegato commented 10 months ago

An example Docker file for testing purposes.

laurenz commented 10 months ago

Thank you!

My personal problem is that I don't do Docker, so I cannot review the patch, and I won't be able to handle any problem reports with the Dockerfile.

So I'll let this pull request sit until someone knowledgable steps up and reviews it...

emyu10 commented 7 months ago

I have managed to create a docker image and I have tested it and it works as it should

emyu10 commented 7 months ago

I have managed to create a docker image and I have tested it and it works as it should

https://github.com/emyu10/postgres-oracle-fdw

laurenz commented 7 months ago

Thanks, @emyu10. I'm ready to merge it, but there is one thing that should be fixed that even I can spot: The Dockerfile mentions PostgreSQL 16.1, but the current minor release is 16.2. @thiagosegato, could you remove the minor version? I think that is more confusing than useful.

emyu10 commented 7 months ago

@laurenz I think you misunderstood what I said. I haven't got the time to test the Dockerfile provided by @thiagosegato . But I can test it and let you know. Sorry for the misunderstanding created

laurenz commented 7 months ago

Ah, ok. Thanks for the clarification.

emyu10 commented 7 months ago

@thiagosegato's image does build successfully. But when I try to run a container using the image, I get the following error

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

initdb: error: invalid locale settings; check LANG and LC_* environment variables

I think the error is related to postgres docker image. Not necessarily @thiagosegato's image. He can confirm it.

kgeis commented 6 months ago

A multi-stage Docker build is a good practice to avoid littering the final image with development packages. The Dockerfile below is based on what I've been using in a production setting for the past couple of years.

(edit: removed PostgreSQL minor version)

FROM postgres:16 AS build_oracle_fdw

ARG  ORACLE_FDW_VERSION=2_6_0
ARG  ORACLE_VERSION=21.13.0.0.0
ARG  ORACLE_VERSION_PATH=2113000
ENV  ORACLE_HOME=/instantclient_21_13
RUN  apt-get -q update && \
     apt-get -q -y install wget unzip build-essential postgresql-server-dev-$PG_MAJOR && \
     wget https://download.oracle.com/otn_software/linux/instantclient/${ORACLE_VERSION_PATH}/instantclient-basiclite-linux.x64-${ORACLE_VERSION}dbru.zip && \
     wget https://download.oracle.com/otn_software/linux/instantclient/${ORACLE_VERSION_PATH}/instantclient-sdk-linux.x64-${ORACLE_VERSION}dbru.zip && \
     unzip /instantclient-basiclite-linux.x64-${ORACLE_VERSION}dbru.zip && \
     unzip /instantclient-sdk-linux.x64-${ORACLE_VERSION}dbru.zip && \
     wget https://github.com/laurenz/oracle_fdw/archive/ORACLE_FDW_${ORACLE_FDW_VERSION}.tar.gz && \
     tar zxf ORACLE_FDW_${ORACLE_FDW_VERSION}.tar.gz && \
     cd oracle_fdw-ORACLE_FDW_${ORACLE_FDW_VERSION} && \
     make && \
     rm -rf ${ORACLE_HOME}/sdk

FROM postgres:16

ARG  ORACLE_FDW_VERSION=2_6_0
ENV  ORACLE_HOME=/instantclient_21_13
ENV  LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
RUN  apt update && \
     apt install -y libaio1
COPY --from=build_oracle_fdw ${ORACLE_HOME} ${ORACLE_HOME}
COPY --from=build_oracle_fdw /oracle_fdw-ORACLE_FDW_${ORACLE_FDW_VERSION}/oracle_fdw.so /usr/lib/postgresql/${PG_MAJOR}/lib/
COPY --from=build_oracle_fdw /oracle_fdw-ORACLE_FDW_${ORACLE_FDW_VERSION}/oracle_fdw.control /oracle_fdw-ORACLE_FDW_${ORACLE_FDW_VERSION}/*.sql /usr/share/postgresql/${PG_MAJOR}/extension/
laurenz commented 6 months ago

@kgeis Thanks - what do I do with that information?

kgeis commented 6 months ago

@kgeis Thanks - what do I do with that information?

@laurenz That's up to you! 🙂 You said you wanted to "let this pull request sit until someone knowledgable steps up and reviews it." Personally, of course, I think you should replace the Dockerfile in the PR with mine. Aside, since you marked this PR "wontfix", you should remove that or close it.

laurenz commented 6 months ago

I have removed the "wontfix" tag for the time being.

So now I have two proposed Dockerfiles. As I said, I am not in a position to review them. What would be helpful would be a Dockerfile that a couple of Docker users can agree on.

AmebaBrain commented 6 months ago

oh...count me in! )

I think there are a lot of possible implementation for such an image. Here is mine, for example. And corresponding image on docker hub.

I'm maintaining a repo with set of postgres docker images with different FDWs installed. As well as mixed image with set of FDWs combined. Currently, there are already 8 FDWs avaible + 2 built-in (postgres_fdw & file_fdw).