-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
109 lines (103 loc) · 3.97 KB
/
docker-compose.yml
File metadata and controls
109 lines (103 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# CodeIgniter 4 Project Docker Configuration
# ==========================================
#
# This Docker Compose file orchestrates a Docker environment suitable for developing
# and running a CodeIgniter 4 application. It sets up the following services:
#
# 1. App - The main application service running PHP and the CodeIgniter framework.
# 2. Nginx - A web server to serve the CodeIgniter application.
# 3. MySQL - A database server for the application's data persistence.
# 4. Redis - A key-value store used for caching and session storage to enhance performance.
# 5. Adminer - A database management tool accessible via a web interface for managing the MySQL database.
#
# Each service is configured to meet the development needs of a typical CodeIgniter 4 application,
# ensuring that developers can work on the application in an environment that mirrors
# production settings as closely as possible. This setup also facilitates easy sharing of
# the development environment among team members, ensuring consistency across development setups.
#
# Usage:
# ------
# To start the entire stack, run: `docker-compose up -d`
# This will build and start all the defined services in detached mode.
#
# To stop the services, run: `docker-compose down`
# This command stops and removes all running containers defined in this file.
#
# Service Details:
# ----------------
# - `app`: This service uses a custom Dockerfile located in `./docker/ci4`. It's set up to run PHP applications,
# particularly tailored for the CodeIgniter framework. The project directory is mounted into the container
# to allow live editing of the application code.
#
# - `nginx`: Configured as the web server for the application. It uses the official Nginx image and forwards
# requests to the PHP application running in the `app` service. Custom Nginx configurations can be applied
# by modifying `./docker/nginx/nginx.conf`.
#
# - `mysql`: This service runs a MySQL database server, version 5.7. It's used for the application's data storage.
# The service is configured with environment variables to set the root password and create a default database
# upon initialization.
#
# - `redis`: Utilizes the latest Redis image to provide caching and session storage capabilities. It's accessible
# by the application through the network, enhancing performance by storing session and cache data in memory.
#
# - `adminer`: A lightweight database management tool that provides a web interface for managing MySQL databases.
# It's useful for development and debugging purposes.
#
# Network Configuration:
# ----------------------
# All services are connected via a custom bridge network named `app-network`. This setup ensures that services
# can communicate with each other using service names as hostnames, thereby simplifying configuration and connectivity.
#
# Volumes:
# --------
# - `mysql-data`: A named volume for persisting MySQL data. This ensures that the database data remains
# intact across container restarts and rebuilds.
#
# Note: Modify the service configurations as per your project requirements. Ensure that any sensitive or
# environment-specific variables are appropriately managed, ideally through a `.env` file or Docker secrets.
#
version: '3.8'
services:
app:
build:
context: ./docker/ci4
volumes:
- .:/var/www/html
depends_on:
- mysql
environment:
CI_ENVIRONMENT: development
networks:
- app-network
nginx:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./public:/var/www/html/public
- ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
networks:
- app-network
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: ci4
MYSQL_ROOT_PASSWORD: root
redis:
image: redis:latest
ports:
- "6379:6379"
networks:
- app-network
adminer:
image: adminer
restart: always
ports:
- 8081:8080
networks:
app-network:
driver: bridge
volumes:
mysql-data: