Skip to content

Commit 5a007e7

Browse files
committed
🧸 change to mongodb-community-server:latest 🧸
1 parent a8f5473 commit 5a007e7

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ make podman-run
1919

2020
Database:
2121
```
22-
podman run --name mongo -p 27017:27017 mongo:latest
22+
podman run --name mongo -p 27017:27017 docker.io/mongodb/mongodb-community-server:latest
2323
```
2424

2525
Application:
@@ -67,7 +67,7 @@ Deploy MongoDB
6767

6868
```bash
6969
oc apply -f mongodb-persistent.yml
70-
oc new-app mongodb-persistent -p MONGODB_DATABASE=cats -p MONGODB_USER=catuser -p MONGODB_PASSWORD=password -p MONGODB_ADMIN_PASSWORD=password
70+
oc new-app mongodb-persistent -p MONGODB_DB=cats -p MONGODB_USER=catuser -p MONGODB_PASSWORD=password -p MONGODB_ADMIN_PASSWORD=password
7171
```
7272

7373
Build and deploy application on OpenShift using Jkube-s2i

‎mongodb-persistent.yml‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ objects:
8686
- name: latest
8787
from:
8888
kind: DockerImage
89-
name: "registry.access.redhat.com/rhscl/mongodb-36-rhel7:${MONGODB_VERSION}"
89+
name: "docker.io/mongodb/mongodb-community-server:${MONGODB_VERSION}" # registry.access.redhat.com/rhscl/mongodb-36-rhel7:${MONGODB_VERSION}"
9090
importPolicy:
9191
insecure: true
9292
referencePolicy:
@@ -121,20 +121,36 @@ objects:
121121
secretKeyRef:
122122
key: database-password
123123
name: ${DATABASE_SERVICE_NAME}
124-
- name: MONGODB_ADMIN_PASSWORD
124+
- name: MONGO_INITDB_ROOT_USERNAME
125+
valueFrom:
126+
secretKeyRef:
127+
key: database-user
128+
name: ${DATABASE_SERVICE_NAME}
129+
- name: MONGO_INITDB_ROOT_PASSWORD
125130
valueFrom:
126131
secretKeyRef:
127132
key: database-admin-password
128133
name: ${DATABASE_SERVICE_NAME}
129-
- name: MONGODB_DATABASE
130-
value: ${MONGODB_DATABASE}
134+
- name: MONGODB_DB
135+
value: ${MONGODB_DB}
131136
image: ' '
132137
imagePullPolicy: IfNotPresent
133138
livenessProbe:
134139
initialDelaySeconds: 30
135140
tcpSocket:
136141
port: 27017
137142
timeoutSeconds: 1
143+
lifecycle:
144+
postStart:
145+
exec:
146+
command:
147+
- /bin/bash
148+
- -i
149+
- -c
150+
- |
151+
if ( $(sleep 5 && mongosh -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --eval="use $MONGODB_DB" --eval='db.getUsers().users.length == 0') ); then
152+
sleep 5 && mongosh -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --eval="use $MONGODB_DB" --eval='db.createUser( {"pwd":"$MONGODB_PASSWORD","roles":["readWrite","dbAdmin"],"user":"$MONGODB_USER"} )'
153+
fi
138154
name: mongodb
139155
ports:
140156
- containerPort: 27017
@@ -202,9 +218,9 @@ parameters:
202218
required: true
203219
- description: Name of the MongoDB database accessed.
204220
displayName: MongoDB Database Name
205-
name: MONGODB_DATABASE
221+
name: MONGODB_DB
206222
required: true
207-
value: sampledb
223+
value: cats
208224
- description: Password for the database admin user.
209225
displayName: MongoDB Admin Password
210226
from: '[a-zA-Z0-9]{16}'
@@ -224,7 +240,7 @@ parameters:
224240
- description: The name of the MongoDB imagestream to be used
225241
displayName: Name of MongoDB Image
226242
name: MONGODB_IMAGE
227-
value: mongodb-36-rhel7
243+
value: mongodb
228244
- description: Version of MongoDB image to be used
229245
displayName: Version of MongoDB Image
230246
name: MONGODB_VERSION

0 commit comments

Comments
 (0)