Skip to content
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

Update mongo #13043

Merged
merged 1 commit into from
Aug 25, 2022
Merged

Update mongo #13043

merged 1 commit into from
Aug 25, 2022

Conversation

tianon
Copy link
Member

@tianon tianon commented Aug 25, 2022

Changes:

Changes:

- docker-library/mongo@ee1d695: Merge pull request docker-library/mongo#559 from infosiftr/missed-one
- docker-library/mongo@9631e54: Fix missed mongo to use mongosh on 6.0
@github-actions
Copy link

Diff for 7a061fd:
diff --git a/_bashbrew-cat b/_bashbrew-cat
index c5b7d80..6846279 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -32,13 +32,13 @@ Constraints: windowsservercore-ltsc2022
 Tags: 4.0.28-xenial, 4.0-xenial
 SharedTags: 4.0.28, 4.0
 Architectures: amd64, arm64v8
-GitCommit: 06b403b869fc79cf176561a47e5ccebf97a42bad
+GitCommit: 9631e54a2885018f440e8da2840c21793c156f94
 Directory: 4.0
 
 Tags: 4.2.22-bionic, 4.2-bionic
 SharedTags: 4.2.22, 4.2
 Architectures: amd64, arm64v8
-GitCommit: 06b403b869fc79cf176561a47e5ccebf97a42bad
+GitCommit: 9631e54a2885018f440e8da2840c21793c156f94
 Directory: 4.2
 
 Tags: 4.2.22-nanoserver-1809, 4.2-nanoserver-1809
@@ -72,7 +72,7 @@ Constraints: windowsservercore-ltsc2022
 Tags: 4.4.16-focal, 4.4-focal, 4-focal
 SharedTags: 4.4.16, 4.4, 4
 Architectures: amd64, arm64v8
-GitCommit: 06b403b869fc79cf176561a47e5ccebf97a42bad
+GitCommit: 9631e54a2885018f440e8da2840c21793c156f94
 Directory: 4.4
 
 Tags: 4.4.16-nanoserver-1809, 4.4-nanoserver-1809, 4-nanoserver-1809
@@ -106,7 +106,7 @@ Constraints: windowsservercore-ltsc2022
 Tags: 5.0.11-focal, 5.0-focal, 5-focal
 SharedTags: 5.0.11, 5.0, 5
 Architectures: amd64, arm64v8
-GitCommit: 06b403b869fc79cf176561a47e5ccebf97a42bad
+GitCommit: 9631e54a2885018f440e8da2840c21793c156f94
 Directory: 5.0
 
 Tags: 5.0.11-nanoserver-1809, 5.0-nanoserver-1809, 5-nanoserver-1809
@@ -140,7 +140,7 @@ Constraints: windowsservercore-ltsc2022
 Tags: 6.0.1-focal, 6.0-focal, 6-focal, focal
 SharedTags: 6.0.1, 6.0, 6, latest
 Architectures: amd64, arm64v8
-GitCommit: 06b403b869fc79cf176561a47e5ccebf97a42bad
+GitCommit: 9631e54a2885018f440e8da2840c21793c156f94
 Directory: 6.0
 
 Tags: 6.0.1-nanoserver-1809, 6.0-nanoserver-1809, 6-nanoserver-1809, nanoserver-1809
diff --git a/mongo_4-focal/docker-entrypoint.sh b/mongo_4-focal/docker-entrypoint.sh
index 2313c41..73ac921 100755
--- a/mongo_4-focal/docker-entrypoint.sh
+++ b/mongo_4-focal/docker-entrypoint.sh
@@ -196,7 +196,12 @@ _parse_config() {
 			echo >&2
 			return 1
 		fi
-		mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		if [ "$mongoShell" = 'mongo' ]; then
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		else
+			# https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile"
+		fi
 		if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then
 			# if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out
 			echo >&2 'error: unexpected "js-yaml.js" output while parsing config:'
@@ -242,6 +247,12 @@ _dbPath() {
 if [ "$originalArgOne" = 'mongod' ]; then
 	file_env 'MONGO_INITDB_ROOT_USERNAME'
 	file_env 'MONGO_INITDB_ROOT_PASSWORD'
+
+	mongoShell='mongo'
+	if ! command -v "$mongoShell" > /dev/null; then
+		mongoShell='mongosh'
+	fi
+
 	# pre-check a few factors to see if it's even worth bothering with initdb
 	shouldPerformInitdb=
 	if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
@@ -337,11 +348,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
 
 		"${mongodHackedArgs[@]}" --fork
 
-		mongoShell='mongo'
-		if ! command -v "$mongoShell" > /dev/null; then
-			mongoShell='mongosh'
-		fi
-
 		mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet )
 
 		# check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc)
diff --git a/mongo_4.0-xenial/docker-entrypoint.sh b/mongo_4.0-xenial/docker-entrypoint.sh
index 2313c41..73ac921 100755
--- a/mongo_4.0-xenial/docker-entrypoint.sh
+++ b/mongo_4.0-xenial/docker-entrypoint.sh
@@ -196,7 +196,12 @@ _parse_config() {
 			echo >&2
 			return 1
 		fi
-		mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		if [ "$mongoShell" = 'mongo' ]; then
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		else
+			# https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile"
+		fi
 		if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then
 			# if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out
 			echo >&2 'error: unexpected "js-yaml.js" output while parsing config:'
@@ -242,6 +247,12 @@ _dbPath() {
 if [ "$originalArgOne" = 'mongod' ]; then
 	file_env 'MONGO_INITDB_ROOT_USERNAME'
 	file_env 'MONGO_INITDB_ROOT_PASSWORD'
+
+	mongoShell='mongo'
+	if ! command -v "$mongoShell" > /dev/null; then
+		mongoShell='mongosh'
+	fi
+
 	# pre-check a few factors to see if it's even worth bothering with initdb
 	shouldPerformInitdb=
 	if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
@@ -337,11 +348,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
 
 		"${mongodHackedArgs[@]}" --fork
 
-		mongoShell='mongo'
-		if ! command -v "$mongoShell" > /dev/null; then
-			mongoShell='mongosh'
-		fi
-
 		mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet )
 
 		# check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc)
diff --git a/mongo_4.2-bionic/docker-entrypoint.sh b/mongo_4.2-bionic/docker-entrypoint.sh
index 2313c41..73ac921 100755
--- a/mongo_4.2-bionic/docker-entrypoint.sh
+++ b/mongo_4.2-bionic/docker-entrypoint.sh
@@ -196,7 +196,12 @@ _parse_config() {
 			echo >&2
 			return 1
 		fi
-		mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		if [ "$mongoShell" = 'mongo' ]; then
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		else
+			# https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile"
+		fi
 		if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then
 			# if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out
 			echo >&2 'error: unexpected "js-yaml.js" output while parsing config:'
@@ -242,6 +247,12 @@ _dbPath() {
 if [ "$originalArgOne" = 'mongod' ]; then
 	file_env 'MONGO_INITDB_ROOT_USERNAME'
 	file_env 'MONGO_INITDB_ROOT_PASSWORD'
+
+	mongoShell='mongo'
+	if ! command -v "$mongoShell" > /dev/null; then
+		mongoShell='mongosh'
+	fi
+
 	# pre-check a few factors to see if it's even worth bothering with initdb
 	shouldPerformInitdb=
 	if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
@@ -337,11 +348,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
 
 		"${mongodHackedArgs[@]}" --fork
 
-		mongoShell='mongo'
-		if ! command -v "$mongoShell" > /dev/null; then
-			mongoShell='mongosh'
-		fi
-
 		mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet )
 
 		# check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc)
diff --git a/mongo_5-focal/docker-entrypoint.sh b/mongo_5-focal/docker-entrypoint.sh
index 2313c41..73ac921 100755
--- a/mongo_5-focal/docker-entrypoint.sh
+++ b/mongo_5-focal/docker-entrypoint.sh
@@ -196,7 +196,12 @@ _parse_config() {
 			echo >&2
 			return 1
 		fi
-		mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		if [ "$mongoShell" = 'mongo' ]; then
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		else
+			# https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile"
+		fi
 		if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then
 			# if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out
 			echo >&2 'error: unexpected "js-yaml.js" output while parsing config:'
@@ -242,6 +247,12 @@ _dbPath() {
 if [ "$originalArgOne" = 'mongod' ]; then
 	file_env 'MONGO_INITDB_ROOT_USERNAME'
 	file_env 'MONGO_INITDB_ROOT_PASSWORD'
+
+	mongoShell='mongo'
+	if ! command -v "$mongoShell" > /dev/null; then
+		mongoShell='mongosh'
+	fi
+
 	# pre-check a few factors to see if it's even worth bothering with initdb
 	shouldPerformInitdb=
 	if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
@@ -337,11 +348,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
 
 		"${mongodHackedArgs[@]}" --fork
 
-		mongoShell='mongo'
-		if ! command -v "$mongoShell" > /dev/null; then
-			mongoShell='mongosh'
-		fi
-
 		mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet )
 
 		# check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc)
diff --git a/mongo_focal/docker-entrypoint.sh b/mongo_focal/docker-entrypoint.sh
index 2313c41..73ac921 100755
--- a/mongo_focal/docker-entrypoint.sh
+++ b/mongo_focal/docker-entrypoint.sh
@@ -196,7 +196,12 @@ _parse_config() {
 			echo >&2
 			return 1
 		fi
-		mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		if [ "$mongoShell" = 'mongo' ]; then
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
+		else
+			# https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh
+			"$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile"
+		fi
 		if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then
 			# if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out
 			echo >&2 'error: unexpected "js-yaml.js" output while parsing config:'
@@ -242,6 +247,12 @@ _dbPath() {
 if [ "$originalArgOne" = 'mongod' ]; then
 	file_env 'MONGO_INITDB_ROOT_USERNAME'
 	file_env 'MONGO_INITDB_ROOT_PASSWORD'
+
+	mongoShell='mongo'
+	if ! command -v "$mongoShell" > /dev/null; then
+		mongoShell='mongosh'
+	fi
+
 	# pre-check a few factors to see if it's even worth bothering with initdb
 	shouldPerformInitdb=
 	if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
@@ -337,11 +348,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
 
 		"${mongodHackedArgs[@]}" --fork
 
-		mongoShell='mongo'
-		if ! command -v "$mongoShell" > /dev/null; then
-			mongoShell='mongosh'
-		fi
-
 		mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet )
 
 		# check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc)

Relevant Maintainers:

@yosifkit yosifkit merged commit 101343d into docker-library:master Aug 25, 2022
@yosifkit yosifkit deleted the mongo branch August 25, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants