Skip to content

Commit d6f68e1

Browse files
committed
added create_tables.sql for phpmyadmin and updated the some files
1 parent fd4eb40 commit d6f68e1

File tree

8 files changed

+393
-42
lines changed

8 files changed

+393
-42
lines changed

README.md

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

55
#### Full stack Nginx Slim "webapp":
66
<p align="left"> <a href="https://www.slimframework.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/11195762?s=200&v=4" alt="Slim" 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

@@ -137,7 +137,7 @@ For convenience you may add a new entry into your hosts file.
137137
docker volume create portainer_data
138138
docker compose -f portainer-docker-compose.yml -p portainer up -d
139139
```
140-
manage docker with [Portainer](https://www.portainer.io/solutions/docker) is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API.
140+
manage docker with [Portainer](https://www.portainer.io/) is the definitive container management tool for Docker, Docker Swarm with it's highly intuitive GUI and API.
141141

142142
You can also visit `https://example.com:9001` to access portainer after starting the containers.
143143

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

291291
### backup
292292

293-
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
293+
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
294294

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

297-
##### # old docker backup folder remove
298-
299-
```
300-
50 23 * * * find ${DIRECTORY_PATH}/backups/backup* -type f -mtime +1 | xargs rm
301-
```
302-
303-
##### # backup exclude slim, backups folders in ${DIRECTORY_PATH}
304-
305-
```
306-
00 01 * * * tar -czvf ${DIRECTORY_PATH}/backups/'backup-example.com-'$(date +"\%Y-\%m-\%dT\%H-\%M-\%S")'.tar.gz' --exclude='backups' ${DIRECTORY_PATH}
307-
```
308-
309-
[CronHowto](https://help.ubuntu.com/community/CronHowto)
297+
```BACKUP_CRON_EXPRESSION: '20 01 * * *'``` the UTC timezone.

docker-compose.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ services:
3535
labels:
3636
- 'docker-volume-backup.stop-during-backup=true'
3737
command: >
38-
bash -c "apt-get -y update && apt-get install -y zip unzip libicu-dev && docker-php-ext-install pdo_mysql intl && docker-php-ext-enable pdo_mysql intl; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
38+
bash -c "apt-get -y update && apt-get install -y zip unzip libicu-dev && docker-php-ext-install pdo_mysql intl; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
3939
if [ \"$$(ls -A ${WEBSERVER_DOC_ROOT}/webapp)\" ]; then composer update --working-dir=${WEBSERVER_DOC_ROOT}/webapp; else composer create-project slim/slim-skeleton:dev-master webapp && cd ${WEBSERVER_DOC_ROOT}/webapp && composer require slim/http-cache; fi;
4040
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"
4141
@@ -74,8 +74,6 @@ services:
7474
NGINX_HOST: ${DOMAIN_NAME}
7575
NGINX_PORT: 80
7676
TZ: '${LOCAL_TIMEZONE}'
77-
labels:
78-
- "docker-volume-backup.stop-during-backup=true"
7977
command: bash -c "/docker-entrypoint.sh nginx -v; sh /tmp/ssl-conf.sh '${DOMAIN_NAME}' '${LETSENCRYPT_CONF_PREFIX}' '${NGINX_PREFIX}'"
8078

8179
certbot:
@@ -104,6 +102,7 @@ services:
104102
- backend
105103
- frontend
106104
volumes:
105+
- 'phpmyadmin:${WEBSERVER_DOC_ROOT}/sql'
107106
- type: bind
108107
source: ./phpmyadmin/apache2/sites-available/default-ssl.conf
109108
target: '${APACHE_CONFDIR_PREFIX}/sites-available/default-ssl.conf'
@@ -124,21 +123,19 @@ services:
124123
restart: unless-stopped
125124
ports:
126125
- '9090:443'
127-
#links:
128-
# - database
126+
links:
127+
- database
129128
environment:
130-
#PMA_HOST: database
131-
PMA_PMADB: phpmyadmin
129+
PMA_HOST: 'database'
130+
PMA_PMADB: 'phpmyadmin'
132131
PMA_CONTROLUSER: '${PMA_CONTROLUSER}'
133132
PMA_CONTROLPASS: '${PMA_CONTROLPASS}'
134133
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
135134
UPLOAD_LIMIT: '${PMA_UPLOAD_LIMIT}'
136135
MEMORY_LIMIT: '${PMA_MEMORY_LIMIT}'
137136
TZ: '${LOCAL_TIMEZONE}'
138-
labels:
139-
- "docker-volume-backup.stop-during-backup=true"
140137
command: >
141-
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
142139
&& printf 'AuthType Digest\\nAuthName \"phpmyadmin\"\\nAuthDigestProvider file\\nAuthUserFile ${PMA_CONF_FOLDER}/.htpasswd\\nRequire valid-user\\n' > ${WEBSERVER_DOC_ROOT}/.htaccess && a2enmod auth_digest;
143140
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;
144141
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;
@@ -151,9 +148,11 @@ services:
151148
- backend
152149
volumes:
153150
- 'db:/var/lib/mysql'
151+
- 'db-backup-data:/tmp/backup'
154152
- type: bind
155153
source: ./database/conf.d/z-mysql.cnf
156154
target: '${MYSQL_CONF_PREFIX}/z-mysql.cnf'
155+
- 'phpmyadmin:/docker-entrypoint-initdb.d'
157156
hostname: database
158157
restart: unless-stopped
159158
ports:
@@ -168,6 +167,8 @@ services:
168167
TZ: '${LOCAL_TIMEZONE}'
169168
labels:
170169
- "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"
171172
command: "--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password"
172173

173174
redis:
@@ -189,29 +190,29 @@ services:
189190
environment:
190191
ALLOW_EMPTY_PASSWORD: 'yes'
191192
TZ: '${LOCAL_TIMEZONE}'
192-
labels:
193-
- "docker-volume-backup.stop-during-backup=true"
194193
command: "redis-server ${REDIS_CONF_PREFIX}/redis/redis.conf"
195194

196195
backup:
197-
image: 'futurice/docker-volume-backup'
196+
image: offen/docker-volume-backup:latest
198197
container_name: backup
199198
networks:
200199
- backend
201200
volumes:
202-
- '/var/run/docker.sock:/var/run/docker.sock:ro'
203201
- 'html:/backup/html:ro'
204202
- 'db:/backup/db:ro'
203+
- 'db-backup-data:/backup/db-backup-data:ro'
204+
- '/var/run/docker.sock:/var/run/docker.sock:ro'
205205
- type: bind
206206
source: ./backups
207207
target: /archive
208208
hostname: backup
209209
restart: unless-stopped
210210
environment:
211-
BACKUP_WAIT_SECONDS: 120
212211
BACKUP_CRON_EXPRESSION: '20 01 * * *'
213212
BACKUP_FILENAME: 'backup-%Y-%m-%dT%H-%M-%S.tar.gz'
214-
TZ: '${LOCAL_TIMEZONE}'
213+
BACKUP_RETENTION_DAYS: '7'
214+
EXEC_LABEL: 'database'
215+
#BACKUP_EXCLUDE_REGEXP: 'folder|folder|file|\\.log$$'
215216

216217
networks:
217218
backend: null
@@ -227,6 +228,15 @@ volumes:
227228
o: bind
228229
db:
229230
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
230240
dtredis:
231241
name: redis-data
232242
certbot-etc:

install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ sudo apt-get install ca-certificates curl gnupg lsb-release
2525
sudo mkdir -p /etc/apt/keyrings
2626
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
2727
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(grep -Po 'UBUNTU_CODENAME=\K[^;]*' /etc/os-release) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
28-
sudo chmod 666 /var/run/docker.sock
2928
sudo apt-get update
3029

3130
Installed=`sudo apt-cache policy docker-ce | sed -n '2p' | cut -c 14-`

phpmyadmin/apache2/sites-available/default-ssl.sample.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# /usr/share/doc/apache2/README.Debian.gz for more info.
3434
# If both key and certificate are stored in the same file, only the
3535
# SSLCertificateFile directive is needed.
36-
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
36+
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
3737
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
3838

3939
# Server Certificate Chain:

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)