File tree Expand file tree Collapse file tree 5 files changed +15
-15
lines changed
Expand file tree Collapse file tree 5 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,13 @@ COPY --chown=root:root --chmod=755 assets ./assets
4747
4848# Copy entrypoint sctipt and SQLite database
4949COPY --chown=root:root --chmod=755 scripts/entrypoint.sh ./entrypoint.sh
50- COPY --chown=root:root --chmod=755 sqlite3-db ./docker-compose
50+ COPY --chown=root:root --chmod=755 storage ./docker-compose
5151
5252# Create non-root user and make volume mount point writable
5353RUN groupadd --system fastapi && \
5454 adduser --system --ingroup fastapi --disabled-password --gecos '' fastapi && \
55- mkdir -p /sqlite3-db && \
56- chown fastapi:fastapi /sqlite3-db
55+ mkdir -p /storage && \
56+ chown fastapi:fastapi /storage
5757
5858# Drop privileges
5959USER fastapi
Original file line number Diff line number Diff line change 88from sqlalchemy .ext .asyncio import create_async_engine , AsyncSession
99from sqlalchemy .orm import sessionmaker , declarative_base
1010
11- database_file_path = os .getenv ("DATABASE_FILE_PATH " , "./sqlite3-db /players-sqlite3.db" )
12- DATABASE_URL = f"sqlite+aiosqlite:///{ database_file_path } "
11+ storage_path = os .getenv ("STORAGE_PATH " , "./storage /players-sqlite3.db" )
12+ DATABASE_URL = f"sqlite+aiosqlite:///{ storage_path } "
1313
1414logger = logging .getLogger ("uvicorn" )
1515logging .getLogger ("sqlalchemy.engine.Engine" ).handlers = logger .handlers
Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ services:
88 ports :
99 - " 9000:9000"
1010 volumes :
11- - sqlite3-db:/sqlite3-db /
11+ - storage:/storage /
1212 environment :
1313 - PYTHONUNBUFFERED=1
14- - DATABASE_FILE_PATH=/sqlite3-db /players-sqlite3.db
14+ - STORAGE_PATH=/storage /players-sqlite3.db
1515 restart : unless-stopped
1616
1717volumes :
18- sqlite3-db :
18+ storage :
Original file line number Diff line number Diff line change 11#! /bin/bash
22set -e
33
4- IMAGE_DATABASE_FILE_PATH =" /app/docker-compose/players-sqlite3.db"
5- VOLUME_DATABASE_FILE_PATH =" /sqlite3-db /players-sqlite3.db"
4+ IMAGE_STORAGE_PATH =" /app/docker-compose/players-sqlite3.db"
5+ VOLUME_STORAGE_PATH =" /storage /players-sqlite3.db"
66
77echo " ✔ Starting container..."
88
9- if [ ! -f " $VOLUME_DATABASE_FILE_PATH " ]; then
9+ if [ ! -f " $VOLUME_STORAGE_PATH " ]; then
1010 echo " ⚠️ No existing database file found in volume."
11- if [ -f " $IMAGE_DATABASE_FILE_PATH " ]; then
11+ if [ -f " $IMAGE_STORAGE_PATH " ]; then
1212 echo " Copying database file to writable volume..."
13- cp " $IMAGE_DATABASE_FILE_PATH " " $VOLUME_DATABASE_FILE_PATH "
14- echo " ✔ Database initialized at $VOLUME_DATABASE_FILE_PATH "
13+ cp " $IMAGE_STORAGE_PATH " " $VOLUME_STORAGE_PATH "
14+ echo " ✔ Database initialized at $VOLUME_STORAGE_PATH "
1515 else
16- echo " ⚠️ Database file missing at $IMAGE_DATABASE_FILE_PATH "
16+ echo " ⚠️ Database file missing at $IMAGE_STORAGE_PATH "
1717 exit 1
1818 fi
1919else
File renamed without changes.
You can’t perform that action at this time.
0 commit comments