From 0530956b5be8e4488ee1d65469c41efe12ecf63d Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Tue, 24 Sep 2024 15:17:06 -0400 Subject: [PATCH] Fix docker --- examples/postgres.py | 2 +- postgres/Dockerfile | 10 +++++++++- postgres/docker-compose.yml | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/postgres.py b/examples/postgres.py index de61b65c..534b5484 100644 --- a/examples/postgres.py +++ b/examples/postgres.py @@ -19,7 +19,7 @@ # the backend uses psycopg2 under the hood, so any valid connection string for it will # work; just replace the scheme with `shillelagh+multicorn2` engine = create_engine( - "shillelagh+multicorn2://shillelagh:shillelagh123@localhost:12345/shillelagh", + "shillelagh+multicorn2://shillelagh:shillelagh123@localhost:5432/shillelagh", ) connection = engine.connect() diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 5d45189b..267c7786 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -10,10 +10,12 @@ USER root # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ + git \ postgresql-server-dev-13 \ python3 \ python3-dev \ python3-pip \ + python3-venv \ wget # Download, build, and install multicorn2 @@ -24,7 +26,13 @@ RUN wget https://github.com/pgsql-io/multicorn2/archive/refs/tags/v2.5.tar.gz && make install -RUN pip install -e '.[all]' +# Create a virtual environment and install dependencies +RUN python3 -m venv /code/venv && \ + /code/venv/bin/pip install --upgrade pip && \ + /code/venv/bin/pip install -e '.[all]' + +# Set environment variable for PostgreSQL to use the virtual environment +ENV PATH="/code/venv/bin:$PATH" # Switch back to the default postgres user USER postgres diff --git a/postgres/docker-compose.yml b/postgres/docker-compose.yml index 6b2e1e15..5d905388 100644 --- a/postgres/docker-compose.yml +++ b/postgres/docker-compose.yml @@ -2,7 +2,9 @@ version: '3.8' services: postgres: - build: . + build: + context: .. + dockerfile: postgres/Dockerfile environment: POSTGRES_PASSWORD: shillelagh123 POSTGRES_USER: shillelagh @@ -10,7 +12,6 @@ services: volumes: - db_data:/var/lib/postgresql/data - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro - - ..:/src ports: - "5432:5432"