-
Notifications
You must be signed in to change notification settings - Fork 81
Only create DB directory if using embedded DB #267
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
Conversation
If an external database is being used there is no need to create the local database files. This prevents the database files from being created unless the embedded database is being used.
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant S as Entrypoint.sh
participant DB as PostgreSQL Database
S->>S: Evaluate DATABASE_URL against connection string
alt Match Found
S->>S: Set DATABASE_EMBEDDED = true
else No Match
S->>S: DATABASE_EMBEDDED remains unset
end
S->>S: Check if DATABASE_DATA_DIR exists
alt DATABASE_DATA_DIR missing & DATABASE_EMBEDDED true
S->>S: Initialize database directory
end
S->>S: Check DATABASE_EMBEDDED condition for startup
alt DATABASE_EMBEDDED true
S->>DB: Start PostgreSQL Database
end
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
entrypoint.sh (3)
4-6
: Set DATABASE_EMBEDDED Based on DATABASE_URL
The new conditional block correctly setsDATABASE_EMBEDDED
whenDATABASE_URL
exactly matches the embedded connection string. To improve clarity and avoid any future surprises, consider explicitly settingDATABASE_EMBEDDED
to"false"
in an else clause so that its value is defined regardless of theDATABASE_URL
value.
37-41
: Initialization of DATABASE_DATA_DIR with Embedded DB
The condition now ensures that the database directory is only initialized when using the embedded database. However, in themkdir -p
command, the$DATABASE_DATA_DIR
variable is not quoted while it is quoted in the subsequentchown
command. To maintain consistency and avoid issues with paths that might include spaces, please quote$DATABASE_DATA_DIR
in themkdir
command.Proposed diff:
- mkdir -p $DATABASE_DATA_DIR && chown -R postgres:postgres "$DATABASE_DATA_DIR" + mkdir -p "$DATABASE_DATA_DIR" && chown -R postgres:postgres "$DATABASE_DATA_DIR"🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 38-38: In POSIX sh, echo flags are undefined.
(SC3037)
136-142
: Conditional Startup for Embedded PostgreSQL
The revised block correctly restricts the PostgreSQL startup to scenarios whereDATABASE_EMBEDDED
is"true"
. As a minor improvement, consider quoting$DATABASE_DATA_DIR
in the command used bysu postgres -c "postgres -D $DATABASE_DATA_DIR"
to handle potential spaces in the path.Proposed diff:
- su postgres -c "postgres -D $DATABASE_DATA_DIR" & + su postgres -c "postgres -D \"$DATABASE_DATA_DIR\"" &🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 139-139: In POSIX sh, echo flags are undefined.
(SC3037)
Thanks! Will merge tmwr when I get the chance to sanity check repro |
If an external database is being used there is no need to create the local database files. This prevents the database files from being created unless the embedded database is being used.
Summary by CodeRabbit