refactor: move data.db and uploads to storage/ folder
- Changed database path to ./storage/data.db - Changed uploads path to ./storage/uploads - Updated Dockerfile to create storage/uploads dir (not uploads) - Updated entrypoint.sh to check /app/storage/data.db - Removed COPY of uploads from builder to runner Now all persistent data is in /app/storage/: - /app/storage/data.db (SQLite database) - /app/storage/uploads/ (uploaded media) Easypanel mount: emdash-storage → /app/storage To update EmDash: change version in package.json → push → redeploy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ WORKDIR /app
|
|||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN pnpm build && pnpm exec emdash init && mkdir -p uploads
|
RUN pnpm build && mkdir -p storage/uploads
|
||||||
|
|
||||||
FROM deps AS runner
|
FROM deps AS runner
|
||||||
|
|
||||||
@@ -26,7 +26,6 @@ ENV HOST=0.0.0.0
|
|||||||
|
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
COPY --from=builder /app/uploads ./uploads
|
|
||||||
|
|
||||||
EXPOSE 4321
|
EXPOSE 4321
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ export default defineConfig({
|
|||||||
integrations: [
|
integrations: [
|
||||||
react(),
|
react(),
|
||||||
emdash({
|
emdash({
|
||||||
database: sqlite({ url: "file:./data.db" }),
|
database: sqlite({ url: "file:./storage/data.db" }),
|
||||||
storage: local({
|
storage: local({
|
||||||
directory: "./uploads",
|
directory: "./storage/uploads",
|
||||||
baseUrl: "/_emdash/api/media/file",
|
baseUrl: "/_emdash/api/media/file",
|
||||||
}),
|
}),
|
||||||
plugins: [auditLogPlugin()],
|
plugins: [auditLogPlugin()],
|
||||||
|
|||||||
@@ -2,16 +2,22 @@
|
|||||||
# Wait for volume mount to settle (Easypanel may mount after container starts)
|
# Wait for volume mount to settle (Easypanel may mount after container starts)
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
# Check if data.db exists and has content
|
# Check if data.db exists in storage folder and has content
|
||||||
# Using file size as backup check (empty DB is ~8KB, seeded DB is much larger)
|
DB_PATH="/app/storage/data.db"
|
||||||
DB_SIZE=$(stat -c%s /app/data.db 2>/dev/null || stat -f%z /app/data.db 2>/dev/null || echo "0")
|
UPLOADS_PATH="/app/storage/uploads"
|
||||||
|
|
||||||
if [ -f /app/data.db ] && [ "$DB_SIZE" -gt 1000 ]; then
|
# Ensure storage directories exist
|
||||||
# DB exists and has size > 1KB, check if it has content
|
mkdir -p "$UPLOADS_PATH"
|
||||||
if sqlite3 /app/data.db "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
|
|
||||||
|
# Check if data.db exists and has content
|
||||||
|
if [ -f "$DB_PATH" ]; then
|
||||||
|
DB_SIZE=$(stat -c%s "$DB_PATH" 2>/dev/null || stat -f%z "$DB_PATH" 2>/dev/null || echo "0")
|
||||||
|
if [ "$DB_SIZE" -gt 1000 ]; then
|
||||||
|
if sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
|
||||||
echo "Database exists with content, starting normally..."
|
echo "Database exists with content, starting normally..."
|
||||||
exec node ./dist/server/entry.mjs
|
exec node ./dist/server/entry.mjs
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Database missing, empty, or corrupted. Running emdash init & seed..."
|
echo "Database missing, empty, or corrupted. Running emdash init & seed..."
|
||||||
|
|||||||
Reference in New Issue
Block a user