-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
121 lines (116 loc) · 3.21 KB
/
docker-compose.yml
File metadata and controls
121 lines (116 loc) · 3.21 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
110
111
112
113
114
115
116
117
118
119
120
121
# Define custom Docker networks
networks:
project-network:
# Define services for the application
services:
# PHP service configuration
php:
build:
# Path to the build context
context: .
# Dockerfile for PHP
dockerfile: docker/php/Dockerfile
# Image name
image: php83-fpm-alpine
# Name of the container
container_name: php
# Restart policy
restart: unless-stopped
# Set the working directory inside the container
working_dir: /app
volumes:
# Bind the project directory to the container
- ./project:/app
# Exclude Composer's vendor directory for performance boosting
- /app/vendor
# Map PHP logs to the host system for debugging
- ./logs/php:/var/log/php
# Environment variable for application configuration
environment:
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_PORT: ${POSTGRES_PORT}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
# Attach to the custom network
networks:
- project-network
# Update Composer dependencies and start PHP-FPM
command: sh -c "composer update && php-fpm"
# Nginx service configuration
nginx:
build:
# Path to the build context
context: .
# Dockerfile for Nginx
dockerfile: docker/nginx/Dockerfile
# Image name
image: nginx-alpine
# Name of the container
container_name: nginx
# Restart policy
restart: unless-stopped
# Map container port 80 to host port 8000
ports:
- "${NGINX_PORT}:80"
volumes:
# Bind the project directory to the container
- ./project:/app
# Map Nginx logs to the host system for debugging
- ./logs/nginx:/var/log/nginx
# Ensure the PHP service starts first
depends_on:
- php
# Attach to the custom network
networks:
- project-network
# Postgres database configuration
postgres:
build:
# Path to the build context
context: .
# Dockerfile for PostgreSQL
dockerfile: docker/postgres/Dockerfile
# Image name
image: postgres:17-alpine
# Container name
container_name: postgres
# Restart policy
restart: unless-stopped
# Mounted volumes
volumes:
# Storage for PostgreSQL data on the host
- ./data/postgres:/var/lib/postgresql/data
# Logs PostgreSQL
- ./logs/postgres:/var/log/postgresql
# Environment variables
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
PGDATA: ${POSTGRES_PGDATA}
ports:
- "${POSTGRES_PORT}:5432"
# Connection to the database
networks:
- project-network
# pgAdmin configuration
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
# Restart policy
restart: unless-stopped
ports:
- "${PGADMIN_PORT}:80"
# Environment variables
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
# Mounted volumes
volumes:
- ./data/pgadmin:/var/lib/pgadmin
# Depends on Postgres database container
depends_on:
- postgres
networks:
- project-network