This guide provides a detailed walkthrough for deploying a MoonTV movie website using Docker Compose. The process involves setting up two main services: moontv-core
for the application itself and moontv-kvrocks
for the database, and linking them through a Docker network.
Step 1: Create the docker-compose.yml
File
The foundation of this deployment is the docker-compose.yml
file. This file defines the services, networks, and volumes required to run MoonTV.
The configuration consists of two primary services:
moontv-core
: The main application service using theghcr.io/moontechlab/lunatv:latest
image. It maps port8095
on the host to port3000
inside the container.moontv-kvrocks
: The database service, which uses theapache/kvrocks
image to store data. It uses a volume to persist data on the host machine.
Below is the complete docker-compose.yml
configuration (Updated 2025-10-14. The original ghcr.io/moontechlab/lunatv:latest will no longer be updated. For future updates, you can use ghcr.io/szemeng76/lunatv:latest as a replacement, or find other sources on your own.):
services:
moontv-core:
image: ghcr.io/moontechlab/lunatv:latest
container_name: moontv-core
restart: on-failure
ports:
- '8095:3000'
environment:
- USERNAME=用户名(管理员)
- PASSWORD=管理密码,不能太i暗淡
- NEXT_PUBLIC_STORAGE_TYPE=kvrocks
- KVROCKS_URL=redis://moontv-kvrocks:6666
- AUTH_TOKEN=ccd4edddc0789b370bda2abdadde3e06
networks:
- moontv-network
depends_on:
- moontv-kvrocks
moontv-kvrocks:
image: apache/kvrocks
container_name: moontv-kvrocks
restart: unless-stopped
volumes:
- /www/wwwroot/kvrocks-data:/var/lib/kvrocks
networks:
- moontv-network
networks:
moontv-network:
driver: bridge
volumes:
kvrocks-data:
Note on Environment Variables: Before deploying, you must change the USERNAME
and PASSWORD
to your desired administrator credentials. The password should be strong.
Step 2: Prepare the Host Environment
Before launching the containers, you need to create a directory for the kvrocks
persistent data and place a configuration file within it.
- Create the Data Directory and Set Permissions: You must create the
/www/wwwroot/kvrocks-data
directory on your host machine and ensure it has read and write permissions. - Create
kvrocks.conf
File: Inside the/www/wwwroot/kvrocks-data
directory, create a file namedkvrocks.conf
. This file is essential for the proper functioning of thekvrocks
database.
Copy the entire content below into your kvrocks.conf
file:
################################ GENERAL #####################################
bind 127.0.0.1
socket-fd -1
port 6666
timeout 0
workers 8
daemonize no
cluster-enabled no
repl-namespace-enabled no
persist-cluster-nodes-enabled yes
maxclients 10000
db-name change.me.db
dir /tmp/kvrocks
log-level info
log-retention-days -1
slave-read-only yes
slave-priority 100
replication-connect-timeout-ms 3100
replication-recv-timeout-ms 3200
tcp-backlog 511
master-use-repl-port no
use-rsid-psync no
slave-serve-stale-data yes
slave-empty-db-before-fullsync no
purge-backup-on-fullsync no
max-replication-mb 0
max-io-mb 0
enable-blob-cache no
max-db-size 0
max-backup-to-keep 1
max-backup-keep-hours 24
max-bitmap-to-string-mb 16
redis-cursor-compatible yes
json-max-nesting-depth 1024
json-storage-format json
txn-context-enabled no
################################# TLS ###################################
################################## SLOW LOG ###################################
slowlog-log-slower-than 100000
slowlog-max-len 128
slowlog-dump-logfile-level off
supervised no
################################# PERF LOG ###################################
profiling-sample-ratio 0
profiling-sample-record-max-len 256
profiling-sample-record-threshold-ms 100
################################# CRON ###################################
compaction-checker-cron * 0-7 * * *
################################ MIGRATE #####################################
migrate-type raw-key-value
migrate-speed 4096
migrate-pipeline-size 16
migrate-sequence-gap 10000
migrate-batch-size-kb 16
migrate-batch-rate-limit-mb 16
################################ ROCKSDB #####################################
rocksdb.block_cache_size 4096
rocksdb.block_cache_type lru
rocksdb.max_open_files 8096
rocksdb.write_buffer_size 64
rocksdb.target_file_size_base 128
rocksdb.max_write_buffer_number 4
rocksdb.min_write_buffer_number_to_merge 1
rocksdb.max_background_jobs 4
rocksdb.max_background_compactions -1
rocksdb.max_background_flushes -1
rocksdb.max_subcompactions 2
rocksdb.wal_compression no
rocksdb.max_total_wal_size 512
rocksdb.dump_malloc_stats yes
rocksdb.wal_ttl_seconds 10800
rocksdb.wal_size_limit_mb 16384
rocksdb.block_size 16384
rocksdb.cache_index_and_filter_blocks yes
rocksdb.compression snappy
rocksdb.compression_level 32767
rocksdb.compaction_readahead_size 2097152
rocksdb.compression_start_level 2
rocksdb.delayed_write_rate 0
rocksdb.enable_pipelined_write no
rocksdb.level0_slowdown_writes_trigger 20
rocksdb.level0_stop_writes_trigger 40
rocksdb.level0_file_num_compaction_trigger 4
rocksdb.stats_dump_period_sec 0
rocksdb.disable_auto_compactions no
rocksdb.enable_blob_files no
rocksdb.min_blob_size 4096
rocksdb.blob_file_size 268435456
rocksdb.enable_blob_garbage_collection yes
rocksdb.blob_garbage_collection_age_cutoff 25
rocksdb.level_compaction_dynamic_level_bytes yes
rocksdb.max_bytes_for_level_base 268435456
rocksdb.max_bytes_for_level_multiplier 10
rocksdb.read_options.async_io yes
rocksdb.write_options.sync no
rocksdb.write_options.disable_wal no
rocksdb.write_options.no_slowdown no
rocksdb.write_options.low_pri no
rocksdb.write_options.memtable_insert_hint_per_batch no
rocksdb.rate_limiter_auto_tuned yes
rocksdb.partition_filters yes
rocksdb.max_compaction_bytes 0
rocksdb.sst_file_delete_rate_bytes_per_sec 0
################################ NAMESPACE #####################################
namespace.test change.me
Step 3: Launch the MoonTV Application
With the configuration files in place, you can now launch the application.
-
Pull the Docker Images: Navigate to the directory containing your
docker-compose.yml
file and run the following command to download the necessary images.docker-compose pull
-
Start the Services: Once the images are pulled, start the services in detached mode.
docker-compose up -d
After running this command, Docker will create and start the moontv-core
and moontv-kvrocks
containers. You can now access your MoonTV instance by navigating to http://<your-server-ip>:8095
in your web browser.
Comments