You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once you clone this respository, it comes with default index.php in docroot folder. Inside this docroot, you can replace it with your existing project codebase. For example, I have added drupal8 codebase that looks like below:
192
190
```
@@ -212,6 +210,169 @@ Once you clone this respository, it comes with default index.php in docroot fold
212
210
└── php
213
211
└── Dockerfile
214
212
```
213
+
## Docker Files Explanation
214
+
Docker files define a sets of services which make up an entire application. It allows you to define the dependencies for those services, networks and volumes etc.
215
+
216
+
#### docker-compose.yml
217
+
```
218
+
version: "3.2"
219
+
services:
220
+
php:
221
+
build:
222
+
context: './php/'
223
+
args:
224
+
PHP_VERSION: ${PHP_VERSION}
225
+
networks:
226
+
- backend
227
+
volumes:
228
+
- ${PROJECT_ROOT}/:/var/www/html/
229
+
container_name: php
230
+
apache:
231
+
build:
232
+
context: './apache/'
233
+
args:
234
+
APACHE_VERSION: ${APACHE_VERSION}
235
+
depends_on:
236
+
- php
237
+
- mysql
238
+
networks:
239
+
- frontend
240
+
- backend
241
+
ports:
242
+
- "80:80"
243
+
volumes:
244
+
- ${PROJECT_ROOT}/:/var/www/html/
245
+
container_name: apache
246
+
mysql:
247
+
image: mysql:${MYSQL_VERSION:-latest}
248
+
restart: always
249
+
ports:
250
+
- "3306:3306"
251
+
volumes:
252
+
- data:/var/lib/mysql
253
+
networks:
254
+
- backend
255
+
environment:
256
+
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
257
+
MYSQL_DATABASE: "${DB_NAME}"
258
+
MYSQL_USER: "${DB_USERNAME}"
259
+
MYSQL_PASSWORD: "${DB_PASSWORD}"
260
+
container_name: mysql
261
+
networks:
262
+
frontend:
263
+
backend:
264
+
volumes:
265
+
data:
266
+
267
+
```
268
+
Here version is Docker version. It has php, apache and mysql services. To avoid any custom image for PHP and apache, we are using context here to define the PHP & Apache dockerfile separately. In case of Mysql, we are directly downloading the MySql image because MySql container doesn't require any special library or configuration. You may create a separate Dockerfile for MySql if it's required in your case.
269
+
270
+
#### Apache Dockerfile
271
+
```
272
+
ARG APACHE_VERSION=""
273
+
FROM httpd:${APACHE_VERSION:+${APACHE_VERSION}-}alpine
274
+
275
+
RUN apk update; \
276
+
apk upgrade;
277
+
278
+
# Copy apache vhost file to proxy php requests to php-fpm container
It downloads the php image for the version defined in `.env` file. In our case, it's `7.3`. You can change it as per your requirements. Also, I have added all the minimal PHP libraries along with Composer and Drush to ensure we don't face any issue with core Drupal 8. You may add/update/delete any library in PHP dockerfile as per your requirements.
0 commit comments