Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .docker/pgvector.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM postgres:14-alpine

RUN apk add --no-cache --virtual .build-deps \
git \
build-base \
clang \
llvm13-dev \
&& git clone --branch v0.5.0 https://github.com/pgvector/pgvector.git /tmp/pgvector \
&& cd /tmp/pgvector \
&& make OPTFLAGS="" \
&& make install \
&& rm -r /tmp/pgvector \
&& apk del --purge .build-deps
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ DB_DATABASE="biigle"
DB_USERNAME="biigle"
DB_PASSWORD="secret"

VECTOR_DB_HOST="vector_database"
VECTOR_DB_PORT=5432
VECTOR_DB_DATABASE="biigle"
VECTOR_DB_USERNAME="biigle"
VECTOR_DB_PASSWORD="secret"

VOLUME_ADMIN_STORAGE_DISKS=local

BROADCAST_DRIVER=pusher
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,41 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

build-and-push-pgvector:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0

- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/biigle/pgvector

- name: Build and push Docker image
uses: docker/build-push-action@v4.0.0
with:
context: .
file: .docker/pgvector.dockerfile
build-args: BIIGLE_VERSION=${{ github.event.release.tag_name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ jobs:
run: |
docker pull ghcr.io/biigle/app:latest
docker pull ghcr.io/biigle/worker:latest
docker pull ghcr.io/biigle/pgvector:latest

- name: Start test database
run: docker-compose up -d --no-build database_testing
run: |
docker-compose up -d --no-build database_testing
docker-compose up -d --no-build vector_database_testing

- name: Run tests
run: docker-compose run --rm -u 1001 worker php -d memory_limit=1G vendor/bin/phpunit --random-order
Expand Down Expand Up @@ -71,9 +74,12 @@ jobs:
run: |
docker pull ghcr.io/biigle/app:latest
docker pull ghcr.io/biigle/worker:latest
docker pull ghcr.io/biigle/pgvector:latest

- name: Start test database
run: docker-compose up -d --no-build database_testing
run: |
docker-compose up -d --no-build database_testing
docker-compose up -d --no-build vector_database_testing

- name: Run tests
run: docker-compose run --rm -u 1001 worker php -d memory_limit=1G vendor/bin/phpunit --random-order
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ext-soap": "*",
"ext-vips": "*",
"ext-yaml": "*",
"ankane/pgvector": "^0.1.3",
"biigle/laravel-file-cache": "^4.0",
"doctrine/dbal": "^3.0",
"duncan3dc/bom-string": "^1.1",
Expand Down
56 changes: 54 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
'sslmode' => 'prefer',
],

'pgvector' => [
'driver' => 'pgsql',
'url' => env('VECTOR_DATABASE_URL'),
'host' => env('VECTOR_DB_HOST', 'localhost'),
'port' => env('VECTOR_DB_PORT', '5432'),
'database' => env('VECTOR_DB_DATABASE', 'forge'),
'username' => env('VECTOR_DB_USERNAME', 'forge'),
'password' => env('VECTOR_DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],

'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
Expand Down
26 changes: 26 additions & 0 deletions database/migrations/2022_08_03_000000_create_vector_extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::connection('pgvector')->statement('CREATE EXTENSION IF NOT EXISTS vector');
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::connection('pgvector')->statement('DROP EXTENSION IF EXISTS vector');
}
};
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
depends_on:
- app
- database_testing
- vector_database_testing
build:
context: ./
dockerfile: .docker/worker.dockerfile
Expand Down Expand Up @@ -76,6 +77,21 @@ services:
ports:
- "54320:5432"

vector_database:
image: ghcr.io/biigle/pgvector
build:
context: ./
dockerfile: .docker/pgvector.dockerfile
volumes:
- vecdbdata:/var/lib/postgresql/data
- ./:/data
environment:
- "POSTGRES_DB=biigle"
- "POSTGRES_USER=biigle"
- "POSTGRES_PASSWORD=secret"
ports:
- "54321:5432"

database_testing:
image: postgres:14-alpine
tmpfs:
Expand All @@ -85,6 +101,16 @@ services:
- "POSTGRES_USER=biigle"
- "POSTGRES_PASSWORD=secret"

vector_database_testing:
image: ghcr.io/biigle/pgvector
tmpfs:
- /var/lib/postgresql/data
environment:
- "POSTGRES_DB=biigle"
- "POSTGRES_USER=biigle"
- "POSTGRES_PASSWORD=secret"

volumes:
dbdata:
vecdbdata:

6 changes: 5 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_DATABASE" value="biigle"/>
<env name="DB_HOST" value="database_testing"/>
<env name="DB_DATABASE" value="biigle"/>
<env name="DB_USERNAME" value="biigle"/>
<env name="DB_PASSWORD" value="secret"/>
<env name="VECTOR_DB_HOST" value="vector_database_testing"/>
<env name="VECTOR_DB_DATABASE" value="biigle"/>
<env name="VECTOR_DB_USERNAME" value="biigle"/>
<env name="VECTOR_DB_PASSWORD" value="secret"/>
</php>
</phpunit>
Loading