Skip to content

Commit 78b85e8

Browse files
committed
feat: git config ans ssh keys mounted in PHP containers
1 parent 3f7c06d commit 78b85e8

File tree

6 files changed

+56
-9
lines changed

6 files changed

+56
-9
lines changed

README.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,56 @@
11
# Dev Compose
22

3-
docker-compose development environment for PHP.
3+
## Environment
4+
5+
Docker Compose development environment for PHP.
46

57
- Apache 2
6-
- PHP 7.4 via php-fpm
7-
- PHP 8.0 via php-fpm
8-
- PHP 8.1 via php-fpm
9-
- Mysql 8.0
8+
- PHP 8.3 via php-fpm
9+
- PHP 8.4 via php-fpm
10+
- Mysql 9
11+
- Postgresql 17
12+
- Mongodb + Express
13+
- Memcached
14+
- Redis
1015

11-
```
16+
The environment mounts the `~/html` directory in container's `/var/www/html`, also the `.gitconfig` anche `.ssh` directory from the user's home.
17+
18+
## PHP tools
19+
20+
Inside the container are installed
21+
22+
- phpstan
23+
- PHP CS Fixer
24+
- Composer
25+
- PhpUnit
26+
- Infection
27+
- phpDocumentor
28+
29+
All tools above are available from every location in filesystem. phpDocumentor is named `php-doc`.
30+
31+
## Use the stack
32+
33+
```bash
1234
git clone https://github.com/s3b4stian/dev-compose.git
1335
```
1436

1537
Before all need to build the environment
16-
```
38+
```bash
1739
./build.sh
1840
```
1941

2042
And finally start all
21-
```
43+
```bash
2244
./up.sh
2345
```
2446

25-
To stop all containers
47+
To enter in development environment
48+
```bash
49+
./exec.sh
2650
```
51+
52+
To stop all containers
53+
```bash
2754
./down.sh
2855
```
2956

docker-compose.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ services:
88
restart: always
99
volumes:
1010
- "/home/__CURRENT_USER__/html:/var/www/html"
11+
- "/home/__CURRENT_USER__/.ssh:/home/ubuntu/.ssh"
12+
- "/home/__CURRENT_USER__/.gitconfig:/home/ubuntu/.gitconfig"
1113
dev_php_83:
1214
container_name: dev_phpfpm_83
1315
hostname: php83-dev-container
@@ -17,6 +19,8 @@ services:
1719
restart: always
1820
volumes:
1921
- "/home/__CURRENT_USER__/html:/var/www/html"
22+
- "/home/__CURRENT_USER__/.ssh:/home/ubuntu/.ssh"
23+
- "/home/__CURRENT_USER__/.gitconfig:/home/ubuntu/.gitconfig"
2024
dev_apache:
2125
container_name: dev_apache
2226
hostname: apache-dev-container

php8.3/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils curl git sudo m
1212
php8.3-msgpack php8.3-igbinary php8.3-memcached php8.3-pgsql php8.3-mongodb php8.3-redis && \
1313
apt-get clean && rm -rf /var/lib/apt/lists/*
1414

15+
## set ubuntu user password
16+
RUN echo "ubuntu:ubuntu" | chpasswd
17+
1518
## Create required dirs
1619
RUN mkdir -p /run/php/ && mkdir /php_tools
1720

php8.3/tools/install-php-tools.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ rm /tmp/php_tools/*
1414
## ------------------
1515
printf "${RED}Download PHP tools${NC}\n"
1616

17+
### PHP stan
18+
curl https://api.github.com/repos/phpstan/phpstan/releases/latest | grep "phpstan.phar" | cut -d : -f 2,3 | tr -d \" | head -n 2 | tail -n 1 | wget -i - -P /tmp/php_tools
1719
### PHP cs Fixer
1820
#wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/$VER_CS_FIXER/php-cs-fixer.phar -P /tmp/php_tools
1921
curl -sL https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/releases/latest | grep "php-cs-fixer.phar" | cut -d : -f 2,3 | tr -d \" | head -n 2 | tail -n 1 | wget -i - -P /tmp/php_tools
@@ -34,12 +36,14 @@ printf "${RED}Make all executable${NC}\n"
3436

3537
cd /tmp/php_tools
3638

39+
mv phpstan.phar phpstan
3740
mv php-cs-fixer.phar php-cs-fixer
3841
mv composer-stable.phar composer
3942
mv phpunit.phar phpunit
4043
mv infection.phar infection
4144
mv phpDocumentor.phar php-doc
4245

46+
chmod +x phpstan
4347
chmod +x php-cs-fixer
4448
chmod +x composer
4549
chmod +x phpunit
@@ -63,6 +67,7 @@ sudo cp /tmp/php_tools/* /usr/local/sbin
6367
# make link to permit the compressed phar to work
6468
#sudo ln -s /usr/local/sbin/php-doc.phar php-doc
6569

70+
phpstan --version
6671
PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer --version
6772
composer --version
6873
phpunit --version

php8.4/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils curl git sudo m
1212
php8.4-msgpack php8.4-igbinary php8.4-memcached php8.4-pgsql php8.4-mongodb php8.4-redis && \
1313
apt-get clean && rm -rf /var/lib/apt/lists/*
1414

15+
## set ubuntu user password
16+
RUN echo "ubuntu:ubuntu" | chpasswd
17+
1518
## Create required dirs
1619
RUN mkdir -p /run/php/ && mkdir /php_tools
1720

php8.4/tools/install-php-tools.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ rm /tmp/php_tools/*
1414
## ------------------
1515
printf "${RED}Download PHP tools${NC}\n"
1616

17+
### PHP stan
18+
curl https://api.github.com/repos/phpstan/phpstan/releases/latest | grep "phpstan.phar" | cut -d : -f 2,3 | tr -d \" | head -n 2 | tail -n 1 | wget -i - -P /tmp/php_tools
1719
### PHP cs Fixer
1820
#wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/$VER_CS_FIXER/php-cs-fixer.phar -P /tmp/php_tools
1921
curl -sL https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/releases/latest | grep "php-cs-fixer.phar" | cut -d : -f 2,3 | tr -d \" | head -n 2 | tail -n 1 | wget -i - -P /tmp/php_tools
@@ -34,12 +36,14 @@ printf "${RED}Make all executable${NC}\n"
3436

3537
cd /tmp/php_tools
3638

39+
mv phpstan.phar phpstan
3740
mv php-cs-fixer.phar php-cs-fixer
3841
mv composer-stable.phar composer
3942
mv phpunit.phar phpunit
4043
mv infection.phar infection
4144
mv phpDocumentor.phar php-doc
4245

46+
chmod +x phpstan
4347
chmod +x php-cs-fixer
4448
chmod +x composer
4549
chmod +x phpunit
@@ -63,6 +67,7 @@ sudo cp /tmp/php_tools/* /usr/local/sbin
6367
# make link to permit the compressed phar to work
6468
#sudo ln -s /usr/local/sbin/php-doc.phar php-doc
6569

70+
phpstan --version
6671
PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer --version
6772
composer --version
6873
phpunit --version

0 commit comments

Comments
 (0)