Compare commits

..

2 Commits

Author SHA1 Message Date
76edbf0624 feat: add MongoDB and Mongo Express services with initialization script
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m41s
2025-02-09 17:16:16 +01:00
280a013c48 feat: CI-CD workflow for building and pushing Docker images (#2)
Reviewed-on: #2
Co-authored-by: Mirko Milovanovic <mir_ko@me.com>
Co-committed-by: Mirko Milovanovic <mir_ko@me.com>
2025-02-09 17:16:16 +01:00
3 changed files with 87 additions and 0 deletions

5
server/.env.example Normal file
View File

@@ -0,0 +1,5 @@
# MongoDB Environment
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=password
MONGO_EXPRESS_USERNAME=admin
MONGO_EXPRESS_PASSWORD=password

49
server/docker-compose.yml Normal file
View File

@@ -0,0 +1,49 @@
services:
mongodb:
image: mongo:latest
container_name: mongodb
hostname: mongodb
volumes:
- ./mongodb/initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
- mongodb-data:/data/db/
- mongodb-log:/var/log/mongodb/
env_file:
- .env
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
ports:
- "27017:27017"
networks:
- mongodb_network
mongo-express:
image: mongo-express:latest
container_name: mongo-express
restart: always
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_INITDB_ROOT_USERNAME}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_MONGODB_SERVER: 'mongodb'
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_USERNAME}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_PASSWORD}
ports:
- 8081:8081
networks:
- mongodb_network
depends_on:
- mongodb
volumes:
mongodb-data:
driver: local
name: mongo-data
mongodb-log:
driver: local
name: mongo-log
networks:
mongodb_network:
driver: bridge
name: mongo-network

View File

@@ -0,0 +1,33 @@
db = db.getSiblingDB("statistics");
db.createRole({
role: "statsReadWrite",
privileges: [
{
resource: {
db: "statistics",
collection: "peertube",
},
actions: ["insert"],
},
],
roles: [
{
role: "read",
db: "statistics",
},
],
});
db.createUser({
user: "stats_user",
pwd: "@z^VFhN7q%vzit",
roles: [
{
role: 'statsReadWrite',
db: 'statistics',
},
],
});
db.createCollection("peertube");