|
1 | 1 | #!/bin/sh |
2 | 2 | set -e |
3 | 3 |
|
4 | | -echo "✔ Executing entrypoint script..." |
| 4 | +# Helper function for formatted logging |
| 5 | +log() { |
| 6 | + echo "[ENTRYPOINT] $(date '+%Y/%m/%d - %H:%M:%S') | $1" |
| 7 | + return 0 |
| 8 | +} |
5 | 9 |
|
6 | | -IMAGE_STORAGE_PATH="/app/hold/players-sqlite3.db" |
7 | | -VOLUME_STORAGE_PATH="/storage/players-sqlite3.db" |
| 10 | +log "✔ Starting container..." |
8 | 11 |
|
9 | | -echo "✔ Starting container..." |
| 12 | +STORAGE_PATH="${STORAGE_PATH:-storage/players-sqlite3.db}" |
10 | 13 |
|
11 | | -if [ ! -f "$VOLUME_STORAGE_PATH" ]; then |
12 | | - echo "⚠️ No existing database file found in volume." |
13 | | - if [ -f "$IMAGE_STORAGE_PATH" ]; then |
14 | | - echo "Copying database file to writable volume..." |
15 | | - if cp "$IMAGE_STORAGE_PATH" "$VOLUME_STORAGE_PATH"; then |
16 | | - echo "✔ Database initialized at $VOLUME_STORAGE_PATH" |
17 | | - else |
18 | | - echo "❌ Failed to copy database from $IMAGE_STORAGE_PATH to $VOLUME_STORAGE_PATH" |
19 | | - echo " Check file permissions and available disk space." |
20 | | - exit 1 |
21 | | - fi |
22 | | - else |
23 | | - echo "⚠️ Database file missing at $IMAGE_STORAGE_PATH" |
24 | | - exit 1 |
25 | | - fi |
| 14 | +mkdir -p "$(dirname "$STORAGE_PATH")" |
| 15 | + |
| 16 | +if [ ! -f "$STORAGE_PATH" ]; then |
| 17 | + log "⚠️ No existing database file found at $STORAGE_PATH." |
| 18 | + log "🗄️ Flyway migrations will initialize the database on first start." |
26 | 19 | else |
27 | | - echo "✔ Existing database file found. Skipping seed copy." |
| 20 | + log "✔ Existing database file found at $STORAGE_PATH." |
28 | 21 | fi |
29 | 22 |
|
30 | | -echo "✔ Ready!" |
31 | | -echo "🚀 Launching app..." |
32 | | -echo "" |
33 | | -echo "🔌 Endpoints:" |
34 | | -echo " Health: http://localhost:9001/actuator/health" |
35 | | -echo " Players: http://localhost:9000/players" |
36 | | -echo "" |
| 23 | +log "✔ Ready!" |
| 24 | +log "🚀 Launching app..." |
| 25 | +log "🔌 API endpoints | http://localhost:9000" |
| 26 | +log "📚 Swagger UI | http://localhost:9000/swagger/index.html" |
| 27 | +log "❤️ Health check | http://localhost:9001/actuator/health" |
37 | 28 | exec "$@" |
0 commit comments