feat(infra): add PostGIS and pgvector database container and API Dockerfile
- Create docker/postgres/Dockerfile extending postgis:17-3.5 with pgvector v0.8.0. - Add docker/postgres/init-extensions.sql to initialize postgis and vector extensions on DB creation. - Update docker-compose.yml pg_database service to build from custom Dockerfile. - Add api/Dockerfile using python 3.14-bookworm-slim with uv.
This commit is contained in:
1 parent
4c856b1b3e
commit
58c3e76c08
4 files changed
+49
-1
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Copy dependency files
|
||||||
|
COPY api/pyproject.toml api/uv.lock /app/
|
||||||
|
|
||||||
|
# Install dependencies without installing the project itself
|
||||||
|
RUN uv sync --frozen --no-dev --no-install-project
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY api /app
|
||||||
|
|
||||||
|
# Install the application package
|
||||||
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
|
# Add virtual environment to PATH
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
pg_database:
|
pg_database:
|
||||||
image: postgres:17
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/postgres/Dockerfile
|
||||||
container_name: postgres_db
|
container_name: postgres_db
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM postgis/postgis:17-3.5
|
||||||
|
|
||||||
|
# Install build dependencies and pgvector
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
postgresql-17-pgvector || \
|
||||||
|
(apt-get install -y --no-install-recommends git build-essential postgresql-server-dev-17 && \
|
||||||
|
cd /tmp && \
|
||||||
|
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
|
||||||
|
cd pgvector && \
|
||||||
|
make && \
|
||||||
|
make install && \
|
||||||
|
apt-get remove -y git build-essential postgresql-server-dev-17 && \
|
||||||
|
apt-get autoremove -y && \
|
||||||
|
rm -rf /tmp/pgvector) && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY docker/postgres/init-extensions.sql /docker-entrypoint-initdb.d/01-init-extensions.sql
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- Initialize core extensions required by Novias del Gato
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vector;
|
||||||
Reference in new issue
Block a user