Skip to content

Commit a79997a

Browse files
committed
Update docker-compose.yml
1 parent b252cb5 commit a79997a

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

docker-compose.yml

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ services:
44

55
laravel:
66
depends_on:
7-
- database
8-
image: '${PHP_IMAGE_NAME}'
7+
database:
8+
condition: service_healthy
9+
image: ${PHP_IMAGE_NAME}
910
container_name: laravel
1011
networks:
1112
- backend
@@ -28,32 +29,32 @@ services:
2829
- database
2930
- redis
3031
healthcheck:
31-
test: ["CMD-SHELL", "curl -fk https://${DOMAIN_NAME} || exit 1"]
32-
interval: 10s
32+
test: ["CMD-SHELL", "/bin/pidof php-fpm > /dev/null || exit 1"]
33+
interval: 5s
3334
timeout: 5s
34-
retries: 6
35-
start_period: 60s
35+
retries: 50
3636
environment:
3737
TZ: '${LOCAL_TIMEZONE}'
38-
labels:
38+
labels:
3939
- 'docker-volume-backup.stop-during-backup=true'
40-
command: >
41-
bash -c "apt-get -y update && sh /tmp/packagecheck.sh 'zip unzip' && curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s intl pdo_mysql && pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
42-
if [ -f \"${WEBSERVER_DOC_ROOT}/webapp/.env\" ]; then composer update --working-dir=${WEBSERVER_DOC_ROOT}/webapp; else composer create-project laravel/laravel webapp && chmod -R 777 ${WEBSERVER_DOC_ROOT}/webapp/storage/framework ${WEBSERVER_DOC_ROOT}/webapp/storage/logs; fi;
43-
sed -i \"s/DB_HOST=127.0.0.1/DB_HOST=database/;s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/\" ${WEBSERVER_DOC_ROOT}/webapp/.env; grep -qe 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini; php-fpm"
40+
command: >
41+
bash -c "apt-get update && sh /tmp/packagecheck.sh 'zip unzip' && curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s intl pdo_mysql && if pecl install -p -- redis; then pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis; fi; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
42+
if [ -f \"${WEBSERVER_DOC_ROOT}/.env\" ]; then composer update --working-dir=${WEBSERVER_DOC_ROOT}; else rm -f ${WEBSERVER_DOC_ROOT}/README.md && composer create-project laravel/laravel . --working-dir=${WEBSERVER_DOC_ROOT} && chmod -R 777 ${WEBSERVER_DOC_ROOT}/storage/framework ${WEBSERVER_DOC_ROOT}/storage/logs; fi;
43+
sed -i \"s/DB_HOST=127.0.0.1/DB_HOST=database/;s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/\" ${WEBSERVER_DOC_ROOT}/.env; grep -qe 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini; php-fpm"
4444
4545
webserver:
4646
depends_on:
47-
- laravel
48-
image: 'httpd:latest'
47+
laravel:
48+
condition: service_healthy
49+
image: httpd:latest
4950
container_name: webserver
5051
networks:
51-
- backend
52+
- backend
5253
volumes:
5354
- 'html:${WEBSERVER_DOC_ROOT}'
5455
- type: bind
5556
source: ./webserver
56-
target: '${HTTPD_PREFIX}/conf'
57+
target: '${HTTPD_PREFIX}/conf'
5758
hostname: webserver
5859
restart: unless-stopped
5960
ports:
@@ -63,19 +64,24 @@ services:
6364
environment:
6465
TZ: '${LOCAL_TIMEZONE}'
6566
command: bash -c "sed -i 's/example.com/${DOMAIN_NAME}/g' ${HTTPD_PREFIX}/conf/extra/httpd-vhosts.conf && httpd -t; httpd-foreground"
66-
67+
6768
certbot:
6869
depends_on:
6970
- proxy
70-
image: certbot/certbot
71+
image: certbot/certbot:latest
7172
container_name: certbot
7273
networks:
7374
- backend
7475
volumes:
7576
- 'certbot-etc:${LETSENCRYPT_CONF_PREFIX}'
7677
- 'certbot-var:/var/lib/letsencrypt'
77-
- '/tmp/acme-challenge:/tmp/acme-challenge'
78-
restart: unless-stopped
78+
- '/tmp/acme-challenge:/tmp/acme-challenge'
79+
restart: unless-stopped
80+
healthcheck:
81+
test: ["CMD-SHELL", "test -d ${LETSENCRYPT_CONF_PREFIX}/live/${DOMAIN_NAME} || exit 1"]
82+
interval: 5s
83+
timeout: 5s
84+
retries: 20
7985
environment:
8086
TZ: '${LOCAL_TIMEZONE}'
8187
entrypoint: /bin/sh -c "certbot certonly --webroot --webroot-path /tmp/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email ${LETSENCRYPT_EMAIL} -d ${DOMAIN_NAME} -d www.${DOMAIN_NAME};
@@ -119,16 +125,17 @@ services:
119125

120126
phpmyadmin:
121127
depends_on:
122-
- certbot
123-
image: phpmyadmin/phpmyadmin
128+
certbot:
129+
condition: service_healthy
130+
image: phpmyadmin:latest
124131
container_name: phpmyadmin
125132
networks:
126133
- backend
127134
- frontend
128135
volumes:
129136
- type: bind
130137
source: ./phpmyadmin/apache2/sites-available/default-ssl.conf
131-
target: '${APACHE_CONFDIR_PREFIX}/sites-available/default-ssl.conf'
138+
target: '${APACHE_CONFDIR_PREFIX}/sites-available/default-ssl.conf'
132139
- type: bind
133140
source: ./phpmyadmin/apache2/ports.conf
134141
target: '${APACHE_CONFDIR_PREFIX}/ports.conf'
@@ -163,9 +170,9 @@ services:
163170
mkdir -p ${WEBSERVER_DOC_ROOT}/../upload && chown www-data:www-data ${WEBSERVER_DOC_ROOT}/../upload && chmod a+w ${WEBSERVER_DOC_ROOT}/../upload; mkdir -p ${WEBSERVER_DOC_ROOT}/../save && chown www-data:www-data ${WEBSERVER_DOC_ROOT}/../save && chmod a+w ${WEBSERVER_DOC_ROOT}/../save;
164171
grep -qxF 'ServerName 127.0.0.1' ${APACHE_CONFDIR_PREFIX}/apache2.conf || echo -e '\\nServerName 127.0.0.1' >> ${APACHE_CONFDIR_PREFIX}/apache2.conf; grep -qe 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini;
165172
a2enmod ssl && a2ensite default-ssl && a2dissite 000-default && /docker-entrypoint.sh 'apache2-foreground'"
166-
173+
167174
database:
168-
image: '${DATABASE_IMAGE_NAME}:${DATABASE_VERSION}'
175+
image: ${DATABASE_IMAGE_NAME}:${DATABASE_VERSION}
169176
container_name: database
170177
networks:
171178
- backend
@@ -180,6 +187,11 @@ services:
180187
restart: unless-stopped
181188
ports:
182189
- '3306:3306'
190+
healthcheck:
191+
test: ["CMD-SHELL", "${DATABASE_ADMIN_COMMANDLINE} ping --silent || exit 1"]
192+
interval: 5s
193+
timeout: 5s
194+
retries: 50
183195
environment:
184196
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
185197
MYSQL_DATABASE: '${DB_NAME}'
@@ -188,14 +200,14 @@ services:
188200
MYSQL_ALLOW_EMPTY_PASSWORD: 'No'
189201
MYSQL_ROOT_HOST: '${MYSQL_ROOT_HOST}'
190202
TZ: '${LOCAL_TIMEZONE}'
191-
labels:
203+
labels:
192204
- "docker-volume-backup.stop-during-backup=true"
193205
- "docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -uroot -p${MYSQL_ROOT_PASSWORD} --all-databases > /tmp/backup/db_backup_data.sql'"
194206
- "docker-volume-backup.exec-label=database"
195-
command: bash -c "apt-get -y update && apt-get install -y gettext-base && export PMA_CONTROLUSER=${PMA_CONTROLUSER} export PMA_CONTROLPASS=${PMA_CONTROLPASS} && envsubst '$$PMA_CONTROLUSER,$$PMA_CONTROLPASS' < /docker-entrypoint-initdb.d/create_tables.sql.template > /docker-entrypoint-initdb.d/create_tables.sql && docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password"
196-
207+
command: bash -c "${DATABASE_PACKAGE_MANAGER} && export PMA_CONTROLUSER=${PMA_CONTROLUSER} export PMA_CONTROLPASS=${PMA_CONTROLPASS} && envsubst '$$PMA_CONTROLUSER,$$PMA_CONTROLPASS' < /docker-entrypoint-initdb.d/create_tables.sql.template > /docker-entrypoint-initdb.d/create_tables.sql && docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=${DATABASE_AUTHENTICATION_PLUGIN}"
208+
197209
redis:
198-
image: 'redis:latest'
210+
image: redis:latest
199211
container_name: redis
200212
networks:
201213
- backend
@@ -235,7 +247,7 @@ services:
235247
BACKUP_FILENAME: 'backup-%Y-%m-%dT%H-%M-%S.tar.gz'
236248
BACKUP_RETENTION_DAYS: '7'
237249
EXEC_LABEL: 'database'
238-
BACKUP_EXCLUDE_REGEXP: 'webapp/app|webapp/bootstrap|webapp/database|webapp/tests|webapp/vendor|\\.log$$'
250+
#BACKUP_EXCLUDE_REGEXP: 'folder|folder|file|\\.log$$'
239251

240252
networks:
241253
backend: null
@@ -263,6 +275,6 @@ volumes:
263275
dtredis:
264276
name: redis-data
265277
certbot-etc:
266-
external: true
278+
external: true
267279
certbot-var:
268280
name: certbot-var

0 commit comments

Comments
 (0)