Skip to content

Commit 6bd7bb6

Browse files
author
Pieter Meyvaert
committed
Initial commit - copy from compose-pimcore
0 parents  commit 6bd7bb6

19 files changed

+763
-0
lines changed

.env-sample

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Configure what UID and GID your PHP container must use.
3+
# This usually should match your Hosts UID and GID.
4+
# To find your local UID you can run id -u and to find your local GID you can run id -g.
5+
#
6+
C_UID=1000
7+
C_GID=1000
8+
9+
#
10+
# Choose your PHP version. To see which versions are available see https://github.com/dockerwest/php-symfony
11+
#
12+
PHPVERSION=7.1
13+
14+
#
15+
# Choose what version of Nginx you want. To see which versions are available see https://github.com/dockerwest/nginx-symfony
16+
#
17+
NGINXVERSION=stable
18+
19+
#
20+
# This setting defines what the hostname will be you can browse your Symfony app.
21+
# The example configuration will be give you http://application.dev.
22+
#
23+
BASEHOST=application.dev
24+
25+
#
26+
# Choose whatever you want to use as default mysql root password.
27+
#
28+
MYSQL_ROOT_PASSWORD=toor
29+
30+
#
31+
# A relative or absolute path to your application code.
32+
#
33+
APPLICATION=../application
34+
35+
#
36+
# Set the development flag. Default we use noprofile which will allow us to use xdebug.
37+
# When DEVELOPMENT=1 you also have tideways enabled which gives you profiling output of you application.
38+
# To visualize your profiling output see https://github.com/BlackIkeEagle/docker-compose-xhgui
39+
#
40+
DEVELOPMENT=noprofile
41+
42+
#
43+
# Set the default window manager when running the environment
44+
# Available options are: tmux, screen and byobu
45+
#
46+
WINDOW_MANAGER=tmux

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

LICENSE.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
The MIT License (MIT)
2+
=====================
3+
4+
Copyright © `2017` `DockerWest contributors`
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the “Software”), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.
26+

README.md

+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
PHP basic developer environment
2+
===============================
3+
4+
Basic developer environment for Symfony apps.
5+
6+
Usage
7+
-----
8+
9+
For your convenience the developer environment has some helpers which take away
10+
some difficulties you could experience using docker containers.
11+
12+
If you want this easy helpers to be readily available for you you can use
13+
`environment` before you start. `environment` allows you to start your
14+
environment with an updated `PATH` and allows you to choose between `tmux`,
15+
`screen` or `byobu`. You can also define a default in the .env file.
16+
17+
explicit setting the window manager:
18+
19+
~~~ sh
20+
$ ./environment [tmux|screen|byobu]
21+
~~~
22+
23+
using default window manager, defined in .env
24+
25+
~~~ sh
26+
$ ./environment
27+
~~~
28+
29+
When you are running in this environment all helpers are available in your path.
30+
31+
You are not required to use the environent, but then you have to call the
32+
helpers with their full path.
33+
34+
To make use of the helpers you should use the `run` wrapper for `docker-compose`.
35+
36+
~~~ sh
37+
$ run up
38+
~~~
39+
40+
Configuration
41+
-------------
42+
43+
There is a sample configuration `.env-sample` which contains the defaults used
44+
in this environment.
45+
46+
If you want to change some of these values, copy `.env-sample` to `.env` and
47+
start editing.
48+
49+
default `.env-sample`
50+
51+
~~~
52+
C_UID=1000
53+
C_GID=1000
54+
PHPVERSION=7.1
55+
NGINXVERSION=stable
56+
BASEHOST=application.dev
57+
MYSQL_ROOT_PASSWORD=toor
58+
APPLICATION=../application
59+
DEVELOPMENT=noprofile
60+
WINDOW_MANAGER=tmux
61+
~~~
62+
63+
### C_UID / C_GID
64+
65+
Configure what UID and GID your PHP container must use. This usually should
66+
match your Hosts UID and GID. To find your local UID you can run `id -u` and to
67+
find your local GID you can run `id -g`.
68+
69+
### PHPVERSION
70+
71+
Choose your PHP version. To see which versions are available
72+
[here](https://github.com/dockerwest/php-symfony).
73+
74+
### NGINXVERSION
75+
76+
Choose what version of Nginx you want. To see which versions are available see
77+
[here](https://github.com/dockerwest/nginx-symfony)
78+
79+
### BASEHOST
80+
81+
This setting defines what the hostname will be you can browse your Symfony app.
82+
The example configuration will be give you `http://application.dev`.
83+
84+
### MYSQL_ROOT_PASSWORD
85+
86+
Choose whatever you want to use as default root password.
87+
88+
### APPLICATION
89+
90+
A relative or absolute path to your application code.
91+
92+
### DEVELOPMENT
93+
94+
Set the development flag. Default we use noprofile which will allow us to use
95+
xdebug. When `DEVELOPMENT=1` you also have tideways enabled which gives you
96+
profiling output of you application.
97+
98+
To visualize your profiling output see
99+
[docker-compose-xhgui](https://github.com/BlackIkeEagle/docker-compose-xhgui)
100+
101+
### WINDOW_MANAGER
102+
Set the default window manager when running the environment.
103+
Available options are: tmux, screen and byobu
104+
105+
Helpers
106+
-------
107+
108+
### composer
109+
Run the [composer](https://getcomposer.org/) command inside the php docker container.
110+
The working directory will be the current directory you are executing this command from.
111+
Your $HOME/.ssh and $HOME/.composer folders wil be mounted inside this container to enable you to make use of your ssh keys and composer cache.
112+
113+
eg. `$ composer require package_name`
114+
115+
### create_db
116+
Create a new database inside the running mysql container with the name 'database' and 'DEFAULT CHARSET utf8mb4'.
117+
118+
eg. `$ create_db database`
119+
120+
### mysql
121+
Execute a mysql command inside the running mysql container as the root user.
122+
123+
eg. `$ mysql "SELECT * FROM table_name;"`
124+
125+
### mysqldump
126+
Execute the mysqldump command inside the running mysql container as the root user.
127+
128+
eg. `$ mysqldump db_name > export_file_name.sql`
129+
130+
### mysqlimport
131+
Import a given mysql file into a given database, inside the running mysql container as the root user.
132+
133+
eg. `$ mysqlimport db_name import_file_name.sql`
134+
135+
### node
136+
Execute the [node](https://nodejs.org) command inside a node container.
137+
The working directory will be the current directory you are executing this command from.
138+
139+
eg. `$ node js_file.js`
140+
141+
### npm
142+
Execute the [npm](https://www.npmjs.com/) command inside a node container.
143+
The working directory will be the current directory you are executing this command from.
144+
Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache.
145+
146+
eg. `$ npm install package_name`
147+
148+
### yarn
149+
Execute the [yarn](https://yarnpkg.com) command inside a node container.
150+
The working directory will be the current directory you are executing this command from.
151+
Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache.
152+
153+
eg. `$ yarn add package_name`
154+
155+
### php
156+
Execute the php command inside the running php container, or inside a php-symfony container if none is running.
157+
The working directory will be the current directory you are executing this command from.
158+
159+
eg. `$ php -v`
160+
161+
### redis-cli
162+
Execute the [redis-cli](https://redis.io/topics/rediscli) command in the running redis container.
163+
164+
eg. `$ redis-cli flushall`
165+
166+
### run
167+
Run docker-compose for the current project, setting the project name to the BASEHOST variable from the .env file
168+
169+
eg. `$ run up`
170+
171+
Tricks
172+
------
173+
174+
### macOS
175+
176+
For this environment to work properly you should install gnu coreutils
177+
178+
using homebrew:
179+
180+
~~~ sh
181+
$ brew install coreutils
182+
~~~
183+
184+
On macOS you could just install docker from the docker site and run like this.
185+
But our experience is that the native docker install is fairly slow to use. We
186+
would suggest you to install [dinghy](https://github.com/codekitchen/dinghy).
187+
188+
[install dinghy](https://github.com/codekitchen/dinghy#install) and install the
189+
VM technology you want to use. If you want native xhyve support you can
190+
additionally install
191+
[xhyve driver for docker machine](https://github.com/zchee/docker-machine-driver-xhyve).
192+
193+
If you have dinghy installed this environment will try to use it.
194+
195+
Currently there is an annoying limitation when we are using dinghy and that is
196+
that the hostnames used must end with `docker`.
197+
198+
#### tmux on macOS
199+
200+
Tmux starts the shells as loginshells, that means that for example bash is
201+
going to load the `profile` files. This sort of behaviour triggers the
202+
path_helper that will move our added PATH to the end. This is not the behaviour
203+
we want.
204+
205+
To fix this you can change the if for the path helper in your `/etc/profile` to
206+
the following:
207+
208+
~~~ sh
209+
if [ -z $TMUX ] && [ -x /usr/libexec/path_helper ]; then
210+
eval `/usr/libexec/path_helper -s`
211+
fi
212+
~~~
213+
214+
### oh-my-zsh users
215+
216+
[oh-my-zsh](http://ohmyz.sh/) users should check if there is no fixed setting
217+
for `$PATH` in their `~/.zshrc`. If that is the case you can safely comment it
218+
out. If somewhere in your shell startup `$PATH` is forced you lose the features
219+
the `./environment` script brings to you.
220+
221+
License
222+
-------
223+
224+
MIT License (MIT). See [License File](LICENSE.md) for more information.

bin/composer

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
3+
if which greadlink > /dev/null 2>&1; then
4+
alias readlink=greadlink
5+
fi
6+
7+
currentfolder="$(pwd)"
8+
9+
cd "$(dirname "$(dirname "$(readlink -f "$0")")../")"
10+
11+
# we need some configuration
12+
if [ -e .env ]; then
13+
. "$(pwd)/.env"
14+
elif [ -e .env-sample ]; then
15+
. "$(pwd)/.env-sample"
16+
else
17+
echo "no config found"
18+
exit 1
19+
fi
20+
21+
. share/init
22+
23+
docker run -it --rm \
24+
-v "$HOME/.ssh":/var/www/.ssh \
25+
-v "$HOME/.composer":/var/www/.composer \
26+
-v "$currentfolder":/phpapp \
27+
-e DEVELOPMENT="$DEVELOPMENT" \
28+
-e C_UID=$C_UID \
29+
-e C_GID=$C_GID \
30+
dockerwest/php-symfony:$PHPVERSION \
31+
composer "$@"

bin/create_db

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env sh
2+
3+
if which greadlink > /dev/null 2>&1; then
4+
alias readlink=greadlink
5+
fi
6+
7+
currentfolder="$(pwd)"
8+
9+
cd "$(dirname "$(dirname "$(readlink -f "$0")")../")"
10+
11+
# we need some configuration
12+
if [ -e .env ]; then
13+
. "$(pwd)/.env"
14+
elif [ -e .env-sample ]; then
15+
. "$(pwd)/.env-sample"
16+
else
17+
echo "no config found"
18+
exit 1
19+
fi
20+
21+
bin/mysql -e "CREATE DATABASE $1 DEFAULT CHARSET utf8mb4"

bin/mysql

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env sh
2+
3+
if which greadlink > /dev/null 2>&1; then
4+
alias readlink=greadlink
5+
fi
6+
7+
currentfolder="$(pwd)"
8+
9+
cd "$(dirname "$(dirname "$(readlink -f "$0")")../")"
10+
11+
# we need some configuration
12+
if [ -e .env ]; then
13+
. "$(pwd)/.env"
14+
elif [ -e .env-sample ]; then
15+
. "$(pwd)/.env-sample"
16+
else
17+
echo "no config found"
18+
exit 1
19+
fi
20+
21+
# running env?
22+
running=$(run ps | grep Up | wc -l)
23+
if [ $running -gt 0 ]; then
24+
bin/run exec -T mysql mysql -uroot -p"$MYSQL_ROOT_PASSWORD" "$@"
25+
else
26+
echo "mysql requires a running mysql server"
27+
fi

0 commit comments

Comments
 (0)