Skip to content

Commit f35b271

Browse files
Merge pull request #1 from vshn/develop
Initial docker image
2 parents 47b6231 + e32d6c1 commit f35b271

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM haproxy:2.0-alpine
2+
3+
LABEL maintainer="soufiane.benali@vshn.ch"
4+
5+
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
6+
7+
USER 1001
8+
9+
ENV DB1_ADDRESS= \
10+
DB2_ADDRESS= \
11+
DB3_ADDRESS= \
12+
DB1_PORT=3306 \
13+
DB2_PORT=3306 \
14+
DB3_PORT=3306

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
11
# galera-haproxy
22
HAProxy docker image with custom configuration
3+
4+
Dockerized HAProxy with default config file for a multi node galera cluster. To ovveride the default configuration it's possible using the environemnt variables.
5+
6+
## Run
7+
You need to specify the addresses for DB1 through DB3 as well as passwords for service and monitoring users:
8+
```
9+
docker run -e DB1_ADDRESS=127.0.0.1 -e DB2_ADDRESS=127.0.0.2 -e DB3_ADDRESS=127.0.0.3 haproxy-mysql
10+
```
11+
12+
## Configuration
13+
Config is done through env vars:
14+
15+
| Name | Default value | Description |
16+
|-------------------------------|---------------------|-----------------------------------------|
17+
| `DB1_ADDRESS` | | Address for DB1 |
18+
| `DB1_PORT` | `3306` | Port for DB1 |
19+
| `DB2_ADDRESS` | | Address for DB2 |
20+
| `DB2_PORT` | `3306` | Port for DB2 |
21+
| `DB3_ADDRESS` | | Address for DB3 |
22+
| `DB3_PORT` | `3306` | Port for DB3 |
23+
24+
25+
## Build
26+
```
27+
docker build --rm -t vshn/galera-haproxy:1.0.0 .
28+
docker push vshn/galera-haproxy:1.0.0
29+
```

haproxy.cfg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
global
2+
log stdout local0
3+
4+
defaults
5+
log global
6+
7+
option dontlognull
8+
timeout connect 5000
9+
timeout client 10000
10+
timeout server 10000
11+
12+
listen stats
13+
bind 0.0.0.0:8070
14+
mode http
15+
option httplog
16+
stats enable
17+
stats uri /
18+
19+
listen galera
20+
bind 0.0.0.0:3306
21+
mode tcp
22+
option mysql-check
23+
server mysql-1 ${DB1_ADDRESS}:${DB1_PORT} check
24+
server mysql-2 ${DB3_ADDRESS}:${DB2_PORT} check backup
25+
server mysql-3 ${DB2_ADDRESS}:${DB3_PORT} check backup

0 commit comments

Comments
 (0)