Skip to content

Commit 365c1f6

Browse files
committed
added create_tables.sql for phpmyadmin
1 parent aa90821 commit 365c1f6

File tree

5 files changed

+388
-30
lines changed

5 files changed

+388
-30
lines changed

README.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ If You want to build a website with Laravel "webapp" at short time;
44

55
#### Full stack Nginx Laravel "webapp":
66
<p align="left"> <a href="https://laravel.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/958072?s=200&v=4" alt="Laravel" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.docker.com/" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/docker/docker.png" alt="docker" width="40" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://mariadb.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/5877084?s=200&v=4" alt="mariadb" height="50" width="50"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.nginx.com" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1412239?s=200&v=4" alt="nginx" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.php.net" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/25158?s=200&v=4" alt="php" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://redis.io" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1529926?s=200&v=4" alt="redis" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="#" target="_blank" rel="noreferrer"> <img src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/bash/bash.png" alt="Bash" height="50" width="50" /> </a>&nbsp;&nbsp;&nbsp;
7-
<a href="https://www.phpmyadmin.net/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1351977?s=200&v=4" alt="phpmyadmin" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://letsencrypt.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="letsencrypt" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.portainer.io/?hsLang=en" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/22225832?s=200&v=4" alt="portainer" height="40" width="40"/> </a> </p>
7+
<a href="https://www.phpmyadmin.net/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1351977?s=200&v=4" alt="phpmyadmin" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://letsencrypt.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/17889013?s=200&v=4" alt="letsencrypt" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.portainer.io/?hsLang=en" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/22225832?s=200&v=4" alt="portainer" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp; <a href="https://www.offen.dev/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/47735043?s=200&v=4" alt="backup" height="35" width="35"/> </a> </p>
88

99
Plus, manage docker containers with Portainer.
1010

@@ -16,7 +16,7 @@ Plus, manage docker containers with Portainer.
1616
- [phpMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/)
1717
- [database](https://hub.docker.com/_/mariadb)
1818
- [redis](https://hub.docker.com/_/redis)
19-
- [backup](https://hub.docker.com/r/futurice/docker-volume-backup)
19+
- [backup](https://hub.docker.com/r/offen/docker-volume-backup)
2020

2121
#### For certbot (letsencrypt) certificate:
2222

@@ -278,20 +278,8 @@ The first authorize screen(htpasswd;username or password) and phpmyadmin login s
278278

279279
### backup
280280

281-
This will back up the all files and folders, once per day, and write it to ./backups with a filename like backup-2022-02-07T16-51-56.tar.gz
281+
This will back up the all files and folders in database/dump sql and html volumes, once per day, and write it to ./backups with a filename like backup-2023-01-01T10-18-00.tar.gz
282282

283-
#### example for crontab file on the host machine
283+
#### can run on a custom cron schedule
284284

285-
##### # old docker backup folder remove
286-
287-
```
288-
50 23 * * * find ${DIRECTORY_PATH}/backups/backup* -type f -mtime +1 | xargs rm
289-
```
290-
291-
##### # backup exclude laravel, backups folders in ${DIRECTORY_PATH}
292-
293-
```
294-
00 01 * * * tar -czvf ${DIRECTORY_PATH}/backups/'backup-example.com-'$(date +"\%Y-\%m-\%dT\%H-\%M-\%S")'.tar.gz' --exclude='backups' ${DIRECTORY_PATH}
295-
```
296-
297-
[CronHowto](https://help.ubuntu.com/community/CronHowto)
285+
```BACKUP_CRON_EXPRESSION: '20 01 * * *'``` the UTC timezone.

docker-compose.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ services:
102102
- backend
103103
- frontend
104104
volumes:
105+
- 'phpmyadmin:${WEBSERVER_DOC_ROOT}/sql'
105106
- type: bind
106107
source: ./phpmyadmin/apache2/sites-available/default-ssl.conf
107108
target: '${APACHE_CONFDIR_PREFIX}/sites-available/default-ssl.conf'
@@ -122,10 +123,10 @@ services:
122123
restart: unless-stopped
123124
ports:
124125
- '9090:443'
125-
#links:
126-
# - database
126+
links:
127+
- database
127128
environment:
128-
#PMA_HOST: database
129+
PMA_HOST: 'database'
129130
PMA_PMADB: 'phpmyadmin'
130131
PMA_CONTROLUSER: '${PMA_CONTROLUSER}'
131132
PMA_CONTROLPASS: '${PMA_CONTROLPASS}'
@@ -134,7 +135,7 @@ services:
134135
MEMORY_LIMIT: '${PMA_MEMORY_LIMIT}'
135136
TZ: '${LOCAL_TIMEZONE}'
136137
command: >
137-
bash -c "echo ${PMA_HTPASSWD_USERNAME}:phpmyadmin:$$( printf \"%s:%s:%s\" \"${PMA_HTPASSWD_USERNAME}\" \"phpmyadmin\" \"${PMA_HTPASSWD_PASSWORD}\" | md5sum | awk '{print $$1}' ) > ${PMA_CONF_FOLDER}/.htpasswd
138+
bash -c "apt-get -y update && apt-get install -y gettext-base && envsubst < ${WEBSERVER_DOC_ROOT}/sql/create_tables.sql.template > ${WEBSERVER_DOC_ROOT}/sql/create_tables.sql && echo ${PMA_HTPASSWD_USERNAME}:phpmyadmin:$$( printf \"%s:%s:%s\" \"${PMA_HTPASSWD_USERNAME}\" \"phpmyadmin\" \"${PMA_HTPASSWD_PASSWORD}\" | md5sum | awk '{print $$1}' ) > ${PMA_CONF_FOLDER}/.htpasswd
138139
&& printf 'AuthType Digest\\nAuthName \"phpmyadmin\"\\nAuthDigestProvider file\\nAuthUserFile ${PMA_CONF_FOLDER}/.htpasswd\\nRequire valid-user\\n' > ${WEBSERVER_DOC_ROOT}/.htaccess && a2enmod auth_digest;
139140
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;
140141
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;
@@ -147,9 +148,11 @@ services:
147148
- backend
148149
volumes:
149150
- 'db:/var/lib/mysql'
151+
- 'db-backup-data:/tmp/backup'
150152
- type: bind
151153
source: ./database/conf.d/z-mysql.cnf
152154
target: '${MYSQL_CONF_PREFIX}/z-mysql.cnf'
155+
- 'phpmyadmin:/docker-entrypoint-initdb.d'
153156
hostname: database
154157
restart: unless-stopped
155158
ports:
@@ -164,6 +167,8 @@ services:
164167
TZ: '${LOCAL_TIMEZONE}'
165168
labels:
166169
- "docker-volume-backup.stop-during-backup=true"
170+
- "docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -uroot -p${MYSQL_ROOT_PASSWORD} --all-databases > /tmp/backup/db_backup_data.sql'"
171+
- "docker-volume-backup.exec-label=database"
167172
command: "--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password"
168173

169174
redis:
@@ -188,24 +193,26 @@ services:
188193
command: "redis-server ${REDIS_CONF_PREFIX}/redis/redis.conf"
189194

190195
backup:
191-
image: 'futurice/docker-volume-backup'
196+
image: offen/docker-volume-backup:latest
192197
container_name: backup
193198
networks:
194199
- backend
195200
volumes:
196-
- '/var/run/docker.sock:/var/run/docker.sock:ro'
197201
- 'html:/backup/html:ro'
198202
- 'db:/backup/db:ro'
203+
- 'db-backup-data:/backup/db-backup-data:ro'
204+
- '/var/run/docker.sock:/var/run/docker.sock:ro'
199205
- type: bind
200206
source: ./backups
201207
target: /archive
202208
hostname: backup
203209
restart: unless-stopped
204210
environment:
205-
BACKUP_WAIT_SECONDS: 120
206211
BACKUP_CRON_EXPRESSION: '20 01 * * *'
207212
BACKUP_FILENAME: 'backup-%Y-%m-%dT%H-%M-%S.tar.gz'
208-
TZ: '${LOCAL_TIMEZONE}'
213+
BACKUP_RETENTION_DAYS: '7'
214+
EXEC_LABEL: 'database'
215+
#BACKUP_EXCLUDE_REGEXP: 'folder|folder|file|\\.log$$'
209216

210217
networks:
211218
backend: null
@@ -221,6 +228,15 @@ volumes:
221228
o: bind
222229
db:
223230
name: ${DATABASE_CONT_NAME}-data
231+
db-backup-data:
232+
name: ${DATABASE_CONT_NAME}-backup-data
233+
phpmyadmin:
234+
name: phpmyadmin-sql
235+
driver: local
236+
driver_opts:
237+
type: none
238+
device: ${DIRECTORY_PATH}/phpmyadmin/sql
239+
o: bind
224240
dtredis:
225241
name: redis-data
226242
certbot-etc:

phpmyadmin/config.user.inc.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99

1010
$cfg['CheckConfigurationPermissions'] = false;
1111
$cfg['ShowPhpInfo'] = true;
12-
$cfg['Servers'][1]['host'] = 'database';

0 commit comments

Comments
 (0)