提交 868c5c03 编写于 作者: 智布道's avatar 智布道 👁

dockerfile & docker-compose

上级 688b6121
......@@ -120,9 +120,10 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
## Docker Compose
1. 进入 `docs/docker` 目录
2. 按照注释修改 `.env` 文件
3. 执行 `deploy.sh`
1. 打包项目 `mvn clean package -Dmaven.test.skip=true -Pdev`
2. 进入 `docs/docker` 目录
3. 按照注释修改 `.env` 文件
4. 执行 `docker-compose -p oneblog up -d`
# 后续扩展
......
......@@ -5,13 +5,13 @@ ONEBLOG_APP_DIR=D://var/.oneblog
# redis 配置
ONEBLOG_REDIS_DATABASE_INDEX=1
ONEBLOG_REDIS_HOST=oneblog-redis
ONEBLOG_REDIS_HOST=blog-redis
ONEBLOG_REDIS_PORT=6379
# 建议修改为复制密码
ONEBLOG_REDIS_PASSWORD=oneblog123456
# mysql 配置
ONEBLOG_DATASOURCE_HOST=oneblog-mysql
ONEBLOG_DATASOURCE_HOST=blog-mysql
ONEBLOG_DATASOURCE_PORT=3306
ONEBLOG_DATASOURCE_DATABASE_NAME=dblog
ONEBLOG_DATASOURCE_USERNAME=root
......
mvn -X clean package -Dmaven.test.skip=true -Pdev
docker-compose -p oneblog up -d
version: '3.3'
services:
# Redis
blog-redis:
image: redis
restart: always
container_name: blog-redis
hostname: blog-redis
command: redis-server --appendonly yes --requirepass ${ONEBLOG_REDIS_PASSWORD} --bind blog-redis
ports:
- 63799:6379
volumes:
- ${ONEBLOG_APP_DIR}/redis/:/data/
healthcheck:
test: [ "CMD", "redis-cli" ]
timeout: 20s
retries: 10
networks:
- oneblog
# MySQL
oneblog-mysql:
image: oneblog/mysql
blog-mysql:
image: justauth/blog-mysql
build: ./mysql
environment:
MYSQL_ROOT_PASSWORD: ${ONEBLOG_DATASOURCE_PASSWORD}
TZ: Asia/Shanghai
restart: always
container_name: oneblog-mysql
hostname: oneblog-mysql
container_name: blog-mysql
hostname: blog-mysql
volumes:
- ${ONEBLOG_APP_DIR}/mysql:/var/lib/mysql
ports:
......@@ -22,31 +41,13 @@ services:
networks:
- oneblog
# Redis
oneblog-redis:
image: redis
restart: always
container_name: oneblog-redis
hostname: oneblog-redis
command: redis-server --appendonly yes --requirepass ${ONEBLOG_REDIS_PASSWORD} --bind oneblog-redis
ports:
- 63799:6379
volumes:
- ${ONEBLOG_APP_DIR}/redis/:/data/
healthcheck:
test: [ "CMD", "redis-cli" ]
timeout: 20s
retries: 10
networks:
- oneblog
# admin 服务
oneblog-admin:
image: oneblog/blog-admin
blog-admin:
image: justauth/blog-admin
build: ../../blog-admin
restart: always
container_name: oneblog-admin
hostname: oneblog-admin
container_name: blog-admin
hostname: blog-admin
environment:
ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST:
......@@ -66,25 +67,25 @@ services:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
oneblog-redis:
blog-redis:
condition: service_healthy
oneblog-mysql:
blog-mysql:
condition: service_healthy
links:
- oneblog-redis
- oneblog-mysql
- blog-redis
- blog-mysql
ports:
- 8085:8085
networks:
- oneblog
# admin 服务
oneblog-web:
image: oneblog/blog-web
blog-web:
image: justauth/blog-web
build: ../../blog-web
restart: always
container_name: oneblog-web
hostname: oneblog-web
container_name: blog-web
hostname: blog-web
environment:
ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST:
......@@ -104,13 +105,13 @@ services:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
oneblog-redis:
blog-redis:
condition: service_healthy
oneblog-mysql:
blog-mysql:
condition: service_healthy
links:
- oneblog-redis
- oneblog-mysql
- blog-redis
- blog-mysql
ports:
- 8443:8443
networks:
......
......@@ -9,6 +9,6 @@ ADD ./config/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY ../../db/dblog.sql /docker-entrypoint-initdb.d
COPY ./dblog.sql /docker-entrypoint-initdb.d
COPY ../../db/init_data.sql /docker-entrypoint-initdb.d
COPY ./init_data.sql /docker-entrypoint-initdb.d
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册