Skip to content

Commit 54bd164

Browse files
committed
Try again with mongocryptd
1 parent aad1756 commit 54bd164

File tree

1 file changed

+40
-25
lines changed

1 file changed

+40
-25
lines changed
Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
11
#!/bin/bash
22
set -eu
33

4-
echo "Starting MongoDB Atlas Local container..."
4+
echo "Starting MongoDB Atlas Local and mongocryptd..."
5+
6+
# Configurable image names
7+
ATLAS_LOCAL_IMAGE=${1:-mongodb/mongodb-atlas-local:latest}
8+
MONGOCRYPTD_IMAGE=${2:-mongodb/mongodb-enterprise-server:latest}
59

6-
IMAGE=${1:-mongodb/mongodb-atlas-local:latest}
710
DOCKER=$(which docker || which podman)
811

9-
# Pull the latest Atlas Local image
10-
$DOCKER pull $IMAGE
12+
# --- Start Atlas Local ---
13+
echo "Pulling Atlas Local image..."
14+
$DOCKER pull $ATLAS_LOCAL_IMAGE
1115

12-
# Stop any existing Atlas Local container
16+
echo "Stopping existing Atlas Local container (if any)..."
1317
$DOCKER kill mongodb_atlas_local || true
1418

15-
# Run Atlas Local
16-
CONTAINER_ID=$($DOCKER run --rm -d --name mongodb_atlas_local -p 27017:27017 $IMAGE)
19+
echo "Starting Atlas Local container..."
20+
ATLAS_LOCAL_ID=$($DOCKER run --rm -d \
21+
--name mongodb_atlas_local \
22+
-p 27017:27017 \
23+
$ATLAS_LOCAL_IMAGE)
1724

25+
# --- Wait for Atlas Local logs ---
1826
function wait_for_container() {
19-
local container_id=$1
20-
echo "Waiting for container to become healthy..."
21-
sleep 2
22-
$DOCKER logs mongodb_atlas_local
27+
local name=$1
28+
echo "Waiting for $name to be ready..."
29+
sleep 2
30+
$DOCKER logs "$name" || true
2331
}
2432

25-
wait_for_container "$CONTAINER_ID"
33+
wait_for_container mongodb_atlas_local
2634

27-
# Give services time to start
28-
sleep 5
35+
# --- Start mongocryptd ---
36+
echo "Pulling MongoDB Enterprise image (for mongocryptd)..."
37+
$DOCKER pull $MONGOCRYPTD_IMAGE
38+
39+
echo "Stopping existing mongocryptd container (if any)..."
40+
$DOCKER kill mongocryptd_container || true
2941

30-
echo "Starting mongocryptd for Client-Side Field Level Encryption..."
42+
echo "Starting mongocryptd container..."
43+
# Expose port 27020 to host so drivers can connect
44+
MONGOCRYPTD_ID=$($DOCKER run --rm -d \
45+
--name mongocryptd_container \
46+
-p 27020:27020 \
47+
$MONGOCRYPTD_IMAGE \
48+
mongocryptd --port=27020 --bind_ip=0.0.0.0)
3149

32-
# Check if mongocryptd is already running
33-
if pgrep -x "mongocryptd" > /dev/null; then
34-
echo "mongocryptd is already running."
35-
else
36-
# Start mongocryptd locally
37-
mongocryptd --port=27020 --bind_ip=127.0.0.1 --logpath=mongocryptd.log --fork
38-
echo "mongocryptd started on 127.0.0.1:27020"
39-
fi
50+
wait_for_container mongocryptd_container
51+
52+
echo "Sleeping for a few seconds for services to initialize..."
53+
sleep 5
4054

41-
echo "Atlas Local running on port 27017"
42-
echo "mongocryptd running on port 27020"
55+
# --- Status ---
56+
echo "✅ Atlas Local running on: mongodb://localhost:27017"
57+
echo "✅ mongocryptd running on: localhost:27020"

0 commit comments

Comments
 (0)