Skip to content

Commit

Permalink
Merge pull request #474 from Runtee/sql-dump
Browse files Browse the repository at this point in the history
feat: Implement Database Import and Streamlit Dashboard Setup via Doc…
  • Loading branch information
djeck1432 authored Feb 27, 2025
2 parents f74ddbe + 610385b commit 65fb87c
Show file tree
Hide file tree
Showing 6 changed files with 1,086 additions and 28 deletions.
33 changes: 33 additions & 0 deletions apps/dashboard_app/.entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -e # Exit immediately if any command fails

# Wait for the database to be ready
# Import data from dump file
if [ -f ./derisk_dump_part_aa.sql ]; then
echo "Importing data from derisk_dump_part_aa.sql..."
PGPASSWORD="$DB_PASSWORD" psql -U "$DB_USER" -d "$DB_NAME" -h "$DB_HOST" -p "$DB_PORT" -f ./derisk_dump_part_aa.sql
echo "Data import complete."
else
echo "No ./derisk_dump_part_aa.sql file found."
while true; do
read -p "Do you want to continue without importing data? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
echo "Skipping data import and continuing..."
break
;;
no|NO|n|N)
echo "Stopping the process as requested."
exit 1
;;
*)
echo "Invalid input. Please type 'yes' or 'no'."
;;
esac
done
fi

## Start Streamlit
#echo "Starting Streamlit application..."
#streamlit run dashboard.py --server.port=8501 --server.address=0.0.0.0
2 changes: 1 addition & 1 deletion apps/dashboard_app/.env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PostgreSQL
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=data_handler
DB_NAME=postgres
DB_HOST=db
DB_PORT=5432
18 changes: 9 additions & 9 deletions apps/dashboard_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM python:3.10
FROM python:3.12

RUN apt-get update && apt-get install -y \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

RUN pip install poetry
COPY legacy_app/pyproject.toml legacy_app/poetry.lock* ./
COPY pyproject.toml poetry.lock* ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi

COPY legacy_app/src legacy_app/src
COPY legacy_app/app.py .
COPY legacy_app/update_data.py .

CMD ["streamlit", "run", "dashboard.py"]
&& poetry install --no-interaction --no-ansi --no-root

COPY . .
ENTRYPOINT ["../.entrypoint.sh"]
Loading

0 comments on commit 65fb87c

Please sign in to comment.