1 Star 0 Fork 75

luoyong0189/huasenjio-compose

forked from 花森/huasenjio-compose 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
docker-compose.yml 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
花森 提交于 2023-02-11 14:32 . feat:重构docker-compose配置
# 版本号
version: "3"
# 自定义网络
networks:
# 网络名字
huasenNetwork:
# 网关驱动
driver: bridge
# 容器服务
services:
# 服务名称
mongo:
# 安装镜像
image: mongo:4.2.2
# 容器名称
container_name: mongo
privileged: true
volumes:
# /data/db数据目录挂载到宿主机
- ./huasen-mongo/volume:/data/db
# init-mongo.js文件会在mongodb容器初始化完成之后执行,给数据库创建默认的角色
- ./huasen-mongo/init-mongo-open.js:/docker-entrypoint-initdb.d/mongo-init.js
command: mongod --bind_ip 0.0.0.0
environment:
# 设置时区为上海(东八区)
TZ: Asia/Shanghai
# 初始化mongodb的账户,账户创建在admin下,拥有超管权限
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: Mongo12345*
MONGO_INITDB_DATABASE: admin
ports:
# 将容器的27017端口映射到宿主机的27017端口
- 37017:27017
networks:
# 设置网络
- huasenNetwork
redis:
image: redis:6.0.10-alpine
container_name: redis
privileged: true
environment:
- TZ=Asia/Shanghai
ports:
- 7379:6379
# 挂载配置文件和数据
volumes:
- ./huasen-redis/conf/redis-open.conf:/usr/local/etc/redis/redis.conf
- ./huasen-redis/data:/data:rw
# 执行配置
command: redis-server /usr/local/etc/redis/redis.conf
networks:
- huasenNetwork
nginx:
image: nginx:1.23.1
container_name: nginx
restart: always
volumes:
# 将容器中的nginx配置挂载到宿主机上对应的文件
- ./huasen-nginx/conf/nginx-open.conf:/etc/nginx/nginx.conf
- ./huasen-nginx/www:/home/www
- ./huasen-nginx/log:/var/log/nginx
- ./huasen-nginx/html:/usr/share/nginx/html
# 端口暴露
ports:
# - 80:80
- target: 80
published: 80
protocol: tcp
mode: host
environment:
- TZ=Asia/Shanghai
networks:
- huasenNetwork
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
privileged: true
user: root
volumes:
# 挂载目录到容器
- ./huasen-jenkins/:/var/jenkins_home
# 代理部署目录到容器
- ./:/huasen-compose
# 代理docker-compose到容器
- /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
# 代理docker到容器
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
ports:
- "8080:8080"
environment:
- TZ=Asia/Shanghai
networks:
- huasenNetwork
server:
# 指定Dockerflie构建镜像
build:
context: ./huasen-server
# 定义容器名称
container_name: server
privileged: true
user: root
# 代理日志文件
volumes:
- ./huasen-log/:/app/huasen-server/log
- ./huasen-store/:/app/huasen-store
ports:
- "3000:3000"
- "8181:8181"
environment:
- TZ=Asia/Shanghai
depends_on:
- mongo
- redis
networks:
- huasenNetwork
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/luoyong0189/huasenjio-compose.git
git@gitee.com:luoyong0189/huasenjio-compose.git
luoyong0189
huasenjio-compose
huasenjio-compose
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385