-
Notifications
You must be signed in to change notification settings - Fork 0
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
Install postgres in Dockerfile for psycopg2 to build correctly #205
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on my ec2 and its failing (testing Dockerfile-node). Will take a deeper look and update.
node-app | File "/app/node/storage/db/init_db.py", line 55, in <module>
node-app | init_db()
node-app | File "/app/node/storage/db/init_db.py", line 23, in init_db
node-app | engine = create_engine(LOCAL_DB_URL)
node-app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
node-app | File "<string>", line 2, in create_engine
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
node-app | return fn(*args, **kwargs) # type: ignore[no-any-return]
node-app | ^^^^^^^^^^^^^^^^^^^
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 602, in create_engine
node-app | dbapi = dbapi_meth(**dbapi_args)
node-app | ^^^^^^^^^^^^^^^^^^^^^^^^
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 696, in import_dbapi
node-app | import psycopg2
node-app | File "/app/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 51, in <module>
node-app | from psycopg2._psycopg import ( # noqa
node-app | ImportError: libpq.so.5: cannot open shared object file: No such file or directory
node-app | + poetry run python -m node.storage.db.init_db
node-app | Traceback (most recent call last):
node-app | File "<frozen runpy>", line 198, in _run_module_as_main
node-app | File "<frozen runpy>", line 88, in _run_code
node-app | File "/app/node/storage/db/init_db.py", line 55, in <module>
node-app | init_db()
node-app | File "/app/node/storage/db/init_db.py", line 23, in init_db
node-app | engine = create_engine(LOCAL_DB_URL)
node-app | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
node-app | File "<string>", line 2, in create_engine
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
node-app | return fn(*args, **kwargs) # type: ignore[no-any-return]
node-app | ^^^^^^^^^^^^^^^^^^^
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 602, in create_engine
node-app | dbapi = dbapi_meth(**dbapi_args)
node-app | ^^^^^^^^^^^^^^^^^^^^^^^^
node-app | File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 696, in import_dbapi
node-app | import psycopg2
node-app | File "/app/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 51, in <module>
node-app | from psycopg2._psycopg import ( # noqa
node-app | ImportError: libpq.so.5: cannot open shared object file: No such file or directory
@@ -15,11 +15,16 @@ RUN apt-get install curl gcc curl git -y | |||
|
|||
# add conda install to path; use base environment | |||
ENV PATH="/opt/conda/bin:${PATH}" | |||
RUN conda create -n node python=3.12 | |||
RUN conda create -y -n node python=3.12 | |||
RUN echo "source activate node" > /root/.bashrc | |||
ENV PATH="/opt/conda/envs/node/bin:$PATH" | |||
RUN echo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a typo
RUN echo "source activate node" > /root/.bashrc | ||
ENV PATH="/opt/conda/envs/node/bin:$PATH" | ||
RUN echo | ||
|
||
# install postgres (required for poetry to build psycopg2 from source) | ||
RUN conda install -y conda-forge::postgresql=17.2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like LDFLAGS
and CPPFLAGS
are missing?
@moarshy Can you verify if pg_config binary is in PATH? |
this is the only change we would need to get it working |
which EC2 AMI are you using? Amazon Linux boxes are notorious for having missing C libraries compared to other distros like debian and ubuntu. |
I am on ubuntu. Does it matter though? since its failing in the docker? Anyways, it was just missing a single lib |
Fixes #204.
Read this msg on Discord for context.