Skip to content

Commit

Permalink
Merge pull request #24 from LlmLaraHub/docker-sail
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile authored Jun 22, 2024
2 parents eec8f4b + 11c7144 commit 0d4bc4a
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 1 deletion.
89 changes: 89 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.3
dockerfile: Dockerfile
args:
WWWGROUP: "${WWWGROUP}"
image: sail-8.3/app
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "${APP_PORT:-80}:80"
- "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
- "${REVERB_SERVER_PORT:-8080}:8080"
environment:
WWWUSER: "${WWWUSER}"
LARAVEL_SAIL: 1
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
IGNITION_LOCAL_SITES_PATH: "${PWD}"
volumes:
- ".:/var/www/html"
networks:
- sail
depends_on:
- pgsql
- redis
pgsql:
build: ./docker/psql
ports:
- "${FORWARD_DB_PORT:-5432}:5432"
environment:
PGPASSWORD: "${DB_PASSWORD:-secret}"
POSTGRES_DB: "${DB_DATABASE}"
POSTGRES_USER: "${DB_USERNAME}"
POSTGRES_PASSWORD: "${DB_PASSWORD:-secret}"
volumes:
- "sail-pgsql:/var/lib/postgresql/data"
- "./vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql"
networks:
- sail
healthcheck:
test:
- CMD
- pg_isready
- "-q"
- "-d"
- "${DB_DATABASE}"
- "-U"
- "${DB_USERNAME}"
retries: 3
timeout: 5s
redis:
image: "redis:alpine"
ports:
- "${FORWARD_REDIS_PORT:-6379}:6379"
volumes:
- "sail-redis:/data"
networks:
- sail
healthcheck:
test:
- CMD
- redis-cli
- ping
retries: 3
timeout: 5s
ollama:
build: ./docker/ollama
container_name: larallama-ollama
ports:
- "11434:11434"
healthcheck:
test: ollama --version || exit 1
volumes:
- sail-ollama:/root/.ollama
networks:
- sail
entrypoint: ["/usr/bin/bash", "/pull-llama3.sh"]
networks:
sail:
driver: bridge
volumes:
sail-pgsql:
driver: local
sail-redis:
driver: local
sail-ollama:
driver: local
3 changes: 3 additions & 0 deletions docker/ollama/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ollama/ollama:latest

COPY ./pull-llama3.sh /pull-llama3.sh
19 changes: 19 additions & 0 deletions docker/ollama/pull-llama3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

/bin/ollama serve &
# Record Process ID.
pid=$!

# Pause for Ollama to start.
sleep 5

echo "🔴==================== Retrieve LLAMA3 model"
ollama pull llama3
echo "🟢==================== LLAMA3 model pulled"

echo "🔴==================== Retrieve embedding model"
ollama pull mxbai-embed-large
echo "🟢==================== embedding model pulled"

# Wait for Ollama process to finish.
wait $pid
10 changes: 10 additions & 0 deletions docker/psql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM postgres:15

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-15-pgvector \
postgresql-15-postgis \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./extensions.sh /docker-entrypoint-initdb.d/10_postgis.sh
20 changes: 20 additions & 0 deletions docker/psql/extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"

# Create the 'template_postgis' template db
"${psql[@]}" <<- 'EOSQL'
CREATE DATABASE template_postgis IS_TEMPLATE true;
EOSQL

# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB"; do
echo "Loading PostGIS extensions into $DB"
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS vector;
EOSQL
done
2 changes: 1 addition & 1 deletion package-lock.json

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

0 comments on commit 0d4bc4a

Please sign in to comment.