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 . .
|
||||
|
||||
RUN pnpm build && pnpm exec emdash init && mkdir -p uploads
|
||||
RUN pnpm build && mkdir -p storage/uploads
|
||||
|
||||
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/dist ./dist
|
||||
COPY --from=builder /app/uploads ./uploads
|
||||
|
||||
EXPOSE 4321
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ export default defineConfig({
|
||||
integrations: [
|
||||
react(),
|
||||
emdash({
|
||||
database: sqlite({ url: "file:./data.db" }),
|
||||
database: sqlite({ url: "file:./storage/data.db" }),
|
||||
storage: local({
|
||||
directory: "./uploads",
|
||||
directory: "./storage/uploads",
|
||||
baseUrl: "/_emdash/api/media/file",
|
||||
}),
|
||||
plugins: [auditLogPlugin()],
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
# Wait for volume mount to settle (Easypanel may mount after container starts)
|
||||
sleep 3
|
||||
|
||||
# Check if data.db exists and has content
|
||||
# Using file size as backup check (empty DB is ~8KB, seeded DB is much larger)
|
||||
DB_SIZE=$(stat -c%s /app/data.db 2>/dev/null || stat -f%z /app/data.db 2>/dev/null || echo "0")
|
||||
# Check if data.db exists in storage folder and has content
|
||||
DB_PATH="/app/storage/data.db"
|
||||
UPLOADS_PATH="/app/storage/uploads"
|
||||
|
||||
if [ -f /app/data.db ] && [ "$DB_SIZE" -gt 1000 ]; then
|
||||
# DB exists and has size > 1KB, check if it has content
|
||||
if sqlite3 /app/data.db "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
|
||||
echo "Database exists with content, starting normally..."
|
||||
exec node ./dist/server/entry.mjs
|
||||
# Ensure storage directories exist
|
||||
mkdir -p "$UPLOADS_PATH"
|
||||
|
||||
# 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..."
|
||||
exec node ./dist/server/entry.mjs
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user