developmentseed / eoAPI

[Active Development] Earth Observation API (Metadata, Raster and Vector services)
https://eoapi.dev
MIT License
196 stars 21 forks source link

requests/urllib3 installation broken in Dockerfile.db #70

Closed hrodmn closed 1 year ago

hrodmn commented 1 year ago

I tried running the deployment process because eoAPI sounds AWESOME but I hit a snag on the database deployment. I got it working but it's worth a PR to fix it.

Problem description

A recent upgrade to urllib3 seems to have broken the version of requests that gets installed in Dockerfile.db so the BootstrappedDb deployment fails.

I can't seem to get a full traceback from AWS CloudWatch but here is the error message:

[ERROR] Runtime.ImportModuleError: Unable to import module 'handler': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/var/task/urllib3/util/ssl_.py)

I was able to fix the problem by explicitly installing urllib3<2 in Dockerfile.db:

diff --git a/infrastructure/aws/dockerfiles/Dockerfile.db b/infrastructure/aws/dockerfiles/Dockerfile.db
index 52df1b4..17c4d23 100644
--- a/infrastructure/aws/dockerfiles/Dockerfile.db
+++ b/infrastructure/aws/dockerfiles/Dockerfile.db
@@ -10,7 +10,7 @@ WORKDIR /tmp
 RUN python -m pip install pip -U

 RUN echo "Using PGSTAC Version ${PGSTAC_VERSION}"
-RUN python -m pip install requests psycopg["binary,pool"] pypgstac==${PGSTAC_VERSION} -t /asset
+RUN python -m pip install urllib<2 requests psycopg["binary,pool"] pypgstac==${PGSTAC_VERSION} -t /asset

 COPY infrastructure/aws/handlers/db_handler.py /asset/handler.py

Here is a relevant issue in requests: https://github.com/psf/requests/issues/6432 requests v2.30.0 should be working with urllib3>2 but maybe we are pinned to something less than v2.30.0 by another package. I haven't run the docker network locally yet but will try to dig in to find out the actual best solution.

Environment Information

Ubuntu 22.04, Python 3.10.6

vincentsarago commented 1 year ago

oh nice catch πŸ™

I'm sorry because I know that debugging BootstrapedDb step must have been a pain.

I'm not a big fan of requests so I'm going to fix this by replacing it with httpx πŸ˜„

vincentsarago commented 1 year ago

should be fixed with latest commit in main πŸ™

hrodmn commented 1 year ago

I'm sorry because I know that debugging BootstrapedDb step must have been a pain.

I got lucky. I tweaked Dockerfile.db and tried again - it worked!

I'm not a big fan of requests so I'm going to fix this by replacing it with httpx smile

Excellent - thanks for the quick fix!