Skip to content

Commit

Permalink
move docker-composer to directory,add a .env file (#253)
Browse files Browse the repository at this point in the history
Co-authored-by: faizel <[email protected]>
  • Loading branch information
faizel-88 and FaiZell authored May 11, 2024
1 parent ef4e2b5 commit 2c4dfab
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 60 deletions.
60 changes: 0 additions & 60 deletions docker-compose.yml

This file was deleted.

47 changes: 47 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### COMMON #############################################
TIMEZONE=Asia/Shanghai

### NGINX ##############################################
NGINX_CONTAINER_NAME=mineadmin-nginx
NGINX_VERSION=nginx:latest
NGINX_HTTP_PORT=80
NGINX_HTTPS_PORT=443
NGINX_SSL_PATH=./nginx-frontend/ssl
NGINX_CONF_PATH=./nginx-frontend/servers
NGINX_ROOT_PATH=../web/dist

### HYPERF #############################################
HYPERF_CONTAINER_NAME=mineadmin-hyperf
HYPERF_VERSION=hyperf/hyperf:8.1-alpine-v3.18-swoole
HYPERF_ENTRYPOINT_DIR=/opt/www
HYPERF_HTTP_PORT=9501
HYPERF_WEBSOCKET_PORT=9502
HYPERF_RPC_PORT=9503
HYPERF_PROJECT_PATH=../

### MYSQL ##############################################
MYSQL_CONTAINER_NAME=mineadmin-mysql
MYSQL_VERSION=5.7
MYSQL_ROOT_PASSWORD=123456
MYSQL_PORT=3306
MYSQL_DATA_PATH=./db/data
MYSQL_LOGS_PATH=./db/logs
MYSQL_CONF_PATH=./db/conf
MYSQL_ENTRYPOINT_INITDB=/docker-entrypoint-initdb.d

### REDIS ##############################################
REDIS_CONTAINER_NAME=mineadmin-redis
REDIS_VERSION=redis:latest
REDIS_PORT=6380
REDIS_DATA_PATH=./redis

### RABBITMQ ###########################################
RABBITMQ_CONTAINER_NAME=mineadmin-rabbitmq
RABBITMQ_VERSION=rabbitmq:management
RABBITMQ_DEFAULT_USER=mineadmin
RABBITMQ_DEFAULT_PASS=12345

RABBITMQ_ERLANG_PORT=4369
RABBITMQ_CLIENT_PORT=5672
RABBITMQ_MANAGEMENT_PORT=15672
RABBITMQ_NODE_PORT=25672
2 changes: 2 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
db
redis
83 changes: 83 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: '3'
services:
# 首先下载前端,https://gitee.com/mineadmin/mineadmin-vue
# 在后端根目录建立mine-ui目录,把前端文件复制过来。
# 容器内访问宿主机的地址用:host.docker.internal
# 宿主机也可以在hosts文件添加:127.0.0.1 host.docker.internal
# mine-ui的.env.development文件127.0.0.1替换为host.docker.internal
nginx-frontend:
container_name: ${NGINX_CONTAINER_NAME}
image: ${NGINX_VERSION}
restart: always
environment:
- "TIMEZONE=${TIMEZONE}"
ports:
- "${NGINX_HTTP_PORT}:80"
- "${NGINX_HTTPS_PORT}:443"
volumes:
- ${NGINX_ROOT_PATH}:/usr/share/nginx/html
- ${NGINX_CONF_PATH}:/etc/nginx/conf.d
- ${NGINX_SSL_PATH}:/etc/nginx/ssl

# mineadmin的.env的mysql、redis如果连接到宿主机,地址用:host.docker.internal
# 如果是连接到docker内服务,则用服务名称,如:redis
hyperf:
container_name: ${HYPERF_CONTAINER_NAME}
image: ${HYPERF_VERSION}
restart: always
environment:
- "TIMEZONE=${TIMEZONE}"
- "APP_PROJECT=hyperf"
- "APP_SYSTEM_ENV=docker"
working_dir: ${HYPERF_ENTRYPOINT_DIR}
ports:
- ${HYPERF_HTTP_PORT}:9501
- ${HYPERF_WEBSOCKET_PORT}:9502
- ${HYPERF_RPC_PORT}:9503
volumes:
- ${HYPERF_PROJECT_PATH}:/opt/www
entrypoint: ["php", "watch", "-c"]

# 没有将volumes映射出来,需要持久化自行百度一下

mysql:
container_name: ${MYSQL_CONTAINER_NAME}
image: mysql:${MYSQL_VERSION}
restart: always
environment:
- "TZ=${TIMEZONE}"
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- "explicit_defaults_for_timestamp=true"
- "lower_case_table_names=1"
ports:
- "${MYSQL_PORT}:3306"
volumes:
- ${MYSQL_DATA_PATH}:/var/lib/mysql
- ${MYSQL_LOGS_PATH}:/var/log/mysql
- ${MYSQL_CONF_PATH}:/etc/mysql
# command: "--default-authentication-plugin=mysql_native_password"

redis:
container_name: ${REDIS_CONTAINER_NAME}
image: ${REDIS_VERSION}
restart: always
environment:
- "TZ=${TIMEZONE}"
ports:
- ${REDIS_PORT}:6379
volumes:
- ${REDIS_DATA_PATH}:/data
command: "redis-server /data/redis.conf"

rabbitmq:
container_name: ${RABBITMQ_CONTAINER_NAME}
image: ${RABBITMQ_VERSION}
restart: always
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
ports:
- "${RABBITMQ_ERLANG_PORT}:4369"
- "${RABBITMQ_CLIENT_PORT}:5672"
- "${RABBITMQ_MANAGEMENT_PORT}:15672"
- "${RABBITMQ_NODE_PORT}:25672"

0 comments on commit 2c4dfab

Please sign in to comment.