updated mongo express

This commit is contained in:
Berkay 2025-04-29 14:40:05 +03:00
parent d1234e37ac
commit 2fe676da63
3 changed files with 66 additions and 9 deletions

4
.env
View File

@ -1,7 +1,7 @@
# MongoDB credentials
MONGO_ROOT_USERNAME=admin
MONGO_ROOT_PASSWORD=change_this_password
MONGO_ROOT_PASSWORD=password
# Mongo Express credentials
MONGOEXPRESS_USERNAME=mexpress
MONGOEXPRESS_PASSWORD=change_this_password_too
MONGOEXPRESS_PASSWORD=password

54
config.js Normal file
View File

@ -0,0 +1,54 @@
'use strict';
// Custom Mongo Express configuration
// This file MUST be mounted at /node_modules/mongo-express/config.js
module.exports = {
mongodb: {
// Connection string for MongoDB
connectionString: process.env.ME_CONFIG_MONGODB_URL || 'mongodb://admin:password@mongodb:27017/admin',
// MongoDB server options
admin: true,
// MongoDB authentication options
adminUsername: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || 'admin',
adminPassword: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || 'password',
// Auth database name
auth: [
{
database: process.env.ME_CONFIG_MONGODB_AUTH_DATABASE || 'admin',
username: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || 'admin',
password: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || 'password',
}
]
},
// Web server options
site: {
// Base URL path
baseUrl: '/',
// Web server port
port: process.env.ME_CONFIG_SITE_PORT || 8081,
// Web server host
host: '0.0.0.0'
},
// Options for basic authentication
basicAuth: {
// Use environment variables for basic authentication
username: process.env.ME_CONFIG_BASICAUTH_USERNAME || 'mexpress',
password: process.env.ME_CONFIG_BASICAUTH_PASSWORD || 'password'
},
// Other options
options: {
// Enable editing
editMode: true,
// Enable admin mode
adminMode: true
}
};

View File

@ -15,7 +15,8 @@ services:
ports:
- "27017:27017" # Expose MongoDB port to external machines
# Use a simpler configuration without replica set for now
command: ["--auth", "--bind_ip_all"]
command:
["--auth", "--bind_ip_all", "--logpath", "/proc/1/fd/1", "--logappend"]
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/admin -u ${MONGO_ROOT_USERNAME:-admin} -p ${MONGO_ROOT_PASSWORD:-password} --quiet
interval: 10s
@ -40,7 +41,7 @@ services:
hostname: mongo-express
restart: always
volumes:
- ./mongo-express-config.js:/node_modules/mongo-express/config.js:ro
- ./config.js:/node_modules/mongo-express/config.js:ro
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_ROOT_USERNAME:-admin}
- ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_ROOT_PASSWORD:-password}
@ -49,12 +50,14 @@ services:
# Fix connection string format
- ME_CONFIG_MONGODB_URL=mongodb://${MONGO_ROOT_USERNAME:-admin}:${MONGO_ROOT_PASSWORD:-password}@mongodb:27017/?authSource=admin
# Explicitly disable basic auth
- ME_CONFIG_BASICAUTH_USERNAME=
- ME_CONFIG_BASICAUTH_PASSWORD=
- ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_USERNAME:-mexpress}
- ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD:-password}
ports:
- "8081:8081" # Expose Mongo Express web interface to external machines
- "8001:8081" # Expose Mongo Express web interface to external machines
depends_on:
- mongodb
mongodb:
condition: service_healthy
networks:
- mongo_network
logging: