Skip to content

Commit

Permalink
Fix docker
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Sep 24, 2024
1 parent 811de6d commit f96ed4e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
17 changes: 8 additions & 9 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ You also need to install optional dependencies, depending on the adapter you wan

.. code-block:: bash
$ pip install 'shillelagh[console]' # to use the CLI
$ pip install 'shillelagh[genericjsonapi]' # for Generic JSON
$ pip install 'shillelagh[genericxmlapi]' # for Generic XML
$ pip install 'shillelagh[githubapi]' # for GitHub
$ pip install 'shillelagh[gsheetsapi]' # for GSheets
$ pip install 'shillelagh[htmltableapi]' # for HTML tables
$ pip install 'shillelagh[pandasmemory]' # for Pandas in memory
$ pip install 'shillelagh[s3selectapi]' # for S3 files
$ pip install 'shillelagh[systemapi]' # for CPU information
$ pip install 'shillelagh[console]' # to use the CLI
$ pip install 'shillelagh[githubapi]' # for GitHub
$ pip install 'shillelagh[gsheetsapi]' # for GSheets
$ pip install 'shillelagh[htmltableapi]' # for HTML tables
$ pip install 'shillelagh[pandasmemory]' # for Pandas in memory
$ pip install 'shillelagh[s3selectapi]' # for S3 files
$ pip install 'shillelagh[systemapi]' # for CPU information
Alternatively, you can install everything with:

.. code-block:: bash
$ pip install 'shillelagh[all]'
~
4 changes: 2 additions & 2 deletions docs/postgres.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ To use the backend you need to:

Note that you need to install Python packages in a way that they are available to the process running Postgres. You can either install them globally, or install them in a virtual environment and have it activated in the process that starts Postgres.

The ``postgres/`` directory has a Docker configuration that can be used to test the backend, or as a basis for installation. To run it, enter the directory and execute:
The ``postgres/`` directory has a Docker configuration that can be used to test the backend, or as a basis for installation. To run it, execute:

.. code-block:: bash
docker compose up --build -d
docker compose -f postgres/docker-compose.yml up
You should then be able to run the example script in `examples/postgres.py`_ to test that everything works.
2 changes: 1 addition & 1 deletion examples/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 9 additions & 1 deletion postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
5 changes: 3 additions & 2 deletions postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ version: '3.8'

services:
postgres:
build: .
build:
context: ..
dockerfile: postgres/Dockerfile
environment:
POSTGRES_PASSWORD: shillelagh123
POSTGRES_USER: shillelagh
POSTGRES_DB: shillelagh
volumes:
- db_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
- ..:/src
ports:
- "5432:5432"

Expand Down

0 comments on commit f96ed4e

Please sign in to comment.