Skip to content

Commit 71fcdff

Browse files
authored
Create Dockerfile
1 parent 1e03144 commit 71fcdff

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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"]

0 commit comments

Comments
 (0)