docker compose commands

This commit is contained in:
Xi Yan 2024-11-08 14:00:54 -08:00
parent bd0622ef10
commit 8cd7e406c0
9 changed files with 129 additions and 0 deletions

View file

@ -0,0 +1,18 @@
services:
postgres:
build:
context: ./postgres
dockerfile: postgres.Dockerfile
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./postgres/vector_extension.sql:/docker-entrypoint-initdb.d/0-vector_extension.sql
# - ./postgres/0-vector-extension.sh:/docker-entrypoint-initdb.d/0-vector-extension.sh
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=vectorexample
volumes:
postgres_data:

View file

@ -0,0 +1,14 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
set -e
echo "In create extension"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="$POSTGRES_DB" <<EOFSQL
CREATE EXTENSION vector;
EOFSQL

View file

@ -0,0 +1,2 @@
-- Create the 'store' database
CREATE DATABASE store;

View file

@ -0,0 +1,15 @@
# This is installing the pgvector extension for postgres
FROM postgres:latest
RUN apt-get update && apt-get install -y \
build-essential \
git \
postgresql-server-dev-all \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN git clone https://github.com/pgvector/pgvector.git
WORKDIR /tmp/pgvector
RUN make
RUN make install

View file

@ -0,0 +1,2 @@
-- Create the 'vector' extension within the database that is set in the docker-compose.yml
CREATE EXTENSION IF NOT EXISTS vector;