Skip to content

Instantly share code, notes, and snippets.

View BrianMwas's full-sized avatar
🎯
Make it happen

Brian Mwangi BrianMwas

🎯
Make it happen
View GitHub Profile
@BrianMwas
BrianMwas / build.run
Created October 16, 2023 07:19
Build app from Dockerfile
docker build -t golangmongo .
@BrianMwas
BrianMwas / command_two.yaml
Created August 14, 2023 06:20
Docker compose down
docker compose down
@BrianMwas
BrianMwas / command.yaml
Created August 14, 2023 06:19
Docker compose up command
docker compose up
@BrianMwas
BrianMwas / docker-compose.yaml
Created August 14, 2023 06:17
Complete Docker compose configuration for MongoDB
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
@BrianMwas
BrianMwas / init.js
Created August 13, 2023 18:26
Initialise script that initializes the databases
// 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({
COPY init.js /docker-entrypoint-initdb.d/
@BrianMwas
BrianMwas / run.yaml
Last active October 16, 2023 07:21
Run docker compose command
docker run --name golangmongo -p 4400:4400 gomongo-dev:latest
COPY start.sh .
COPY wait-for.sh .
RUN chmod +x wait-for.sh && chmod +x start.sh
version: '3.9'
services:
mongo:
image: mongo
restart: always
container_name: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=subz
- MONGO_INITDB_ROOT_PASSWORD=subz2023
docker build -t gomongo:latest .