一、背景
作为运维工程师,十几年的职业生涯感触良多。其中,运维人员是辛苦的,知识是广泛的,但心理上是有点苦苦的。大家需要交流,需要开阔视野,需要与这个时代共同进步。于是,有了这个论坛。
二、过程
(1)准备一个域名
lagua.op123.ren
(2)准备compose文件
部署在/opt/discourse目录
mkdir -p /opt/discourse/data
cd /opt/discourse/data
mkdir -p discourse_data postgresql_data redis_data sidekiq_data
chmod 777 *
docker-compose.yml文件
version: '2'
services:
postgresql:
container_name: postgresql
image: harbor.test.stesh.cn/bitnami/postgresql:11
volumes:
- './data/postgresql_data:/bitnami/postgresql'
environment:
- POSTGRESQL_POSTGRES_PASSWORD=admin12345
- POSTGRESQL_USERNAME=ex_discourse
- POSTGRESQL_PASSWORD=user12345
- POSTGRESQL_DATABASE=example_discourse
networks:
discourse-network:
ipv4_address: 192.168.80.51
redis:
container_name: redis
image: harbor.test.stesh.cn/bitnami/redis:6.0
environment:
- REDIS_PASSWORD=redis12345
volumes:
- './data/redis_data:/bitnami/redis'
networks:
discourse-network:
ipv4_address: 192.168.80.52
discourse:
container_name: discourse
image: harbor.test.stesh.cn/bitnami/discourse:2
ports:
- '127.0.0.1:880:3000'
volumes:
- './data/discourse_data:/bitnami/discourse'
depends_on:
- postgresql
- redis
environment:
# 用户和站点配置
- DISCOURSE_HOST=lagua.op123.ren
- DISCOURSE_USERNAME=admin
- DISCOURSE_PASSWORD=xxx
- DISCOURSE_EMAIL=wangyg@sddts.cn
# 数据库连接配置
- DISCOURSE_DATABASE_HOST=postgresql
- DISCOURSE_DATABASE_PORT_NUMBER=5432
- DISCOURSE_DATABASE_USER=ex_discourse
- DISCOURSE_DATABASE_PASSWORD=user12345
- DISCOURSE_DATABASE_NAME=example_discourse
# Redis 连接配置
- DISCOURSE_REDIS_HOST=redis
- DISCOURSE_REDIS_PORT_NUMBER=6379
- DISCOURSE_REDIS_PASSWORD=redis12345
# 使用 postgresql-client 为 Discourse 创建数据库
- POSTGRESQL_CLIENT_POSTGRES_USER=postgres
- POSTGRESQL_CLIENT_POSTGRES_PASSWORD=admin12345
- POSTGRESQL_CLIENT_CREATE_DATABASE_NAME=example_discourse
- POSTGRESQL_CLIENT_CREATE_DATABASE_EXTENSIONS=hstore,pg_trgm
# SMTP
- DISCOURSE_SMTP_HOST=smtp.feishu.cn
- DISCOURSE_SMTP_PORT=465
- DISCOURSE_SMTP_USER=wangyg@sddts.cn
- DISCOURSE_SMTP_PASSWORD=xxx
- DISCOURSE_SMTP_PROTOCOL=tls
- DISCOURSE_SMTP_AUTH=login
networks:
discourse-network:
ipv4_address: 192.168.80.31
sidekiq:
container_name: sidekiq
image: harbor.test.stesh.cn/bitnami/discourse:2
depends_on:
- discourse
volumes:
- './data/sidekiq_data:/bitnami/discourse'
command: /opt/bitnami/scripts/discourse-sidekiq/run.sh
environment:
# 用户和站点配置
- DISCOURSE_HOST=lagua.op123.ren
- DISCOURSE_USERNAME=admin
- DISCOURSE_PASSWORD=xxx
- DISCOURSE_EMAIL=wangyg@sddts.cn
# 数据库连接配置
- DISCOURSE_DATABASE_HOST=postgresql
- DISCOURSE_DATABASE_PORT_NUMBER=5432
- DISCOURSE_DATABASE_USER=ex_discourse
- DISCOURSE_DATABASE_PASSWORD=user12345
- DISCOURSE_DATABASE_NAME=example_discourse
# Redis 连接配置
- DISCOURSE_REDIS_HOST=redis
- DISCOURSE_REDIS_PORT_NUMBER=6379
- DISCOURSE_REDIS_PASSWORD=redis12345
# SMTP
- DISCOURSE_SMTP_HOST=smtp.feishu.cn
- DISCOURSE_SMTP_PORT=465
- DISCOURSE_SMTP_USER=wangyg@sddts.cn
- DISCOURSE_SMTP_PASSWORD=xxx
- DISCOURSE_SMTP_PROTOCOL=tls
- DISCOURSE_SMTP_AUTH=login
networks:
discourse-network:
ipv4_address: 192.168.80.32
networks:
discourse-network:
driver: bridge
ipam:
config:
- subnet: 192.168.80.0/24
(3)使用frpc将端口127.0.0.1:880打通到公网
# frpc.toml
serverAddr = "xxx"
serverPort = xxx
[[proxies]]
name = "discourse"
type = "tcp"
localIP = "127.0.0.1"
localPort = 880
remotePort = 7001
公网服务器反代
127.0.0.1:7001