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

dockerfile & docker-compose

上级 688b6121
...@@ -120,9 +120,10 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇 ...@@ -120,9 +120,10 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
## Docker Compose ## Docker Compose
1. 进入 `docs/docker` 目录 1. 打包项目 `mvn clean package -Dmaven.test.skip=true -Pdev`
2. 按照注释修改 `.env` 文件 2. 进入 `docs/docker` 目录
3. 执行 `deploy.sh` 3. 按照注释修改 `.env` 文件
4. 执行 `docker-compose -p oneblog up -d`
# 后续扩展 # 后续扩展
......
...@@ -5,13 +5,13 @@ ONEBLOG_APP_DIR=D://var/.oneblog ...@@ -5,13 +5,13 @@ ONEBLOG_APP_DIR=D://var/.oneblog
# redis 配置 # redis 配置
ONEBLOG_REDIS_DATABASE_INDEX=1 ONEBLOG_REDIS_DATABASE_INDEX=1
ONEBLOG_REDIS_HOST=oneblog-redis ONEBLOG_REDIS_HOST=blog-redis
ONEBLOG_REDIS_PORT=6379 ONEBLOG_REDIS_PORT=6379
# 建议修改为复制密码 # 建议修改为复制密码
ONEBLOG_REDIS_PASSWORD=oneblog123456 ONEBLOG_REDIS_PASSWORD=oneblog123456
# mysql 配置 # mysql 配置
ONEBLOG_DATASOURCE_HOST=oneblog-mysql ONEBLOG_DATASOURCE_HOST=blog-mysql
ONEBLOG_DATASOURCE_PORT=3306 ONEBLOG_DATASOURCE_PORT=3306
ONEBLOG_DATASOURCE_DATABASE_NAME=dblog ONEBLOG_DATASOURCE_DATABASE_NAME=dblog
ONEBLOG_DATASOURCE_USERNAME=root ONEBLOG_DATASOURCE_USERNAME=root
......
mvn -X clean package -Dmaven.test.skip=true -Pdev
docker-compose -p oneblog up -d
version: '3.3' version: '3.3'
services: 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 # MySQL
oneblog-mysql: blog-mysql:
image: oneblog/mysql image: justauth/blog-mysql
build: ./mysql build: ./mysql
environment: environment:
MYSQL_ROOT_PASSWORD: ${ONEBLOG_DATASOURCE_PASSWORD} MYSQL_ROOT_PASSWORD: ${ONEBLOG_DATASOURCE_PASSWORD}
TZ: Asia/Shanghai TZ: Asia/Shanghai
restart: always restart: always
container_name: oneblog-mysql container_name: blog-mysql
hostname: oneblog-mysql hostname: blog-mysql
volumes: volumes:
- ${ONEBLOG_APP_DIR}/mysql:/var/lib/mysql - ${ONEBLOG_APP_DIR}/mysql:/var/lib/mysql
ports: ports:
...@@ -22,31 +41,13 @@ services: ...@@ -22,31 +41,13 @@ services:
networks: networks:
- oneblog - 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 服务 # admin 服务
oneblog-admin: blog-admin:
image: oneblog/blog-admin image: justauth/blog-admin
build: ../../blog-admin build: ../../blog-admin
restart: always restart: always
container_name: oneblog-admin container_name: blog-admin
hostname: oneblog-admin hostname: blog-admin
environment: environment:
ONEBLOG_REDIS_DATABASE_INDEX: ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST: ONEBLOG_REDIS_HOST:
...@@ -66,25 +67,25 @@ services: ...@@ -66,25 +67,25 @@ services:
volumes: volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog - ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on: depends_on:
oneblog-redis: blog-redis:
condition: service_healthy condition: service_healthy
oneblog-mysql: blog-mysql:
condition: service_healthy condition: service_healthy
links: links:
- oneblog-redis - blog-redis
- oneblog-mysql - blog-mysql
ports: ports:
- 8085:8085 - 8085:8085
networks: networks:
- oneblog - oneblog
# admin 服务 # admin 服务
oneblog-web: blog-web:
image: oneblog/blog-web image: justauth/blog-web
build: ../../blog-web build: ../../blog-web
restart: always restart: always
container_name: oneblog-web container_name: blog-web
hostname: oneblog-web hostname: blog-web
environment: environment:
ONEBLOG_REDIS_DATABASE_INDEX: ONEBLOG_REDIS_DATABASE_INDEX:
ONEBLOG_REDIS_HOST: ONEBLOG_REDIS_HOST:
...@@ -104,13 +105,13 @@ services: ...@@ -104,13 +105,13 @@ services:
volumes: volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog - ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on: depends_on:
oneblog-redis: blog-redis:
condition: service_healthy condition: service_healthy
oneblog-mysql: blog-mysql:
condition: service_healthy condition: service_healthy
links: links:
- oneblog-redis - blog-redis
- oneblog-mysql - blog-mysql
ports: ports:
- 8443:8443 - 8443:8443
networks: networks:
......
...@@ -9,6 +9,6 @@ ADD ./config/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf ...@@ -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 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.
先完成此消息的编辑!
想要评论请 注册