Skip to content

Commit 50a8f49

Browse files
committed
updated docker with variables and other changes
1 parent bbc0704 commit 50a8f49

File tree

5 files changed

+112
-21
lines changed

5 files changed

+112
-21
lines changed

docker-compose.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,36 @@ version: '3'
22

33
services:
44
fpm:
5-
build: php${PHP_VERSION}/fpm
6-
depends_on:
7-
- mariadb
8-
- redis
5+
build:
6+
context: php${PHP_VERSION}/fpm
7+
args:
8+
PHP_ENABLE_REDIS: ${PHP_ENABLE_REDIS}
9+
PHP_ENABLE_XDEBUG: ${PHP_ENABLE_XDEBUG}
10+
PHP_ENABLE_MONGODB: ${PHP_ENABLE_MONGODB}
11+
ports:
12+
- ${PHP_FPM_PORT}:9000
913
volumes:
1014
- ./project:/var/www/project
15+
depends_on:
16+
- mariadb
17+
# - mongodb
18+
# - redis
1119

1220
cli:
1321
build:
1422
context: php${PHP_VERSION}/cli
1523
args:
1624
NODE_VERSION: ${NODE_VERSION}
25+
PHP_ENABLE_REDIS: ${PHP_ENABLE_REDIS}
26+
PHP_ENABLE_XDEBUG: ${PHP_ENABLE_XDEBUG}
27+
PHP_ENABLE_MONGODB: ${PHP_ENABLE_MONGODB}
1728
working_dir: /var/www/project
1829
volumes:
1930
- ./project:/var/www/project
2031
depends_on:
2132
- mariadb
22-
- redis
33+
# - mongodb
34+
# - redis
2335

2436
nginx:
2537
image: nginx:alpine
@@ -28,11 +40,10 @@ services:
2840
volumes:
2941
- ./project:/var/www/project
3042
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:cached
43+
environment:
44+
- PHP_FPM_PORT=${PHP_FPM_PORT}
3145
depends_on:
3246
- fpm
33-
34-
redis:
35-
image: redis:alpine
3647

3748
mariadb:
3849
image: mariadb:${MARIADB_VERSION}
@@ -56,3 +67,21 @@ services:
5667
- mariadb
5768
ports:
5869
- ${PHPMYADMIN_PORT}:80
70+
71+
# mongodb:
72+
# image: mongo:${MONGODB_VERSION}
73+
# ports:
74+
# - ${MONGODB_PORT}:27017
75+
# environment:
76+
# MONGO_INITDB_ROOT_USERNAME: ${MONGODB_ROOT_USERNAME}
77+
# MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_ROOT_PASSWORD}
78+
# volumes:
79+
# - ./data/mongodb:/data/db
80+
81+
# redis:
82+
# image: redis:alpine
83+
84+
mailcatcher:
85+
image: sj26/mailcatcher
86+
ports:
87+
- ${MAILCATCHER_PORT}:1080

php7.4/cli/Dockerfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
FROM php:7.4-cli
22

3-
MAINTAINER ReadyMadeHost
4-
5-
ARG NODE_VERSION
6-
ENV NODE_VERSION ${NODE_VERSION}
3+
LABEL maintainer="ReadyMadeHost http://readymadehost.com"
74

85
# Installing required packages
96
RUN apt-get update && apt-get upgrade -y
@@ -36,10 +33,15 @@ RUN docker-php-ext-install \
3633
opcache \
3734
gd
3835

39-
# Installing others dependencies
36+
RUN pecl install apcu
37+
RUN docker-php-ext-enable apcu
38+
39+
# Installing other extensions but enabled dynamically
4040
RUN pecl install redis
41-
RUN docker-php-ext-enable redis
42-
# RUN pecl install mongodb-1.8.0
41+
# RUN docker-php-ext-enable redis
42+
RUN pecl install xdebug
43+
# RUN docker-php-ext-enable xdebug
44+
RUN pecl install mongodb
4345
# RUN docker-php-ext-enable mongodb
4446

4547
# Updating php.ini
@@ -53,6 +55,9 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
5355
RUN wget https://get.symfony.com/cli/installer -O - | bash
5456
RUN echo 'export PATH="$HOME/.symfony/bin:$PATH"' >> ~/.bashrc
5557

58+
ARG NODE_VERSION
59+
ENV NODE_VERSION ${NODE_VERSION}
60+
5661
# Installing node
5762
RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
5863
RUN apt-get -y install nodejs
@@ -63,7 +68,15 @@ ADD manage-project-permission.sh /root/manage-project-permission.sh
6368
RUN chmod +x /root/manage-project-permission.sh
6469
RUN echo 'alias mpp="/root/manage-project-permission.sh"' >> /root/.bashrc
6570
RUN /root/manage-project-permission.sh
71+
72+
ARG PHP_ENABLE_REDIS
73+
ENV PHP_ENABLE_REDIS ${PHP_ENABLE_REDIS}
74+
ARG PHP_ENABLE_XDEBUG
75+
ENV PHP_ENABLE_XDEBUG ${PHP_ENABLE_XDEBUG}
76+
ARG PHP_ENABLE_MONGODB
77+
ENV PHP_ENABLE_MONGODB ${PHP_ENABLE_MONGODB}
78+
6679
ADD docker-entrypoint.sh /root/docker-entrypoint.sh
6780
RUN chmod +x /root/docker-entrypoint.sh
6881

69-
CMD ["/root/docker-entrypoint.sh"]
82+
CMD ["/root/docker-entrypoint.sh", "bash"]

php7.4/cli/docker-entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,19 @@
22

33
/root/manage-project-permission.sh
44

5+
if [ ${PHP_ENABLE_REDIS} -eq "1" ]; then
6+
docker-php-ext-enable redis
7+
echo "-- php cli redis extension enabled"
8+
fi
9+
10+
if [ ${PHP_ENABLE_XDEBUG} -eq "1" ]; then
11+
docker-php-ext-enable xdebug
12+
echo "-- php cli xdebug extension enabled"
13+
fi
14+
15+
if [ ${PHP_ENABLE_MONGODB} -eq "1" ]; then
16+
docker-php-ext-enable mongodb
17+
echo "-- php cli mongodb extension enabled"
18+
fi
19+
520
tail -f /dev/null

php7.4/fpm/Dockerfile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM php:7.4-fpm
22

3-
MAINTAINER ReadyMadeHost
3+
LABEL maintainer="ReadyMadeHost http://readymadehost.com"
44

55
# Installing required packages
66
RUN apt-get update && apt-get upgrade -y
@@ -26,13 +26,29 @@ RUN docker-php-ext-install \
2626
opcache \
2727
gd
2828

29-
# Installing others dependencies
29+
RUN pecl install apcu
30+
RUN docker-php-ext-enable apcu
31+
32+
# Installing other extensions but enabled dynamically
3033
RUN pecl install redis
31-
RUN docker-php-ext-enable redis
32-
# RUN pecl install mongodb-1.8.0
34+
# RUN docker-php-ext-enable redis
35+
RUN pecl install xdebug
36+
# RUN docker-php-ext-enable xdebug
37+
RUN pecl install mongodb
3338
# RUN docker-php-ext-enable mongodb
3439

3540
# Updating php.ini
3641
ADD conf/php.ini /usr/local/etc/php/php.ini
3742

38-
CMD ["php-fpm", "-F"]
43+
ARG PHP_ENABLE_REDIS
44+
ENV PHP_ENABLE_REDIS ${PHP_ENABLE_REDIS}
45+
ARG PHP_ENABLE_XDEBUG
46+
ENV PHP_ENABLE_XDEBUG ${PHP_ENABLE_XDEBUG}
47+
ARG PHP_ENABLE_MONGODB
48+
ENV PHP_ENABLE_MONGODB ${PHP_ENABLE_MONGODB}
49+
50+
# Add scripts
51+
ADD docker-entrypoint.sh /root/docker-entrypoint.sh
52+
RUN chmod +x /root/docker-entrypoint.sh
53+
54+
CMD ["/root/docker-entrypoint.sh", "php-fpm", "-F"]

php7.4/fpm/docker-entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ ${PHP_ENABLE_REDIS} -eq "1" ]; then
4+
docker-php-ext-enable redis
5+
echo "-- php fpm redis extension enabled"
6+
fi
7+
8+
if [ ${PHP_ENABLE_XDEBUG} -eq "1" ]; then
9+
docker-php-ext-enable xdebug
10+
echo "-- php fpm xdebug extension enabled"
11+
fi
12+
13+
if [ ${PHP_ENABLE_MONGODB} -eq "1" ]; then
14+
docker-php-ext-enable mongodb
15+
echo "-- php fpm mongodb extension enabled"
16+
fi
17+
18+
exec "$@"

0 commit comments

Comments
 (0)