diff --git a/.env.example b/.env.example index 9e15581..b9c649f 100755 --- a/.env.example +++ b/.env.example @@ -1,12 +1,12 @@ APP_NAME=web-php APP_PORT=8080 +PHP_VERSION=7.2 REDIS_HOST=web-redis REDIS_PORT=6379 -DB_DATABASE=example - DB_HOST=web-mysql DB_PORT=3306 DB_USERNAME=root -DB_PASSWORD=secret \ No newline at end of file +DB_PASSWORD=root +DB_DATABASE=example \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index 025725e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM 1and1internet/ubuntu-16-apache-php-7.2 - -# install phpredis function -RUN apt-get update && \ - apt-get install -y software-properties-common && \ - apt-get install -y php7.2-redis - -EXPOSE 8080 - -WORKDIR /var/www/html diff --git a/README.md b/README.md index 24f4b5a..824709e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Docker-AMPR -Apache + Mysql + PHP + Redis 直接在 docker 上運行懶人包 +- Apache + fcgid + PHP + Redis + MySQL 直接在 docker 上運行懶人包。 +- 使用 [網紅神人等級](https://shazi.info/) 的 [映像檔](https://github.com/shazi7804/docker-apache2-fcgid-worker-php7)。 +- [English](https://github.com/andykuen/Docker-AMPR/blob/master/README_EN.md) ## 如何使用 @@ -29,8 +31,22 @@ P.S. 預設網址: `http://127.0.0.1:8080/` | $ make exec | 進入 container 裡面 | | $ make del | 解除安裝 Docker-AMPR | -## 相關範例 -### 在 Docker-AMPR 開發 Laravel 相關程式 +# 環境參數 +| 參數 | 說明 | 預設值 | +| ----------- | ---------------------- | -------- | +| APP_NAME | docker container 名稱 | web-php | +| APP_PORT | docker port | 8080 | +| PHP_VERSION | php 版本 | 7.2 | +| REDIS_HOST | redis host | web-redis | +| REDIS_PORT | redis port | 6379 | +| DB_DATABASE | database 名稱 | example | +| DB_HOST | database host | web-mysql | +| DB_PORT | database port | 3306 | +| DB_USERNAME | database 使用者名稱 | root | +| DB_PASSWORD | database 密碼 | root | + +# 相關範例 +## 在 Docker-AMPR 開發 Laravel 相關程式 1. 進入 container 裡面 ```bash diff --git a/README_EN.md b/README_EN.md index 78ea12e..15894b4 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,5 +1,7 @@ # Docker-AMPR -Example for Apache+Mysql+PHP+Redis run on docker +- Example for Apache + mod_fcgid + PHP + Redis + MySQL run on docker +- Use [Mr. shazi](https://shazi.info/)'s [image](https://github.com/shazi7804/docker-apache2-fcgid-worker-php7). +- [中文說明](https://github.com/andykuen/Docker-AMPR/blob/master/README.md) ## How to use @@ -27,7 +29,23 @@ Example for Apache+Mysql+PHP+Redis run on docker | $ make exec | go into APP container | | $ make del | delete container | -## for Laravel example + +# Environment document +| Key | Help | Default | +| ----------- | ---------------------- | --------- | +| APP_NAME | docker container name | web-php | +| APP_PORT | docker port | 8080 | +| PHP_VERSION | php version | 7.2 | +| REDIS_HOST | redis host | web-redis | +| REDIS_PORT | redis port | 6379 | +| DB_DATABASE | database name | example | +| DB_HOST | database host | web-mysql | +| DB_PORT | database port | 3306 | +| DB_USERNAME | database username | root | +| DB_PASSWORD | database password | root | + +# Example +## For Laravel framework 1. go into container ```bash diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c419263..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/database/example.sql b/database/example.sql new file mode 100755 index 0000000..fdec53f --- /dev/null +++ b/database/example.sql @@ -0,0 +1,9 @@ +-- database example +CREATE DATABASE IF NOT EXISTS `example` CHARACTER SET utf8 COLLATE utf8_unicode_ci; + +-- users +CREATE TABLE IF NOT EXISTS `example`.`users` ( + `id` VARCHAR(32) COLLATE utf8_unicode_ci NOT NULL, + `name` VARCHAR(32) COLLATE utf8_unicode_ci NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5f6522a..8467187 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,16 @@ version: "3.5" services: web: + image: shazi7804/apache2-fcgid-worker-php7:${PHP_VERSION} container_name: ${APP_NAME} hostname: ${APP_NAME} networks: - LAN - build: - context: ./ - dockerfile: Dockerfile ports: - - ${APP_PORT}:8080 + - ${APP_PORT}:80 volumes: - ./:/var/www/html/ + working_dir: /var/www/html/ environment: DB_HOST: ${DB_HOST} REDIS_HOST: ${REDIS_HOST} @@ -45,7 +44,8 @@ services: - LAN ports: - ${REDIS_PORT}:6379 + networks: LAN: driver: bridge - name: web_LAN + name: ${APP_NAME}_LAN