-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update contributors.json * new contributor * Improve README.md * Containerize the blt project along with database * Apply suggestions from code review * Update .env.example * retain sentry * set ssl_redirect to True * Revert to apply pre-commit * pass pre-commit and make the required changes by Settings SECURE_SSL_REDIRECT=TRUE * retain secure_proxy_ssl_header and pass run test * pass run test --------- Co-authored-by: DonnieBLT <[email protected]>
- Loading branch information
1 parent
2ccd1f7
commit ae45ef2
Showing
4 changed files
with
112 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ [email protected] | |
SUPERUSER_PASSWORD=admi345n@12343453 | ||
|
||
DOMAIN_NAME=localhost | ||
PORT=80 | ||
PORT=8000 | ||
CALLBACK_URL_FOR_GITHUB=http://127.0.0.1:8000/ | ||
CALLBACK_URL_FOR_GOOGLE=http://127.0.0.1:8000/ | ||
CALLBACK_URL_FOR_FACEBOOK=http://127.0.0.1:8000/ | ||
|
@@ -17,12 +17,15 @@ LANGCHAIN_TRACING_V2=true | |
LANGCHAIN_PROJECT=default | ||
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" | ||
|
||
#Database URL | ||
DATABASE_URL=postgres://user:password@localhost:5432/dbname | ||
#Database Credentials | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_USER=postgres | ||
POSTGRES_DB=example_db | ||
POSTGRES_PORT=5432 #default is 5432, but sometimes it may be occupied by other services. So you can change it to any other port. | ||
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${POSTGRES_PORT}/${POSTGRES_DB} | ||
|
||
#Sentry DSN | ||
SENTRY_DSN=https://[email protected]/0 | ||
|
||
|
||
SLACK_CLIENT_ID= | ||
SLACK_CLIENT_SECRET= | ||
SLACK_CLIENT_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
version: "3" | ||
|
||
services: | ||
db: | ||
image: postgres | ||
ports: | ||
- "${POSTGRES_PORT}:5432" | ||
volumes: | ||
- postgres_db:/var/lib/postgresql/data | ||
environment: | ||
- POSTGRES_USER=${POSTGRES_USER} | ||
- POSTGRES_DB=${POSTGRES_DB} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
container_name: postgres-db | ||
restart: always | ||
|
||
app: | ||
command: "poetry run python manage.py runserver 0.0.0.0:8000" | ||
build: . | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
container_name: app | ||
restart: on-failure | ||
env_file: | ||
- .env | ||
volumes: | ||
- .:/blt | ||
ports: | ||
- "8000:8000" | ||
- "${PORT}:8000" | ||
environment: | ||
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
command: ./entrypoint.sh | ||
|
||
init: | ||
profiles: | ||
- init | ||
build: . | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
env_file: | ||
- .env | ||
volumes: | ||
- .:/blt | ||
environment: | ||
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
command: ./entrypoint.sh | ||
|
||
volumes: | ||
postgres_db: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
set -x | ||
echo "Entrypoint script is running" | ||
|
||
# Wait for the database to be ready | ||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "db" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c '\q'; do | ||
>&2 echo "Postgres is unavailable - sleeping" | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Postgres is up - executing command" | ||
|
||
# Function to check if migrations are applied | ||
check_migrations() { | ||
python manage.py showmigrations --plan | grep -q "\[ \]" | ||
return $? | ||
} | ||
|
||
# Check if migrations need to be applied | ||
if check_migrations; then | ||
echo "Migrations need to be applied. Running initialization tasks." | ||
|
||
# Run migrations | ||
echo "Migration script is running" | ||
python manage.py migrate | ||
|
||
# Load initial data | ||
python manage.py loaddata website/fixtures/initial_data.json | ||
|
||
# Create superuser | ||
echo "Creating the superuser, if it does not exist!" | ||
python manage.py initsuperuser | ||
|
||
# Collect static files | ||
echo "Collecting the static files!" | ||
python manage.py collectstatic --noinput | ||
else | ||
echo "All migrations have already been applied. Skipping initialization." | ||
fi | ||
|
||
# Start the main application | ||
echo "Starting the main application http://localhost:8000/" | ||
exec python manage.py runserver 0.0.0.0:8000 |