Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Database Import and Streamlit Dashboard Setup via Doc… #474

Merged
merged 3 commits into from
Feb 27, 2025
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
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