部署
1.编写配置文件
vim docker-compose.yml
内容如下
version: "3.7"# networks
networks:proxy:driver: bridgeipam:driver: defaultconfig:- subnet: 172.20.0.0/24api-db: nullredis: nullmesh-db: null# docker managed persistent volumes
volumes:tactical_data: nullpostgres_data: nullmongo_data: nullmesh_data: nullredis_data: nullservices:# postgres database for api servicetactical-postgres:container_name: trmm-postgresimage: postgres:13-alpinerestart: alwaysenvironment:POSTGRES_DB: tacticalrmmPOSTGRES_USER: ${POSTGRES_USER}POSTGRES_PASSWORD: ${POSTGRES_PASS}volumes:- postgres_data:/var/lib/postgresql/datanetworks:- api-db# redis container for celery taskstactical-redis:container_name: trmm-redisimage: redis:6.0-alpineuser: 1000:1000command: redis-serverrestart: alwaysvolumes:- redis_data:/datanetworks:- redis# used to initialize the docker environmenttactical-init:container_name: trmm-initimage: ${IMAGE_REPO}tactical:${VERSION}restart: on-failurecommand: ["tactical-init"]environment:POSTGRES_USER: ${POSTGRES_USER}POSTGRES_PASS: ${POSTGRES_PASS}APP_HOST: ${APP_HOST}API_HOST: ${API_HOST}MESH_USER: ${MESH_USER}MESH_HOST: ${MESH_HOST}TRMM_USER: ${TRMM_USER}TRMM_PASS: ${TRMM_PASS}depends_on:- tactical-postgres- tactical-meshcentral- tactical-redisnetworks:- api-db- proxy- redisvolumes:- tactical_data:/opt/tactical- mesh_data:/meshcentral-data- mongo_data:/mongo/data/db- redis_data:/redis/data# natstactical-nats:container_name: trmm-natsimage: ${IMAGE_REPO}tactical-nats:${VERSION}user: 1000:1000restart: alwaysenvironment:API_HOST: ${API_HOST}volumes:- tactical_data:/opt/tacticalnetworks:api-db: nullproxy:aliases:- ${API_HOST}# meshcentral containertactical-meshcentral:container_name: trmm-meshcentralimage: ${IMAGE_REPO}tactical-meshcentral:${VERSION}user: 1000:1000restart: alwaysenvironment:MESH_HOST: ${MESH_HOST}MESH_USER: ${MESH_USER}MESH_PASS: ${MESH_PASS}MONGODB_USER: ${MONGODB_USER}MONGODB_PASSWORD: ${MONGODB_PASSWORD}MESH_PERSISTENT_CONFIG: ${MESH_PERSISTENT_CONFIG}networks:proxy:aliases:- ${MESH_HOST}mesh-db: nullvolumes:- tactical_data:/opt/tactical- mesh_data:/home/node/app/meshcentral-datadepends_on:- tactical-mongodb# mongodb container for meshcentraltactical-mongodb:container_name: trmm-mongodbimage: mongo:4.4user: 1000:1000restart: alwaysenvironment:MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}MONGO_INITDB_DATABASE: meshcentralnetworks:- mesh-dbvolumes:- mongo_data:/data/db# container that hosts vue frontendtactical-frontend:container_name: trmm-frontendimage: ${IMAGE_REPO}tactical-frontend:${VERSION}user: 1000:1000restart: alwaysnetworks:- proxyvolumes:- tactical_data:/opt/tacticalenvironment:API_HOST: ${API_HOST}# container for django backendtactical-backend:container_name: trmm-backendimage: ${IMAGE_REPO}tactical:${VERSION}user: 1000:1000command: ["tactical-backend"]restart: alwaysnetworks:- proxy- api-db- redisvolumes:- tactical_data:/opt/tacticaldepends_on:- tactical-postgres# container for django websockets connectionstactical-websockets:container_name: trmm-websocketsimage: ${IMAGE_REPO}tactical:${VERSION}user: 1000:1000command: ["tactical-websockets"]restart: alwaysnetworks:- proxy- api-db- redisvolumes:- tactical_data:/opt/tacticaldepends_on:- tactical-postgres- tactical-backend# container for tactical reverse proxytactical-nginx:container_name: trmm-nginximage: ${IMAGE_REPO}tactical-nginx:${VERSION}user: 1000:1000restart: alwaysenvironment:APP_HOST: ${APP_HOST}API_HOST: ${API_HOST}MESH_HOST: ${MESH_HOST}CERT_PUB_KEY: ${CERT_PUB_KEY}CERT_PRIV_KEY: ${CERT_PRIV_KEY}networks:proxy:ipv4_address: 172.20.0.20ports:- "${TRMM_HTTP_PORT-80}:8080"- "${TRMM_HTTPS_PORT-443}:4443"volumes:- tactical_data:/opt/tactical# container for celery worker servicetactical-celery:container_name: trmm-celeryimage: ${IMAGE_REPO}tactical:${VERSION}user: 1000:1000command: ["tactical-celery"]restart: alwaysnetworks:- redis- proxy- api-dbvolumes:- tactical_data:/opt/tacticaldepends_on:- tactical-postgres- tactical-redis# container for celery beat servicetactical-celerybeat:container_name: trmm-celerybeatimage: ${IMAGE_REPO}tactical:${VERSION}user: 1000:1000command: ["tactical-celerybeat"]restart: alwaysnetworks:- proxy- redis- api-dbvolumes:- tactical_data:/opt/tacticaldepends_on:- tactical-postgres- tactical-redis
2.环境参数
vim .env
内容如下
IMAGE_REPO=tacticalrmm/
VERSION=latest# tactical credentials (Used to login to dashboard)
TRMM_USER=tactical
TRMM_PASS=tactical# optional web port override settings
TRMM_HTTP_PORT=80
TRMM_HTTPS_PORT=443# dns settings
APP_HOST=rmm.example.com
API_HOST=api.example.com
MESH_HOST=mesh.example.com# mesh settings
MESH_USER=tactical
MESH_PASS=tactical
MONGODB_USER=mongouser
MONGODB_PASSWORD=mongopass
MESH_PERSISTENT_CONFIG=0# database settings
POSTGRES_USER=postgres
POSTGRES_PASS=postgrespass
3.配置hosts
增加如下内容
192.168.168.110 rmm.example.com
192.168.168.110 api.example.com
192.168.168.110 mesh.example.com
4.启动
docker compose up -d