From 3bc8f58a1bd757ebe91acf1f7862a4e65846dead Mon Sep 17 00:00:00 2001 From: SimpleYoungMan Date: Tue, 29 Oct 2019 11:03:46 +0800 Subject: [PATCH] docker-compose config update readme update some file --- .env.example | 6 +++--- .gitignore | 4 ++++ docker-compose.yml | 24 ++++++++++++++++++++++++ init.sh | 4 +--- install.sql | 5 ++++- nginx/backend.conf | 3 +++ readme.md | 37 ++++++++++++++++++++++++++++++++++++- 7 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yml create mode 100644 nginx/backend.conf diff --git a/.env.example b/.env.example index 2d2ea86f..ecad6400 100755 --- a/.env.example +++ b/.env.example @@ -7,9 +7,9 @@ APP_URL=http://localhost LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=127.0.0.1 +DB_HOST=db DB_PORT=3306 -DB_DATABASE=laravel +DB_DATABASE=v2board DB_USERNAME=root DB_PASSWORD= @@ -49,4 +49,4 @@ DEFAULT_INVITE_FORCE=0 DEFAULT_INVITE_COMMISSION=10 DEFAULT_INVITE_GEN_LIMIT=5 DEFAULT_STOP_REGISTER=0 -DEFAULT_EMAIL_VERIFY=0 \ No newline at end of file +DEFAULT_EMAIL_VERIFY=0 diff --git a/.gitignore b/.gitignore index 597e9483..8ee057df 100755 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,11 @@ .env .env.backup .phpunit.result.cache +.idea Homestead.json Homestead.yaml npm-debug.log yarn-error.log +composer.phar +yarn.lock +dbdata diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..dfaf6cf6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + db: + container_name: v2board-db + image: mysql + environment: + - MYSQL_ALLOW_EMPTY_PASSWORD=true + volumes: + - ./dbdata:/var/lib/mysql + - ./install.sql:/install.sql + backend: + image: composer + working_dir: /root/backend + volumes: + - .:/root/backend + nginx: + image: nginx + volumes: + - .:/root/backend + - ./nginx:/etc/nginx/conf.d + ports: + - 8964:80 + diff --git a/init.sh b/init.sh index eb34e7ca..e6c3ff48 100755 --- a/init.sh +++ b/init.sh @@ -1,4 +1,2 @@ -wget https://getcomposer.org/download/1.9.0/composer.phar -php composer install php artisan key:generate -php artisan config:cache \ No newline at end of file +php artisan config:cache diff --git a/install.sql b/install.sql index bd95c9a2..44e4f2fc 100644 --- a/install.sql +++ b/install.sql @@ -2,6 +2,9 @@ SET NAMES utf8; SET time_zone = '+00:00'; SET foreign_key_checks = 0; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +DROP DATABASE IF EXISTS `v2board`; +CREATE DATABASE `v2board`; +USE `v2board`; DROP TABLE IF EXISTS `v2_invite_code`; CREATE TABLE `v2_invite_code` ( @@ -121,4 +124,4 @@ CREATE TABLE `v2_user` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- 2019-10-22 15:50:47 \ No newline at end of file +-- 2019-10-22 15:50:47 diff --git a/nginx/backend.conf b/nginx/backend.conf new file mode 100644 index 00000000..08c0a311 --- /dev/null +++ b/nginx/backend.conf @@ -0,0 +1,3 @@ +server { + +} diff --git a/readme.md b/readme.md index 9815fcd8..a345a105 100755 --- a/readme.md +++ b/readme.md @@ -1 +1,36 @@ -sh init.sh \ No newline at end of file + +## Environment: + +- PHP7.3+ +- composer +- MySQL5.5+ + +## Steps + +### Before + +执行 `cp .env.example .env` 然后配置它; + +### 本地环境部署 + +1. 下载 composer + > ```shell script + > wget https://getcomposer.org/download/1.9.0/composer.phar + > php composer.phar install + > ``` +2. 初始化项目 + > ```shell script + > sh init.sh + > ``` + > +3. 从 `install.sql` 文件中恢复表 + + +### Docker 环境部署 +1. 初始化项目 + > ```shell script + > docker-compose run --rm backend composer install + > docker-compose run --rm backend sh init.sh + > ``` +2. 进入 docker 容器从 `install.sql` 文件中恢复表 +3. 执行 `docker-compose up -d` 启动服务