Skip to content

Commit edc8871

Browse files
author
Jovert Lota Palonpon
committed
Multi environment Docker configuration, resolve #35
1 parent 9b02283 commit edc8871

File tree

5 files changed

+66
-34
lines changed

5 files changed

+66
-34
lines changed

.docker/php-fpm/Dockerfile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
FROM php:7.3-fpm
22

3-
# Environment Variables
43
ENV MASTER_TZ=Asia/Manila
54
ENV MASTER_DIR=/var/www/html
65

76
RUN ln -snf /usr/share/zoneinfo/${MASTER_TZ} /etc/localtime && echo ${MASTER_TZ} > /etc/timezone
87

9-
# Install dependencies
108
RUN apt-get update && apt-get install -y \
119
build-essential \
1210
libzip-dev \
@@ -21,15 +19,15 @@ RUN apt-get update && apt-get install -y \
2119
git \
2220
curl
2321

24-
# Clear cache
2522
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
2623

27-
# Install PHP extensions
2824
RUN docker-php-ext-install bcmath pdo_mysql mbstring zip exif pcntl && \
2925
docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ && \
3026
docker-php-ext-install gd
3127

32-
# Install composer
28+
# This will override default PHP configuration
29+
COPY .docker/php-fpm/php.ini /usr/local/etc/php/conf.d/local.ini:ro
30+
3331
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
3432

3533
# This will allow the container to use a cached version of PHP packages
@@ -38,19 +36,13 @@ COPY composer.lock composer.json ${MASTER_DIR}/
3836
# This is included just to bypass errors thrown by composer scripts
3937
COPY database ${MASTER_DIR}/database
4038

41-
WORKDIR ${MASTER_DIR}
42-
43-
# Install app dependencies
4439
RUN composer install --no-interaction --no-plugins --no-scripts
4540

46-
# Copy app
4741
COPY . ${MASTER_DIR}
48-
49-
# Copy scripts
5042
COPY ./.docker/scripts/queuer.sh /usr/local/bin/laravel-queuer
5143
COPY ./.docker/scripts/scheduler.sh /usr/local/bin/laravel-scheduler
5244

53-
# Give the scripts executable permissions
45+
RUN chmod -R 775 /var/www/html/storage
5446
RUN chmod u+x /usr/local/bin/laravel-queuer
5547
RUN chmod u+x /usr/local/bin/laravel-scheduler
5648

.docker/webserver/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM nginx:alpine
2+
3+
COPY .docker/webserver/nginx.conf /etc/nginx/conf.d/nginx.conf
4+
5+
COPY . /var/www/html

docker-compose.dev.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3'
2+
services:
3+
php-fpm:
4+
volumes:
5+
- ./:/var/www/html
6+
- ./.docker/php-fpm/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
7+
environment:
8+
APP_ENV: 'development'
9+
10+
scheduler:
11+
volumes:
12+
- ./:/var/www/html
13+
14+
queuer:
15+
volumes:
16+
- ./:/var/www/html
17+
18+
webserver:
19+
ports:
20+
- '80:80'
21+
- '443:443'
22+
volumes:
23+
- ./:/var/www/html
24+
- .docker/webserver/nginx.conf:/etc/nginx/conf.d/nginx.conf
25+
26+
db:
27+
ports:
28+
- '3306:3306'
29+
environment:
30+
MYSQL_DATABASE: laravel-react-admin
31+
MYSQL_ROOT_PASSWORD: secret
32+
volumes:
33+
- ~/.laravel-react-admin-data:/var/lib/mysql

docker-compose.prod.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3'
2+
services:
3+
php-fpm:
4+
environment:
5+
APP_ENV: 'production'
6+
7+
webserver:
8+
ports:
9+
- '80:80'
10+
- '443:443'
11+
12+
db:
13+
ports:
14+
- '3306:3306'
15+
environment:
16+
MYSQL_DATABASE: laravel-react-admin
17+
MYSQL_ROOT_PASSWORD: secret
18+
volumes:
19+
- ~/.laravel-react-admin-data:/var/lib/mysql

docker-compose.yml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ services:
66
dockerfile: ./.docker/php-fpm/Dockerfile
77
image: laravel-react-admin-php-fpm
88
container_name: laravel-react-admin-php-fpm
9-
restart: unless-stopped
109
working_dir: /var/www/html
11-
volumes:
12-
- ./:/var/www/html
13-
- ./.docker/php-fpm/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
10+
restart: unless-stopped
1411
env_file:
1512
- .env
1613

1714
scheduler:
1815
image: laravel-react-admin-php-fpm
1916
container_name: laravel-react-admin-scheduler
20-
volumes:
21-
- ./:/var/www/html
2217
depends_on:
2318
- php-fpm
2419
command: laravel-scheduler
@@ -28,37 +23,25 @@ services:
2823
queuer:
2924
image: laravel-react-admin-php-fpm
3025
container_name: laravel-react-admin-queuer
31-
volumes:
32-
- ./:/var/www/html
3326
depends_on:
3427
- php-fpm
3528
command: laravel-queuer
3629
env_file:
3730
- .env
3831

3932
webserver:
40-
image: nginx:alpine
33+
build:
34+
context: .
35+
dockerfile: ./.docker/webserver/Dockerfile
4136
container_name: laravel-react-admin-webserver
37+
working_dir: /var/www/html
4238
restart: unless-stopped
43-
ports:
44-
- '80:80'
45-
- '443:443'
46-
volumes:
47-
- ./:/var/www/html
48-
- ./.docker/webserver/nginx.conf:/etc/nginx/conf.d/nginx.conf
4939
depends_on:
5040
- php-fpm
5141

5242
db:
5343
image: mysql:5.7
5444
container_name: laravel-react-admin-db
5545
restart: unless-stopped
56-
ports:
57-
- '3306:3306'
58-
environment:
59-
MYSQL_DATABASE: laravel-react-admin
60-
MYSQL_ROOT_PASSWORD: secret
61-
volumes:
62-
- ~/.laravel-react-admin-data:/var/lib/mysql
6346
depends_on:
6447
- php-fpm

0 commit comments

Comments
 (0)