Skip to content

Commit 803ae07

Browse files
committed
chore: improve dockerfile and docs
1 parent c527351 commit 803ae07

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LABEL maintainer="Jose Quintana <git.io/joseluisq>"
55
ENV BUILD_DEPS="gettext" \
66
RUNTIME_DEPS="libintl"
77

8-
RUN apk --no-cache add ca-certificates tzdata mysql-client nano
8+
RUN apk --no-cache add ca-certificates tzdata mysql-client nano dumb-init
99
RUN set -ex; \
1010
apkArch="$(apk --print-arch)"; \
1111
case "$apkArch" in \
@@ -24,3 +24,8 @@ COPY ./__mysqldump.sh /usr/local/bin/__mysqldump.sh
2424
COPY ./mysql_exporter /usr/local/bin/mysql_exporter
2525
RUN chmod +x /usr/local/bin/__mysqldump.sh && \
2626
chmod +x /usr/local/bin/mysql_exporter
27+
28+
EXPOSE 3306
29+
30+
ENTRYPOINT [ "/usr/bin/dumb-init" ]
31+
CMD [ "mysql" ]

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ run:
33
.PHONY: run
44

55
build:
6-
@docker build -t mysql-tools:latest .
6+
@docker build -t alpine-mysql-client:latest .
77
.PHONY: build
88

99
exec:
1010
@docker run --rm -it \
11-
--name mysql-tools \
11+
--name alpine-mysql-client \
1212
--volume $(PWD):/root/sample \
1313
--workdir /root/sample \
14-
mysql-tools \
14+
alpine-mysql-client:latest \
1515
mysql_exporter .env
1616
.PHONY: exec

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# MySQL Tools
1+
# Alpine / MySQL Client
22

3-
> MySQL client tools on Alpine image.
3+
> [MySQL client](https://dev.mysql.com/doc/refman/8.0/en/programs-client.html) tools on top of [Alpine Linux x86_64](https://hub.docker.com/_/alpine).
44
5-
## MySQL Client Tools
5+
**Note:** [MySQL client (mariadb-client)](https://pkgs.alpinelinux.org/package/v3.11/main/x86_64/mysql-client) is an alias package for [mysql-client](https://dev.mysql.com/doc/refman/8.0/en/programs-client.html) migration tools.
6+
7+
## MySQL Client programs
68

79
```sh
810
mysql
@@ -19,9 +21,23 @@ mysqldumpslow
1921
mysqlshow
2022
```
2123

22-
## Setup
24+
**Note:** For more details take a look at:
25+
26+
- [MariaDB 10 - Clients & Utilities](https://mariadb.com/kb/en/clients-utilities/)
27+
- [MySQL 8 - Client Programs](https://dev.mysql.com/doc/refman/8.0/en/programs-client.html)
28+
29+
## Additional Tools
2330

24-
Setup is made using via `.env` files.
31+
This image comes with some additional tools:
32+
33+
### Exporter
34+
35+
`mysql_exporter` is a custom tool which exports a database script using `mysqldump`. Additionally it support gzip compression.
36+
It can be configured via a `.env` file.
37+
38+
#### Setup via environment variables
39+
40+
Setup can be done using a `.env` file.
2541

2642
```env
2743
DB_PROTOCOL=TCP
@@ -36,18 +52,18 @@ DB_PASSWORD=""
3652
DB_ARGS=
3753
```
3854

39-
## Usage
55+
**Notes: **
4056

41-
### Exporter
57+
- `DB_EXPORT_GZIP=true`: Compress the sql file using Gzip (optional)
4258

43-
`mysql_exporter` is a custom tool in order to export a database which supports `.env` files.
59+
#### Export database using a Docker container
4460

4561
```sh
46-
@docker run --rm -it \
47-
--name mysql-tools \
62+
docker run --rm -it \
63+
--name joseluisq/alpine-mysql-client \
4864
--volume $(PWD):/root/sample \
4965
--workdir /root/sample \
50-
mysql-tools \
66+
joseluisq/alpine-mysql-client \
5167
mysql_exporter .env
5268
```
5369

0 commit comments

Comments
 (0)