From 2799cced354da2fdc1844a9e293fbc6e88b20175 Mon Sep 17 00:00:00 2001 From: Cola Date: Tue, 16 Apr 2019 17:17:46 +0800 Subject: [PATCH 01/14] just use image --- docker-compose.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 87529dd..2d43a7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,20 @@ services: app_net: ipv4_address: 172.16.1.40 + mysql: + hostname: docker-mysql + image: mysql:5.7 + ports: + - 3306:3306 + command: --default-authentication-plugin=mysql_native_password + environment: + MYSQL_ROOT_PASSWORD: password + MYSQL_USER: developer + MYSQL_PASSWORD: password + restart: on-failure + networks: + - app_net + nginx: hostname: docker-nginx build: From a8b7933d94e2da5aaf4ded8d33fa743245a7b571 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 25 Apr 2019 15:04:48 +0800 Subject: [PATCH 02/14] keep mysql data, table.. --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 2d43a7b..26a3c25 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,8 @@ services: ports: - 3306:3306 command: --default-authentication-plugin=mysql_native_password + volumes: + - ./Database/mysql:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: password MYSQL_USER: developer From 12f5e6c4f6becd20f1a860149b4aec47b1e8b839 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 18 Jul 2019 17:51:39 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E8=A7=A3=E6=B1=BA=20only=5Ffull=5Fgroup?= =?UTF-8?q?=5Fby=20=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 26a3c25..7eeff29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,7 @@ services: MYSQL_ROOT_PASSWORD: password MYSQL_USER: developer MYSQL_PASSWORD: password + command: mysqld --sql_mode="" --character-set-server=utf8 --init-connect='SET NAMES UTF8;' restart: on-failure networks: - app_net From cfa715931296ce3f873d8943fc0d503a852d62cc Mon Sep 17 00:00:00 2001 From: Cola Date: Wed, 26 Feb 2020 13:31:44 +0800 Subject: [PATCH 04/14] remove depends on service --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index ca52d8d..e75dbfe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -95,7 +95,6 @@ services: depends_on: - FPM - MYSQL - - MEMCACHED restart: on-failure extra_hosts: - "localhost:172.16.1.50" From 0db82c9343ad6e92e6c04dfff4cd10c792d093a4 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 27 Feb 2020 12:19:54 +0800 Subject: [PATCH 05/14] remove reservations.cpus --- docker-compose.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e75dbfe..b4caa79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,6 @@ services: cpus: '0.50' memory: 512M reservations: - cpus: '0.25' memory: 128M restart_policy: condition: on-failure @@ -48,7 +47,6 @@ services: cpus: '0.50' memory: 512M reservations: - cpus: '0.25' memory: 256M restart_policy: condition: on-failure @@ -75,7 +73,6 @@ services: cpus: '0.10' memory: 30M reservations: - cpus: '0.05' memory: 10M restart_policy: condition: on-failure From b4206a4c73137480af276bcb9348198bf2f6585d Mon Sep 17 00:00:00 2001 From: Cola Date: Wed, 26 Feb 2020 14:26:14 +0800 Subject: [PATCH 06/14] update readme --- README.md | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0e60759..3617824 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ > - https ready! > - multiple domain / project support > - PHP Xdebug +> - php7wrapper > > reference from https://laradock.io @@ -14,8 +15,8 @@ - [Change PHP Configuration](#change-php-configuration) - [Information](#info) - ... - - [docker image size preview](#docker-image-size) - [Xdebug & VSCode](#xdebug--vscode) +- [PHP Wrapper](#php-wrapper) # Setup - #### download & install docker for MAX(os x) @@ -26,9 +27,10 @@ >```bash >$ git clone https://github.com/cscolabear/docker-dev.git Projects > - > # [optional] change branch, if you need mysql + > # [optional] create your local branch e.g. local-dev, and merge branch, if you need mysql or memcached > $ git checkout service/add-mysql > ``` + - #### make your folder look like this... (👉 replace `~/Projects` what you want.) > e.g. > @@ -44,19 +46,22 @@ > ```bash > $ cd ~/Projects > $ chmod -R 755 Logs - > $ dokcer-compose up -d + > $ dokcer-compose --compatibility up -d > ``` + > (Compatibility mode: https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-mode) + > > > ⏳ Please wait + > - #### SSH into a container > ```bash - > $ cd ~/Projects/ && clear && docker-compose exec workspace bash + > $ cd ~/Projects/ && clear && docker-compose exec WORKSPACE bash > ``` > > looked like after connected~ > ![docker-for-local-dev-ssh-into](https://user-images.githubusercontent.com/4863629/56189375-60457a80-605a-11e9-9e6d-7a948d339a4c.png) - > you can execute composer, node, npm in here + > you can execute composer, node, npm in this container - #### enjoy Docker 🐳 > 👉 create index.php & index.html @@ -111,7 +116,7 @@ > - modify `Dockerfiles/php-fpm/php.ini` > - restart php-fpm Docker Container > ```base - > $ docker-compose restart fpm + > $ docker-compose restart FPM >``` ## Info @@ -136,11 +141,6 @@ > > ~/Projects/Logs/nginx-error.log -- #### docker image size - > ![docker-image-size](https://user-images.githubusercontent.com/4863629/58860143-0d915200-86de-11e9-9b5a-d4cf688a230d.png) - - - - #### Xdebug & VSCode > - install the vscode extension
> - PHP Debug @@ -175,12 +175,33 @@ > ``` - vscode debug 設定檔每個專案都要設定一次
- - 路徑對應重點, 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確
- 也可以 ssh 至 fpm container 查看 `/tmp/xdebug.log`
+ - 路徑對應是重點(pathMappings), 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確
+ 也可以 ssh 進入 fpm container 查看 `/tmp/xdebug.log`
>``` > "pathMappings": { > "/var/www": "${workspaceRoot}" > // or > "/var/www/[your Project folder]": "${workspaceRoot}" > }, - >``` \ No newline at end of file + >``` + > + > - xdebug.ini + > ; for MAC os x + > xdebug.remote_host=host.docker.internal + > + +# PHP Wrapper + > branch exposure-php 內的 php7wrapper (https://github.com/cscolabear/docker-dev/blob/exposure-php/php7wrapper) + + 因為本機 MAC os x 和 docker 環境內的 PHP 版本不同 + 所以利用 `php7wrapper` 曝光 docker 內的 php 讓本機開發與執行使用同樣的 php 版本 + + - 將 `exposure-php` branch merge 至 local-dev branch + + ```bash + $ ln -s ~/Projects/php7wrapper /usr/local/bin php + $ chmod +x /usr/local/bin php + ``` + (MAC osx 原生 PHP path: /usr/bin/php) + + From 10cfbdac2798f170114d81c9e2046623a2614363 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 27 Feb 2020 12:23:27 +0800 Subject: [PATCH 07/14] readme add preview photo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3617824..7db405c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +> ![preview](https://user-images.githubusercontent.com/4863629/75411880-c332be00-595b-11ea-8490-aa8389a4636d.png) + # Docker Compose for local development > - https ready! From f7af22d67efa5ebdc4f3c1dc1650418ef6543252 Mon Sep 17 00:00:00 2001 From: Cola Date: Tue, 14 Apr 2020 11:01:00 +0800 Subject: [PATCH 08/14] change WORKSPACE export port --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b4caa79..7c947d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -86,7 +86,7 @@ services: context: ./Dockerfiles/workspace image: cscolabear/workspace:latest ports: - - "22:22" + - "3000" volumes: - ./:/var/www depends_on: From d835dceceadfc7356cd287691e0ec0d678652d34 Mon Sep 17 00:00:00 2001 From: Cola Date: Tue, 28 Apr 2020 12:24:22 +0800 Subject: [PATCH 09/14] add delegated, ro para --- docker-compose.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7c947d8..1897fbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,9 +9,9 @@ services: ports: - 9000:9000 volumes: - - ./:/var/www - - ./Dockerfiles/php-fpm/php.ini:/usr/local/etc/php/php.ini - - ./Dockerfiles/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini + - ./:/var/www:delegated + - ./Dockerfiles/php-fpm/php.ini:/usr/local/etc/php/php.ini:ro + - ./Dockerfiles/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:ro deploy: resources: limits: @@ -62,9 +62,9 @@ services: - 80:80 - 443:443 volumes: - - ./:/var/www - - ./Logs:/var/log/nginx - - ./Dockerfiles/nginx/sites-enabled:/etc/nginx/sites-enabled + - ./:/var/www:delegated + - ./Logs:/var/log/nginx:delegated + - ./Dockerfiles/nginx/sites-enabled:/etc/nginx/sites-enabled:ro depends_on: - FPM deploy: @@ -88,7 +88,7 @@ services: ports: - "3000" volumes: - - ./:/var/www + - ./:/var/www:delegated depends_on: - FPM - MYSQL From 547a71b99a5a0fdd7041698be36c9a04c747912a Mon Sep 17 00:00:00 2001 From: Cola Date: Mon, 4 May 2020 10:43:17 +0800 Subject: [PATCH 10/14] update php fpm install open ssl for system upgrade php zip --- Dockerfiles/php-fpm/Dockerfile | 36 ++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/Dockerfiles/php-fpm/Dockerfile b/Dockerfiles/php-fpm/Dockerfile index dd697e0..da3f27f 100644 --- a/Dockerfiles/php-fpm/Dockerfile +++ b/Dockerfiles/php-fpm/Dockerfile @@ -12,6 +12,8 @@ RUN set -xe; \ apt-utils \ unzip \ curl \ + libzip-dev \ + zip \ libmemcached-dev \ zlib1g-dev \ libz-dev \ @@ -35,16 +37,34 @@ RUN set -xe; \ docker-php-ext-install opcache && \ docker-php-ext-enable opcache && \ docker-php-ext-enable redis && \ - docker-php-ext-enable xdebug + docker-php-ext-enable xdebug && \ + docker-php-ext-configure zip --with-libzip && \ + docker-php-ext-install zip -# install zip extensions -# ps. next lines are here becase there is no auto build on docker -RUN apt-get install -y --no-install-recommends \ - libzip-dev \ - zip \ - && docker-php-ext-configure zip --with-libzip \ - && docker-php-ext-install zip +# install, upgrade openssl +RUN apt-get update -yqq \ + && apt-get install -y --no-install-recommends openssl \ + && sed -i 's,^\(MinProtocol[ ]*=\).*,\1'TLSv1.0',g' /etc/ssl/openssl.cnf \ + && sed -i 's,^\(CipherString[ ]*=\).*,\1'DEFAULT@SECLEVEL=1',g' /etc/ssl/openssl.cnf\ + && rm -rf /var/lib/apt/lists/* + + + +# Install needed php extensions: memcache +RUN curl -fsSL 'https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip' -o memcache.zip \ + && unzip memcache.zip \ + && rm memcache.zip \ + && ( \ + cd pecl-memcache-NON_BLOCKING_IO_php7 \ + && phpize \ + && ./configure --enable-memcache \ + && make \ + && make install \ + ) \ + && rm -r pecl-memcache-NON_BLOCKING_IO_php7 \ + && docker-php-ext-enable memcache + COPY ./pool.conf /usr/local/etc/php-fpm.d/pool.conf From c3e999ce6e139ad7c437bad5e16f355e491c07f0 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 11 Jul 2019 18:42:14 +0800 Subject: [PATCH 11/14] add php wrapper bash --- .gitignore | 1 + php7wrapper | 5 +++++ 2 files changed, 6 insertions(+) create mode 100755 php7wrapper diff --git a/.gitignore b/.gitignore index 0931131..3260032 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ !docker-compose.yml !/Logs/ !/Dockerfiles/ +!php7wrapper \ No newline at end of file diff --git a/php7wrapper b/php7wrapper new file mode 100755 index 0000000..22f7e46 --- /dev/null +++ b/php7wrapper @@ -0,0 +1,5 @@ +#!/bin/bash + +docker run --rm -i \ + -v $PWD:/var/www \ + cscolabear/7.2-fpm php "$@" \ No newline at end of file From 16cc3099f2935cdab0d03dd12d2643e1e1dabfd5 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 7 May 2020 12:07:33 +0800 Subject: [PATCH 12/14] update add env phpWrapper use env VOLUMES_DRIVER --- .gitignore | 13 +++---------- Database/.gitignore | 2 ++ docker-compose.yml | 7 +++---- env-example | 6 ++++++ php7wrapper | 5 ----- phpWrapper | 14 ++++++++++++++ 6 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 Database/.gitignore create mode 100644 env-example delete mode 100755 php7wrapper create mode 100755 phpWrapper diff --git a/.gitignore b/.gitignore index 3260032..b9b3612 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,4 @@ -# Ignore everything -/* +.env -# -!.gitignore -!.editorconfig -!README.md -!docker-compose.yml -!/Logs/ -!/Dockerfiles/ -!php7wrapper \ No newline at end of file +.DS_Store +.vscode/* diff --git a/Database/.gitignore b/Database/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/Database/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/docker-compose.yml b/docker-compose.yml index 1897fbc..3e5dba4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: ports: - 9000:9000 volumes: - - ./:/var/www:delegated + - ${VOLUMES_DRIVER}:/var/www:delegated - ./Dockerfiles/php-fpm/php.ini:/usr/local/etc/php/php.ini:ro - ./Dockerfiles/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:ro deploy: @@ -62,7 +62,7 @@ services: - 80:80 - 443:443 volumes: - - ./:/var/www:delegated + - ${VOLUMES_DRIVER}:/var/www:delegated - ./Logs:/var/log/nginx:delegated - ./Dockerfiles/nginx/sites-enabled:/etc/nginx/sites-enabled:ro depends_on: @@ -88,7 +88,7 @@ services: ports: - "3000" volumes: - - ./:/var/www:delegated + - ${VOLUMES_DRIVER}:/var/www:delegated depends_on: - FPM - MYSQL @@ -96,7 +96,6 @@ services: extra_hosts: - "localhost:172.16.1.50" # - "any-your-project-domain:172.16.1.50" - tty: true networks: app_net: ipv4_address: 172.16.1.30 diff --git a/env-example b/env-example new file mode 100644 index 0000000..b8d126c --- /dev/null +++ b/env-example @@ -0,0 +1,6 @@ +# +# DockerDev Variables +# + +# e.g. /Users/USER_NAME/Projects +VOLUMES_DRIVER= diff --git a/php7wrapper b/php7wrapper deleted file mode 100755 index 22f7e46..0000000 --- a/php7wrapper +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -docker run --rm -i \ - -v $PWD:/var/www \ - cscolabear/7.2-fpm php "$@" \ No newline at end of file diff --git a/phpWrapper b/phpWrapper new file mode 100755 index 0000000..7752c80 --- /dev/null +++ b/phpWrapper @@ -0,0 +1,14 @@ +#!/bin/bash + +# https://gist.github.com/mihow/9c7f559807069a03e302605691f85572 +# Local .env +if [ -f .env ]; then + # Load Environment Variables + export $(cat .env | grep -v '#' | awk '/=/ {print $1}') + # For instance, will be example_kaggle_key + echo $KAGGLE_KEY +fi + +docker run --rm -i \ + -v $VOLUMES_DRIVER:/var/www \ + cscolabear/7.2-fpm php "$@" From f40eabb6785ca25253de72af71efa09b1a6420a0 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 7 May 2020 12:50:40 +0800 Subject: [PATCH 13/14] change env usage --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3e5dba4..36b99f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,9 +37,9 @@ services: volumes: - ./Database/mysql:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD: password - MYSQL_USER: developer - MYSQL_PASSWORD: password + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} command: mysqld --sql_mode="" --character-set-server=utf8 --init-connect='SET NAMES UTF8;' deploy: resources: From bf4eb0217a93d0b57fd1e600cca4d41787a37402 Mon Sep 17 00:00:00 2001 From: Cola Date: Thu, 7 May 2020 12:50:45 +0800 Subject: [PATCH 14/14] remove test usename, password --- env-example | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/env-example b/env-example index b8d126c..10c363e 100644 --- a/env-example +++ b/env-example @@ -4,3 +4,10 @@ # e.g. /Users/USER_NAME/Projects VOLUMES_DRIVER= + + + +# mysql +MYSQL_ROOT_PASSWORD= +MYSQL_USER= +MYSQL_PASSWORD=