Skip to content

Commit 3c839c7

Browse files
committed
Merge branch 'master' into service/memcached
# Conflicts: # Dockerfiles/php-fpm/Dockerfile
2 parents b30e4cd + ea134d2 commit 3c839c7

File tree

7 files changed

+83
-42
lines changed

7 files changed

+83
-42
lines changed

.gitignore

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# Ignore everything
2-
/*
1+
.env
32

4-
#
5-
!.gitignore
6-
!.editorconfig
7-
!README.md
8-
!docker-compose.yml
9-
!/Logs/
10-
!/Dockerfiles/
3+
.DS_Store
4+
.vscode/*

Database/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

Dockerfiles/php-fpm/Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RUN set -xe; \
1212
apt-utils \
1313
unzip \
1414
curl \
15+
libzip-dev \
16+
zip \
1517
libmemcached-dev \
1618
zlib1g-dev \
1719
libz-dev \
@@ -35,7 +37,17 @@ RUN set -xe; \
3537
docker-php-ext-install opcache && \
3638
docker-php-ext-enable opcache && \
3739
docker-php-ext-enable redis && \
38-
docker-php-ext-enable xdebug
40+
docker-php-ext-enable xdebug && \
41+
docker-php-ext-configure zip --with-libzip && \
42+
docker-php-ext-install zip
43+
44+
45+
# install, upgrade openssl
46+
RUN apt-get update -yqq \
47+
&& apt-get install -y --no-install-recommends openssl \
48+
&& sed -i 's,^\(MinProtocol[ ]*=\).*,\1'TLSv1.0',g' /etc/ssl/openssl.cnf \
49+
&& sed -i 's,^\(CipherString[ ]*=\).*,\1'DEFAULT@SECLEVEL=1',g' /etc/ssl/openssl.cnf\
50+
&& rm -rf /var/lib/apt/lists/*
3951

4052

4153

@@ -56,15 +68,6 @@ RUN curl -fsSL 'https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCK
5668

5769

5870

59-
# install zip extensions
60-
# ps. next lines are here becase there is no auto build on docker
61-
RUN apt-get install -y --no-install-recommends \
62-
libzip-dev \
63-
zip \
64-
&& docker-php-ext-configure zip --with-libzip \
65-
&& docker-php-ext-install zip
66-
67-
6871
COPY ./pool.conf /usr/local/etc/php-fpm.d/pool.conf
6972

7073

README.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
> ![preview](https://user-images.githubusercontent.com/4863629/75411880-c332be00-595b-11ea-8490-aa8389a4636d.png)
2+
13
# Docker Compose for local development
24

35
> - https ready!
46
> - multiple domain / project support
57
> - PHP Xdebug
8+
> - php7wrapper
69
>
710
> reference from https://laradock.io
811
@@ -14,8 +17,8 @@
1417
- [Change PHP Configuration](#change-php-configuration)
1518
- [Information](#info)
1619
- ...
17-
- [docker image size preview](#docker-image-size)
1820
- [Xdebug & VSCode](#xdebug--vscode)
21+
- [PHP Wrapper](#php-wrapper)
1922

2023
# Setup
2124
- #### download & install docker for MAX(os x)
@@ -26,9 +29,10 @@
2629
>```bash
2730
>$ git clone https://github.com/cscolabear/docker-dev.git Projects
2831
>
29-
> # [optional] change branch, if you need mysql
32+
> # [optional] create your local branch e.g. local-dev, and merge branch, if you need mysql or memcached
3033
> $ git checkout service/add-mysql
3134
> ```
35+
3236
- #### make your folder look like this... (👉 replace `~/Projects` what you want.)
3337
> e.g.
3438
>
@@ -44,19 +48,22 @@
4448
> ```bash
4549
> $ cd ~/Projects
4650
> $ chmod -R 755 Logs
47-
> $ dokcer-compose up -d
51+
> $ dokcer-compose --compatibility up -d
4852
> ```
53+
> (Compatibility mode: https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-mode)
54+
>
4955
>
5056
> ⏳ Please wait
57+
>
5158
5259
- #### SSH into a container
5360
> ```bash
54-
> $ cd ~/Projects/ && clear && docker-compose exec workspace bash
61+
> $ cd ~/Projects/ && clear && docker-compose exec WORKSPACE bash
5562
> ```
5663
>
5764
> looked like after connected~
5865
> ![docker-for-local-dev-ssh-into](https://user-images.githubusercontent.com/4863629/56189375-60457a80-605a-11e9-9e6d-7a948d339a4c.png)
59-
> you can execute composer, node, npm in here
66+
> you can execute composer, node, npm in this container
6067
6168
- #### enjoy Docker 🐳
6269
> 👉 create index.php & index.html
@@ -111,7 +118,7 @@
111118
> - modify `Dockerfiles/php-fpm/php.ini`
112119
> - restart php-fpm Docker Container
113120
> ```base
114-
> $ docker-compose restart fpm
121+
> $ docker-compose restart FPM
115122
>```
116123
117124
## Info
@@ -136,11 +143,6 @@
136143
>
137144
> ~/Projects/Logs/nginx-error.log
138145
139-
- #### docker image size
140-
> ![docker-image-size](https://user-images.githubusercontent.com/4863629/58860143-0d915200-86de-11e9-9b5a-d4cf688a230d.png)
141-
142-
143-
144146
- #### Xdebug & VSCode
145147
> - install the vscode extension <br>
146148
> - PHP Debug
@@ -175,12 +177,33 @@
175177
> ```
176178
177179
- vscode debug 設定檔每個專案都要設定一次<br>
178-
- 路徑對應重點, 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確<br>
179-
也可以 ssh fpm container 查看 `/tmp/xdebug.log`<br>
180+
- 路徑對應是重點(pathMappings), 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確<br>
181+
也可以 ssh 進入 fpm container 查看 `/tmp/xdebug.log`<br>
180182
>```
181183
> "pathMappings": {
182184
> "/var/www": "${workspaceRoot}"
183185
> // or
184186
> "/var/www/[your Project folder]": "${workspaceRoot}"
185187
> },
186-
>```
188+
>```
189+
>
190+
> - xdebug.ini
191+
> ; for MAC os x
192+
> xdebug.remote_host=host.docker.internal
193+
>
194+
195+
# PHP Wrapper
196+
> branch exposure-php 內的 php7wrapper (https://github.com/cscolabear/docker-dev/blob/exposure-php/php7wrapper)
197+
198+
因為本機 MAC os x 和 docker 環境內的 PHP 版本不同
199+
所以利用 `php7wrapper` 曝光 docker 內的 php 讓本機開發與執行使用同樣的 php 版本
200+
201+
- 將 `exposure-php` branch merge 至 local-dev branch
202+
203+
```bash
204+
$ ln -s ~/Projects/php7wrapper /usr/local/bin php
205+
$ chmod +x /usr/local/bin php
206+
```
207+
(MAC osx 原生 PHP path: /usr/bin/php)
208+
209+

docker-compose.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ services:
99
ports:
1010
- 9000:9000
1111
volumes:
12-
- ./:/var/www
13-
- ./Dockerfiles/php-fpm/php.ini:/usr/local/etc/php/php.ini
14-
- ./Dockerfiles/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
12+
- ${VOLUMES_DRIVER}:/var/www:delegated
13+
- ./Dockerfiles/php-fpm/php.ini:/usr/local/etc/php/php.ini:ro
14+
- ./Dockerfiles/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:ro
1515
deploy:
1616
resources:
1717
limits:
@@ -37,9 +37,9 @@ services:
3737
- 80:80
3838
- 443:443
3939
volumes:
40-
- ./:/var/www
41-
- ./Logs:/var/log/nginx
42-
- ./Dockerfiles/nginx/sites-enabled:/etc/nginx/sites-enabled
40+
- ${VOLUMES_DRIVER}:/var/www:delegated
41+
- ./Logs:/var/log/nginx:delegated
42+
- ./Dockerfiles/nginx/sites-enabled:/etc/nginx/sites-enabled:ro
4343
depends_on:
4444
- FPM
4545
deploy:
@@ -78,17 +78,16 @@ services:
7878
context: ./Dockerfiles/workspace
7979
image: cscolabear/workspace:latest
8080
ports:
81-
- "22:22"
81+
- "3000"
8282
volumes:
83-
- ./:/var/www
83+
- ${VOLUMES_DRIVER}:/var/www:delegated
8484
depends_on:
8585
- FPM
8686
- MEMCACHED
8787
restart: on-failure
8888
extra_hosts:
8989
- "localhost:172.16.1.50"
9090
# - "any-your-project-domain:172.16.1.50"
91-
tty: true
9291
networks:
9392
app_net:
9493
ipv4_address: 172.16.1.30

env-example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# DockerDev Variables
3+
#
4+
5+
# e.g. /Users/USER_NAME/Projects
6+
VOLUMES_DRIVER=

phpWrapper

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# https://gist.github.com/mihow/9c7f559807069a03e302605691f85572
4+
# Local .env
5+
if [ -f .env ]; then
6+
# Load Environment Variables
7+
export $(cat .env | grep -v '#' | awk '/=/ {print $1}')
8+
# For instance, will be example_kaggle_key
9+
echo $KAGGLE_KEY
10+
fi
11+
12+
docker run --rm -i \
13+
-v $VOLUMES_DRIVER:/var/www \
14+
cscolabear/7.2-fpm php "$@"

0 commit comments

Comments
 (0)