Skip to content

Commit 16f401f

Browse files
committed
⚙️ avoid file2file mount 📖 conf & logs dirs
1 parent 82ea364 commit 16f401f

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

README.md

+25-10
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ services:
4848
- "3308:3306" #for external connection
4949
restart: always
5050
volumes:
51-
- ../mysql-proxy/main.lua:/opt/main.lua
51+
- ../mysql-proxy-conf:/opt/mysql-proxy/conf
5252
environment:
5353
PROXY_DB_PORT: 3306
5454
REMOTE_DB_HOST: mysql
5555
REMOTE_DB_PORT: 3306
56-
PROXY_LUA_SCRIPT: "/opt/main.lua"
56+
PROXY_LUA_SCRIPT: "/opt/mysql-proxy/conf/main.lua"
5757
depends_on:
5858
- mysql
5959
```
@@ -73,19 +73,19 @@ end
7373
```
7474
...
7575
volumes:
76-
- ../mysql-proxy/log.lua:/opt/log.lua
77-
- ../mysql-proxy/mysql.log:/opt/mysql-proxy/mysql.log
76+
- ../mysql-proxy-conf:/opt/mysql-proxy/conf
77+
- ../mysql-proxy-logs:/opt/mysql-proxy/logs
7878
environment:
7979
PROXY_DB_PORT: 3306
8080
REMOTE_DB_HOST: mysql
8181
REMOTE_DB_PORT: 3306
82-
PROXY_LUA_SCRIPT: "/opt/log.lua"
82+
PROXY_LUA_SCRIPT: "/opt/mysql-proxy/conf/log.lua"
8383
...
8484
```
8585

8686
`/mysql-proxy/log.lua` https://gist.github.com/simonw/1039751
8787
```
88-
local log_file = '/opt/mysql-proxy/mysql.log'
88+
local log_file = '/opt/mysql-proxy/logs/mysql.log'
8989
9090
local fh = io.open(log_file, "a+")
9191
@@ -105,14 +105,29 @@ end
105105
https://hub.docker.com/r/zwxajh/mysql-proxy
106106
https://hub.docker.com/r/gediminaspuksmys/mysqlproxy/
107107

108+
# logrotate
109+
The image can be expand with `logrotate`
110+
Config file `/etc/logrotate.d/mysql-proxy` (approximate)
111+
112+
```
113+
/opt/mysql-proxy/mysql.log {
114+
weekly
115+
missingok
116+
rotate 35600
117+
compress
118+
delaycompress
119+
notifempty
120+
create 666 root root
121+
postrotate
122+
/etc/init.d/mysql-proxy reload > /dev/null
123+
endscript
124+
}
125+
```
126+
108127
# troubleshooting
109128
If you can't create the chain `mysql` -> `mysql-proxy` -> `external client liten 0.0.0.0:3308`
110129
check extends ports on the `mysql` service and/or add `expose` directly
111130
```
112131
expose:
113132
- "3306" #for service mysql-proxy
114133
```
115-
116-
You can create
117-
```touch mysql-proxy/mysql.log```
118-
before run the suite

log.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
-- This script will log the current date and time, the connection id
2828
-- and the query to a file named "mysql.log"
2929
--
30-
local log_file = '/opt/mysql-proxy/mysql.log'
30+
local log_file = '/opt/mysql-proxy/logs/mysql.log'
3131

3232
local fh = io.open(log_file, "a+")
3333

0 commit comments

Comments
 (0)