File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Use the official MongoDB imagee
2
+ FROM mongo:latest
3
+
4
+ # Create a directory to host initialization scripts
5
+ RUN mkdir -p /docker-entrypoint-initdb.d
6
+
7
+ # Copy default data JSON files to the initialization directory
8
+ COPY ./default-data/*.json /docker-entrypoint-initdb.d/
9
+
10
+ # Copy a custom initialization script that imports the default data
11
+ COPY ./mongo-init.sh /docker-entrypoint-initdb.d/
12
+
13
+ # Make the initialization script executable
14
+ RUN chmod +x /docker-entrypoint-initdb.d/mongo-init.sh
15
+
16
+ # MongoDB environment variables (optional)
17
+ ENV MONGO_INITDB_ROOT_USERNAME=root
18
+ ENV MONGO_INITDB_ROOT_PASSWORD=example
19
+
20
+ # Execute the initialization script during container startup
21
+ CMD ["mongod" , "--auth" ]
You can’t perform that action at this time.
0 commit comments