Initial push
This commit is contained in:
45
docker/Dockerfile
Normal file
45
docker/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
# ─── Stage 1: Build ──────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1.3-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies first (cache layer)
|
||||
COPY package.json bun.lock* ./
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build Next.js
|
||||
RUN bun run build
|
||||
|
||||
# ─── Stage 2: Production image ────────────────────────────────────────────────
|
||||
FROM oven/bun:1.3-alpine AS runner
|
||||
|
||||
# Security: run as non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Copy built output
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Copy server entrypoint
|
||||
COPY --from=builder /app/server.ts ./server.ts
|
||||
|
||||
# Create data directory with correct permissions
|
||||
RUN mkdir -p /app/data /app/backups && chown -R nextjs:nodejs /app/data /app/backups
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD wget -qO- http://localhost:3000/api/health || exit 1
|
||||
|
||||
CMD ["bun", "--bun", "run", "server.ts"]
|
||||
36
docker/docker-compose.dev.yml
Normal file
36
docker/docker-compose.dev.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
################################################################################
|
||||
# CubeAdmin — Development Docker Compose
|
||||
#
|
||||
# Usage: docker compose -f docker/docker-compose.dev.yml up
|
||||
#
|
||||
# This starts only the Minecraft server + optional BlueMap for development.
|
||||
# The CubeAdmin panel runs on your host machine with `bun run dev`.
|
||||
################################################################################
|
||||
|
||||
services:
|
||||
minecraft:
|
||||
image: itzg/minecraft-server:latest
|
||||
container_name: minecraft_dev
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
stdin_open: true
|
||||
ports:
|
||||
- "25565:25565"
|
||||
- "25575:25575" # Expose RCON for local development
|
||||
environment:
|
||||
- TYPE=${MC_TYPE:-PAPER}
|
||||
- VERSION=${MC_VERSION:-LATEST}
|
||||
- EULA=TRUE
|
||||
- MEMORY=2G
|
||||
- ENABLE_RCON=true
|
||||
- RCON_PORT=25575
|
||||
- RCON_PASSWORD=${MC_RCON_PASSWORD:-devrcon123}
|
||||
- USE_AIKAR_FLAGS=true
|
||||
volumes:
|
||||
- ./mc-data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "mc-health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 120s
|
||||
129
docker/docker-compose.yml
Normal file
129
docker/docker-compose.yml
Normal file
@@ -0,0 +1,129 @@
|
||||
################################################################################
|
||||
# CubeAdmin — Docker Compose
|
||||
#
|
||||
# Usage:
|
||||
# 1. Copy .env.example to .env and fill in your values
|
||||
# 2. docker compose up -d
|
||||
#
|
||||
# Services:
|
||||
# - cubeadmin : The admin panel (Next.js + Bun)
|
||||
# - minecraft : Minecraft server (optional — disable if you manage your own)
|
||||
# - bluemap : BlueMap 3D map (optional)
|
||||
#
|
||||
################################################################################
|
||||
|
||||
services:
|
||||
# ─── CubeAdmin panel ─────────────────────────────────────────────────────
|
||||
cubeadmin:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
container_name: cubeadmin
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${PORT:-3000}:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:?BETTER_AUTH_SECRET is required}
|
||||
- BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}
|
||||
- RESEND_API_KEY=${RESEND_API_KEY:-}
|
||||
- EMAIL_FROM=${EMAIL_FROM:-CubeAdmin <noreply@example.com>}
|
||||
- MC_SERVER_PATH=/mc-server
|
||||
- MC_RCON_HOST=minecraft
|
||||
- MC_RCON_PORT=${MC_RCON_PORT:-25575}
|
||||
- MC_RCON_PASSWORD=${MC_RCON_PASSWORD:?MC_RCON_PASSWORD is required}
|
||||
- BLUEMAP_URL=${BLUEMAP_URL:-}
|
||||
- DATABASE_PATH=/app/data/cubeadmin.db
|
||||
- BACKUPS_PATH=/app/backups
|
||||
- TRUSTED_ORIGINS=${TRUSTED_ORIGINS:-http://localhost:3000}
|
||||
- INITIAL_ADMIN_EMAIL=${INITIAL_ADMIN_EMAIL:-admin@example.com}
|
||||
- INITIAL_ADMIN_NAME=${INITIAL_ADMIN_NAME:-Administrator}
|
||||
- INITIAL_ADMIN_PASSWORD=${INITIAL_ADMIN_PASSWORD:-ChangeMe123!}
|
||||
volumes:
|
||||
# Persistent database
|
||||
- cubeadmin_data:/app/data
|
||||
# Persistent backups
|
||||
- ${BACKUPS_PATH:-./backups}:/app/backups
|
||||
# Mount Minecraft server directory (read-write for file management)
|
||||
- ${MC_DATA_PATH:-./mc-data}:/mc-server
|
||||
networks:
|
||||
- cubeadmin_net
|
||||
depends_on:
|
||||
minecraft:
|
||||
condition: service_healthy
|
||||
required: false
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
# ─── Minecraft Server (Paper MC) ─────────────────────────────────────────
|
||||
# Remove or comment out this service if you manage your Minecraft server separately
|
||||
minecraft:
|
||||
image: itzg/minecraft-server:latest
|
||||
container_name: minecraft
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
stdin_open: true
|
||||
ports:
|
||||
- "${MC_PORT:-25565}:25565"
|
||||
# Uncomment to expose RCON port externally (not recommended for security)
|
||||
# - "25575:25575"
|
||||
environment:
|
||||
# Server type: VANILLA, PAPER, SPIGOT, FORGE, FABRIC, BUKKIT, BEDROCK
|
||||
- TYPE=${MC_TYPE:-PAPER}
|
||||
- VERSION=${MC_VERSION:-LATEST}
|
||||
- EULA=TRUE
|
||||
- MEMORY=${MC_MEMORY:-2G}
|
||||
- MAX_PLAYERS=${MC_MAX_PLAYERS:-20}
|
||||
- MOTD=${MC_MOTD:-Powered by CubeAdmin}
|
||||
# RCON (required for CubeAdmin command execution)
|
||||
- ENABLE_RCON=true
|
||||
- RCON_PORT=25575
|
||||
- RCON_PASSWORD=${MC_RCON_PASSWORD:?MC_RCON_PASSWORD is required}
|
||||
# Performance
|
||||
- USE_AIKAR_FLAGS=true
|
||||
- VIEW_DISTANCE=10
|
||||
- SIMULATION_DISTANCE=8
|
||||
# Ops
|
||||
- OPS=${MC_OPS:-}
|
||||
- WHITELIST=${MC_WHITELIST:-}
|
||||
- ENABLE_WHITELIST=false
|
||||
volumes:
|
||||
- ${MC_DATA_PATH:-./mc-data}:/data
|
||||
networks:
|
||||
- cubeadmin_net
|
||||
healthcheck:
|
||||
test: ["CMD", "mc-health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 120s
|
||||
|
||||
# ─── BlueMap (optional 3D map) ───────────────────────────────────────────
|
||||
# BlueMap is usually run as a plugin inside the MC server.
|
||||
# This service provides a standalone BlueMap web viewer.
|
||||
# Configure BLUEMAP_URL=http://localhost:8100 in your .env
|
||||
#
|
||||
# bluemap:
|
||||
# image: nginx:alpine
|
||||
# container_name: bluemap
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - "8100:80"
|
||||
# volumes:
|
||||
# - ${MC_DATA_PATH:-./mc-data}/plugins/BlueMap/web:/usr/share/nginx/html:ro
|
||||
# networks:
|
||||
# - cubeadmin_net
|
||||
|
||||
volumes:
|
||||
cubeadmin_data:
|
||||
name: cubeadmin_data
|
||||
|
||||
networks:
|
||||
cubeadmin_net:
|
||||
name: cubeadmin_net
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user