Skip to content
Snippets Groups Projects
Unverified Commit 961c2d96 authored by Sourabh Desai's avatar Sourabh Desai Committed by GitHub
Browse files

simplify specification of DATABASE_URL (#35)

* simplify specification of DATABASE_URL for make run_docker by adding .env.docker

* use localhost + have make migrate create containers first

* update README setup instructions. Just need make run now

* update Makefile to run  before use of 'docker compose create' before use of 'docker compose start'

* newline
parent e81c8395
No related branches found
No related tags found
No related merge requests found
DATABASE_URL=postgresql://user:password@db:5432/llama_app_db
run:
echo "Running in local mode."
docker compose start db
docker compose start localstack
docker compose create db localstack
docker compose start db localstack
poetry run start
run_docker:
echo "Running in local mode with docker."
# Check if .env file would set the DATABASE_URL parameter and ask the user to remove it
# from .env if it would
# This is needed because the DATABASE_URL parameter is set in docker-compose.yml
# Also account for the case where DATABASE_URL exists but has been commented out by
# doing a regex match to see that its at the start of a line
if [ -f .env ] && grep -q -E '^\s*DATABASE_URL\s*=' .env; then \
echo "The .env file contains a DATABASE_URL parameter. Please remove it from the .env file and try again."; \
exit 1; \
fi
docker compose up
migrate:
echo "Running migrations."
docker compose create db
docker compose start db
poetry run python -m alembic upgrade head
......@@ -29,6 +21,7 @@ chat:
poetry run python -m scripts.chat_llama
setup_localstack:
docker compose create localstack
docker compose start localstack
echo "Waiting for localstack to start..."
sleep 3
......@@ -69,6 +62,7 @@ seed_db_preview:
seed_db_local:
echo "Seeding database for local."
docker compose create db
docker compose start db
make setup_localstack
python scripts/seed_db.py --ciks '["0001018724", "1326801"]' --filing_types '["10-K"]'
......@@ -12,9 +12,6 @@ Live at https://secinsights.ai/
- You can leave `AWS_KEY` & `AWS_SECRET` with dummy values
1. `set -a`
1. `source .env`
1. If this is your first time spinning up the service on your machine, run `make run_docker`
- This will spin up the DB, LocalStack, and the FastAPI server all in their own containers but interconnected.
- After all services in the compose stack have started running, exit with ctrl+c
1. Run the database migrations with `make migrate`
1. Run `make run` to start the server locally
- This spins up the Postgres 15 DB & Localstack in their own docker containers.
......
......@@ -3,18 +3,17 @@ services:
llama-app-fastapi:
build:
context: .
args:
DATABASE_URL: postgresql://user:password@db:5432/llama_app_db
volumes:
# allows for live reloading of the app
# when the code within the ./app directory changes
- ./:/app
ports:
- "8000:8000"
- "127.0.0.1:8000:8000"
depends_on:
- db
env_file:
- .env
- .env.docker
environment:
BACKEND_CORS_ORIGINS: '["http://localhost", "http://localhost:8000"]'
......@@ -25,7 +24,7 @@ services:
POSTGRES_PASSWORD: password
POSTGRES_DB: llama_app_db
ports:
- "5432:5432"
- "127.0.0.1:5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment