Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thiagosegato
Copy link

An example Docker file for testing purposes.

@laurenz
Copy link
Owner

laurenz commented Feb 1, 2024

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
Copy link

emyu10 commented Apr 27, 2024

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

@emyu10
Copy link

emyu10 commented Apr 27, 2024

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
Copy link
Owner

laurenz commented Apr 29, 2024

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
Copy link

emyu10 commented Apr 29, 2024

@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
Copy link
Owner

laurenz commented Apr 29, 2024

Ah, ok. Thanks for the clarification.

@emyu10
Copy link

emyu10 commented Apr 29, 2024

@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
Copy link

kgeis commented May 8, 2024

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
Copy link
Owner

laurenz commented May 9, 2024

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

@kgeis
Copy link

kgeis commented May 9, 2024

@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 laurenz removed the wontfix label May 10, 2024
@laurenz
Copy link
Owner

laurenz commented May 10, 2024

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
Copy link

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).

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

Successfully merging this pull request may close these issues.

5 participants