Skip to content

Commit 4015a22

Browse files
committed
Fix dockerfile
1 parent 751613c commit 4015a22

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

docker-entrypoint.sh

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,6 @@ docker_process_init_files() {
272272
done
273273
}
274274

275-
# create_database_from_env creates a database if the DATABASE environment variable is set.
276-
# It retrieves the database name from environment the env var DATABASE
277-
# and attempts to create the database using exec_sql.
278-
create_database_from_env() {
279-
local database
280-
database=$(get_env_var "DB")
281-
282-
if [ -n "$database" ]; then
283-
note "Creating database '${database}'"
284-
exec_sql "Failed to create database '$database': " "CREATE DATABASE IF NOT EXISTS \"$database\";"
285-
fi
286-
}
287-
288275
# is_port_open checks if a TCP port is open on a given host.
289276
# Arguments:
290277
# $1 - Host (IP or hostname)
@@ -310,12 +297,14 @@ start_server() {
310297
local start_time
311298
start_time=$(date +%s)
312299

313-
# If either of the doltgres or postgres specific user and password env vars are set, export them
300+
# If any of the doltgres or postgres specific user, password, and DB env vars are set, export them
314301
# to the ones that doltgres understands so they can be used during initialization.
315302
user=$(get_env_var "USER")
316303
password=$(get_env_var "PASSWORD")
304+
db=$(get_env_var "DB")
317305
export DOLTGRES_USER=$user
318306
export DOLTGRES_PASSWORD=$password
307+
export DOLTGRES_DB=$db
319308

320309
SERVER_PID=-1
321310

@@ -419,8 +408,6 @@ _main() {
419408

420409
start_server "$@"
421410

422-
create_database_from_env
423-
424411
if [[ ! -f $INIT_COMPLETED ]]; then
425412
if ls /docker-entrypoint-initdb.d/* >/dev/null 2>&1; then
426413
docker_process_init_files /docker-entrypoint-initdb.d/*

server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ func createDefaultDatabase(cfg doltservercfg.ServerConfig) error {
218218
// If the environment variable DOLTGRES_DB is set, that value is used. Otherwise, the username is used.
219219
// The username is in turn configured with the environment variable DOLTGRES_USER, defaulting to "postgres".
220220
func getDefaultDatabaseName(userName string) string {
221-
defaultDbName, defaultDbNameSet := os.LookupEnv(DefaultDbNameEnvVar)
222-
if defaultDbNameSet {
221+
defaultDbName := os.Getenv(DefaultDbNameEnvVar)
222+
if defaultDbName != "" {
223223
return defaultDbName
224224
}
225225
return userName

0 commit comments

Comments
 (0)