This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t golangmongo . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo: | |
image: mongo | |
restart: always | |
container_name: mongo | |
ports: | |
- "8081:27017" | |
volumes: | |
- ./data/mongo:/data/db | |
# We have added it here. Ensure its under the /docker-entrypoint-initdb.d | |
- ./data/mongo/init.js:/docker-entrypoint-initdb.d/init.js:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read values from the environment variables | |
var username = 'user'; | |
var password = 'secret'; | |
var database = 'admin'; | |
// set the authentication database | |
db = db.getSiblingDB(database) | |
// Create a user with the specified username, password, and database | |
db.createUser({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COPY init.js /docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --name golangmongo -p 4400:4400 gomongo-dev:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COPY start.sh . | |
COPY wait-for.sh . | |
RUN chmod +x wait-for.sh && chmod +x start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.9' | |
services: | |
mongo: | |
image: mongo | |
restart: always | |
container_name: mongo | |
environment: | |
- MONGO_INITDB_ROOT_USERNAME=subz | |
- MONGO_INITDB_ROOT_PASSWORD=subz2023 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t gomongo:latest . |
NewerOlder