在windows上首先下载DeskTop Docker,安装好后,设置windows Hyper-V,参考我的其他文章,有详细介绍。同时确保宿主机安装好了node和npm环境,下载dnmp环境,
$ git clone https://github.com/shmilylbelva/dnmp.git //建议使用https://github.com/yeszao/dnmp版本,功能更强大
$ cd dnmp
$ docker-compose up
cmd切换到dnmp/www/下,这里的dnmp我是放在d盘的docker目录下的D:\docker\dnmp\www
,执行
git clone https://github.com/kanyxmo/MineAdmin.git mineAdmin
cd mineAdmin
git clone https://github.com/kanyxmo/MineAdmin-Vue.git web
我们不使用mineadmin自带的docker-compose文件,切换到dnmp下,修改docker-compose.yml如下
version: "3"
services:
nginx:
build:
context: ./services/nginx
args:
NGINX_VERSION: nginx:${NGINX_VERSION}
CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
NGINX_INSTALL_APPS: ${NGINX_INSTALL_APPS}
container_name: nginx
ports:
- "${NGINX_HTTP_HOST_PORT}:80"
- "${NGINX_HTTPS_HOST_PORT}:443"
volumes:
- ${SOURCE_DIR}:/www/:rw
- ${NGINX_SSL_CERTIFICATE_DIR}:/ssl:rw
- ${NGINX_CONFD_DIR}:/etc/nginx/conf.d/:rw
- ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf:ro
- ${NGINX_FASTCGI_PHP_CONF}:/etc/nginx/fastcgi-php.conf:ro
- ${NGINX_FASTCGI_PARAMS}:/etc/nginx/fastcgi_params:ro
- ${NGINX_LOG_DIR}:/var/log/nginx/:rw
environment:
TZ: "$TZ"
restart: always
networks:
- default
# 可以把-default 改成下列配置,以固定容器IP
#default:
# ipv4_address: 10.0.0.10
php81:
build:
context: ./services/php81
args:
PHP_VERSION: php:${PHP81_VERSION}-fpm-alpine3.16
CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
PHP_EXTENSIONS: ${PHP81_EXTENSIONS}
TZ: "$TZ"
container_name: php81
ports:
- "9507:9507"
- "9508:9508"
expose:
- 9507
- 9508
extra_hosts:
- "www.hadmin3.dev:172.18.0.1"
volumes:
- ${SOURCE_DIR}:/www/:rw
- ${PHP81_PHP_CONF_FILE}:/usr/local/etc/php/php.ini:ro
- ${PHP81_FPM_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf:rw
- ${PHP81_LOG_DIR}:/var/log/php
- ${DATA_DIR}/composer:/tmp/composer
restart: always
cap_add:
- SYS_PTRACE
networks:
- default
# mineadmin的.env的mysql、redis如果连接到宿主机,地址用:host.docker.internal
# 如果是连接到docker内服务,则用服务名称,如:redis
hyperf:
image: ixmo/mine-admin:latest
restart: always
environment:
- "TIMEZONE=Asia/Shanghai"
- "APP_PROJECT=hyperf"
- "APP_SYSTEM_ENV=docker"
working_dir: "/www/mineadmin/"
ports:
- 9501:9501
- 9502:9502
- 9503:9503
volumes:
- ${SOURCE_DIR}:/www/:rw
entrypoint: ["php","watch", "-c"]
mysql:
image: mysql:${MYSQL_VERSION}
container_name: mysql
ports:
- "${MYSQL_HOST_PORT}:3306"
volumes:
- ${MYSQL_CONF_FILE}:/etc/mysql/conf.d/mysql.cnf:ro
# - ${MYSQL_CNF}:/etc/mysql/my.cnf:ro
- ${DATA_DIR}/mysql:/var/lib/mysql/:rw
- ${MYSQL_LOG_DIR}:/var/log/mysql/:rw
restart: always
networks:
- default
environment:
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_ROOT_HOST: "${MYSQL_ROOT_HOST}"
TZ: "$TZ"
# mysql5:
# image: mysql/mysql-server:${MYSQL5_VERSION}
# container_name: mysql5
# ports:
# - "${MYSQL5_HOST_PORT}:3306"
# volumes:
# - ${MYSQL5_CONF_FILE}:/etc/mysql/conf.d/mysql.cnf:ro
# - ${DATA_DIR}/mysql5:/var/lib/mysql/:rw
# - ${MYSQL5_LOG_DIR}:/var/log/mysql/:rw
# restart: always
# networks:
# - default
# environment:
# MYSQL_ROOT_PASSWORD: "${MYSQL5_ROOT_PASSWORD}"
# MYSQL_ROOT_HOST: "${MYSQL5_ROOT_HOST}"
# TZ: "$TZ"
redis:
image: redis:${REDIS_VERSION}
container_name: redis
ports:
- "${REDIS_HOST_PORT}:6379"
volumes:
- ${REDIS_CONF_FILE}:/etc/redis.conf:ro
- ${DATA_DIR}/redis:/data/:rw
restart: always
entrypoint: ["redis-server", "/etc/redis.conf"]
environment:
TZ: "$TZ"
networks:
- default
rabbitmq:
build:
context: ./services/rabbitmq
args:
RABBITMQ_VERSION: ${RABBITMQ_VERSION}
RABBITMQ_PLUGINS: ${RABBITMQ_PLUGINS}
container_name: rabbitmq
restart: always
ports:
- "${RABBITMQ_HOST_PORT_C}:5672"
- "${RABBITMQ_HOST_PORT_S}:15672"
environment:
TZ: "$TZ"
RABBITMQ_DEFAULT_USER: "${RABBITMQ_DEFAULT_USER}"
RABBITMQ_DEFAULT_PASS: "${RABBITMQ_DEFAULT_PASS}"
networks:
- default
# node:
# image: node:${NODE_VERSION}
# environment:
# - NODE_ENV=production
# volumes:
# - ${SOURCE_DIR}:/www/:rw
# expose:
# - "8081"
# networks:
# - default
# stdin_open: true
# tty: true
networks:
default:
driver: bridge
ipam:
driver: default
# 解除下面的注释可以设置网段,用于nginx等容器固定容器IP
#config:
# - subnet: 10.0.0.0/24
cmd下执行compose-compose up -d进行镜像安装(nginx、php8.1、mysql8.0、rabbitmq、hyperf、redis)
安装完了之后如图
通过desktop进入hyperf-1容器执行如下命令,注意mysql和redis配置,设置mysql主机地址为mysql,账号root,密码123456,redis主机地址为redis,密码为空
composer install -vvv
php bin/hyperf.php mine:install(配置.env)
再次执行
php bin/hyperf.php mine:install(安装数据)
php watch -c //启动热更新
在宿主机cmd下进入到web目录执行
npm install
npm run dev
执行完后如图