feat: initial config, to be tested

This commit is contained in:
root committed 2026-07-30 15:38:12 +01:00
commit b754737879
5 files changed
+260

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# ===========================================
# MongoDB Configuration
# ===========================================
MONGO_ROOT_USER=admin
MONGO_ROOT_PASSWORD=change_this_admin_password
MONGO_DARKAN_USER=dkadmin
MONGO_DARKAN_PASSWORD=change_this_darkan_password
# ===========================================
# World Server Configuration
# ===========================================
WORLD_PORT=43596
WORLD_REPO=https://github.com/DarkanRS/world-server.git
# ===========================================
# Lobby Server Configuration
# ===========================================
LOBBY_REPO=https://github.com/DarkanRS/lobby-server.git
# ===========================================
# Cache Repository (shared)
# ===========================================
CACHE_REPO=https://github.com/DarkanRS/cache.git
+54
View File
@@ -0,0 +1,54 @@
# Build stage
FROM eclipse-temurin:17-jdk as builder
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
gradle \
&& rm -rf /var/lib/apt/lists/*
RUN git lfs install
# Clone repositories
ARG LOBBY_REPO=https://github.com/DarkanRS/lobby-server.git
ARG CACHE_REPO=https://github.com/DarkanRS/cache.git
RUN mkdir -p /darkan && cd /darkan \
&& git clone --depth 1 ${LOBBY_REPO} lobby-server \
&& git clone --depth 1 ${CACHE_REPO} cache
WORKDIR /darkan/lobby-server
# Build the project (adjust based on actual build command)
# Note: Replace with actual build command from the repository
RUN gradle build -x test || true
# Runtime stage
FROM eclipse-temurin:17-jre
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
&& rm -rf /var/lib/apt/lists/*
RUN git lfs install
# Copy built artifacts from builder
COPY --from=builder /darkan /darkan
WORKDIR /darkan/lobby-server
# Expose ports
EXPOSE 43594 43595 4040
# Set environment variables
ENV MONGO_URL=mongodb
ENV MONGO_PORT=27017
ENV MONGO_USER=dkadmin
ENV MONGO_PASSWORD=changeme
# Start command (adjust based on actual startup script)
# Replace with actual startup command from the repository
CMD ["./start.sh"]
+54
View File
@@ -0,0 +1,54 @@
# Build stage
FROM eclipse-temurin:17-jdk as builder
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
gradle \
&& rm -rf /var/lib/apt/lists/*
RUN git lfs install
# Clone repositories
ARG WORLD_REPO=https://github.com/DarkanRS/world-server.git
ARG CACHE_REPO=https://github.com/DarkanRS/cache.git
RUN mkdir -p /darkan && cd /darkan \
&& git clone --depth 1 ${WORLD_REPO} world-server \
&& git clone --depth 1 ${CACHE_REPO} cache
WORKDIR /darkan/world-server
# Build the project (adjust based on actual build command)
# Note: Replace with actual build command from the repository
RUN gradle build -x test || true
# Runtime stage
FROM eclipse-temurin:17-jre
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
&& rm -rf /var/lib/apt/lists/*
RUN git lfs install
# Copy built artifacts from builder
COPY --from=builder /darkan /darkan
WORKDIR /darkan/world-server
# Expose ports (will be configured via .env)
EXPOSE 43596 43597
# Set environment variables
ENV MONGO_URL=mongodb
ENV MONGO_PORT=27017
ENV MONGO_USER=dkadmin
ENV MONGO_PASSWORD=changeme
# Start command (adjust based on actual startup script)
# Replace with actual startup command from the repository
CMD ["./start.sh"]
+77
View File
@@ -0,0 +1,77 @@
version: '3.8'
services:
mongodb:
image: mongo:5.0
container_name: darkan-mongodb
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
volumes:
- mongodb_data:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
ports:
- "27017:27017"
networks:
- darkan-net
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet | grep 1
interval: 30s
timeout: 10s
retries: 5
world:
build:
context: .
dockerfile: Dockerfile.world
container_name: darkan-world
restart: unless-stopped
environment:
WORLD_PORT: ${WORLD_PORT}
MONGO_URL: mongodb
MONGO_PORT: 27017
MONGO_USER: ${MONGO_DARKAN_USER}
MONGO_PASSWORD: ${MONGO_DARKAN_PASSWORD}
depends_on:
mongodb:
condition: service_healthy
ports:
- "${WORLD_PORT}:${WORLD_PORT}"
- "${WORLD_PORT_NEXT}:${WORLD_PORT_NEXT}"
volumes:
- world_data:/darkan
networks:
- darkan-net
lobby:
build:
context: .
dockerfile: Dockerfile.lobby
container_name: darkan-lobby
restart: unless-stopped
environment:
MONGO_URL: mongodb
MONGO_PORT: 27017
MONGO_USER: ${MONGO_DARKAN_USER}
MONGO_PASSWORD: ${MONGO_DARKAN_PASSWORD}
depends_on:
mongodb:
condition: service_healthy
ports:
- "43594:43594"
- "43595:43595"
- "4040:4040"
volumes:
- lobby_data:/darkan
networks:
- darkan-net
volumes:
mongodb_data:
world_data:
lobby_data:
networks:
darkan-net:
driver: bridge
+52
View File
@@ -0,0 +1,52 @@
// MongoDB initialization script
// Creates admin user and darkan-server database with user
print('Starting MongoDB initialization...');
// Get credentials from environment
def getEnv(name, defaultValue) {
const value = cat('/proc/1/environ').split('\x00').find(v => v.startsWith(name + '='));
return value ? value.split('=')[1] : defaultValue;
}
const rootUser = getEnv('MONGO_INITDB_ROOT_USERNAME', 'admin');
const rootPassword = getEnv('MONGO_INITDB_ROOT_PASSWORD', 'admin');
const darkanUser = getEnv('MONGO_DARKAN_USER', 'dkadmin');
const darkanPassword = getEnv('MONGO_DARKAN_PASSWORD', 'dkadmin');
// Connect to admin database
const adminDb = db.getSiblingDB('admin');
// Create root admin user
try {
adminDb.createUser({
user: rootUser,
pwd: rootPassword,
roles: ['root']
});
print(`Created root user: ${rootUser}`);
} catch (e) {
print(`Root user already exists or error: ${e}`);
}
// Authenticate as root user
adminDb.auth(rootUser, rootPassword);
// Create darkan-server database
const darkanDb = db.getSiblingDB('darkan-server');
// Create collection
darkanDb.createCollection('darkan-server');
// Create darkan user with appropriate roles
darkanDb.createUser({
user: darkanUser,
pwd: darkanPassword,
roles: [
{ role: 'dbOwner', db: 'darkan-server' },
{ role: 'readWrite', db: 'darkan-server' }
]
});
print(`Created darkan user: ${darkanUser}`);
print('MongoDB initialization complete!');