From 197a2d5606bb119ab9911fbe4b9bab64c6c57a66 Mon Sep 17 00:00:00 2001 From: kogitant Date: Fri, 8 Nov 2019 13:54:19 +0200 Subject: [PATCH 1/2] Docker support for using latest source codes of pgBadger --- Dockerfile | 22 ++++++++++++++++++++++ README_docker.md | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Dockerfile create mode 100644 README_docker.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..84782b0c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Based on https://github.com/matsuu/docker-pgbadger + +FROM alpine +RUN \ + apk update && \ + apk upgrade && \ + apk add perl && \ + apk add --virtual .build curl make + +ADD . /workdir +RUN \ + ( \ + cd /workdir && \ + perl Makefile.PL && \ + make install \ + ) && \ + apk del --purge .build && \ + rm -rf /workdir/* + + +ENTRYPOINT ["/usr/local/bin/pgbadger"] +CMD ["--help"] diff --git a/README_docker.md b/README_docker.md new file mode 100644 index 00000000..c8289704 --- /dev/null +++ b/README_docker.md @@ -0,0 +1,17 @@ +# Dockerfile +## Build docker image +``` +docker build -t pgbadger:latest . +``` + +To be able to rebuild existing image when source code changes, run +``` +docker rmi pgbadger +``` +and then rebuild the image + + +## Use +``` +docker run -i --rm -v $(pwd):/workdir pgbadger:latest -f stderr -p "%t:%r:%u@%d:[%p]:" /workdir/postgresql.log.2019-11-08-10 --outfile /workdir/report.html +``` From f669dded1df3eefd1c4a7a896e6a990c4106a775 Mon Sep 17 00:00:00 2001 From: kogitant Date: Wed, 13 Nov 2019 08:04:24 +0200 Subject: [PATCH 2/2] Improved docker image usage by using /workdir as the, well, workdir. Updated README.md to link to the README_docker.md --- Dockerfile | 2 +- README.md | 3 +++ README_docker.md | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 84782b0c..ed52b2c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,6 @@ RUN \ apk del --purge .build && \ rm -rf /workdir/* - +WORKDIR /workdir ENTRYPOINT ["/usr/local/bin/pgbadger"] CMD ["--help"] diff --git a/README.md b/README.md index f016306e..cd132485 100644 --- a/README.md +++ b/README.md @@ -482,6 +482,9 @@ For example, to install everything just like Debian does, proceed as follows: By default INSTALLDIRS is set to site. +### DOCKER IMAGE +You can build a docker image of pgbadger following the instructions in [README_Docker.md](README_docker.md) + ### POSTGRESQL CONFIGURATION You must enable and set some configuration directives in your postgresql.conf diff --git a/README_docker.md b/README_docker.md index c8289704..1964e835 100644 --- a/README_docker.md +++ b/README_docker.md @@ -1,17 +1,28 @@ # Dockerfile ## Build docker image ``` -docker build -t pgbadger:latest . +$ docker build -t pgbadger:latest . ``` To be able to rebuild existing image when source code changes, run ``` -docker rmi pgbadger +$ docker rmi pgbadger ``` and then rebuild the image ## Use ``` -docker run -i --rm -v $(pwd):/workdir pgbadger:latest -f stderr -p "%t:%r:%u@%d:[%p]:" /workdir/postgresql.log.2019-11-08-10 --outfile /workdir/report.html +$ docker run -i --rm -v $(pwd):/workdir pgbadger:latest -f stderr -p "%t:%r:%u@%d:[%p]:" postgresql.log.2019-11-08-10 --outfile report.html +``` + +Or parse multiple files at once with 4 threads: +``` +$ cat files_to_parse.txt +postgresql.log.2019-11-08-08 +postgresql.log.2019-11-08-09 +postgresql.log.2019-11-08-10 +postgresql.log.2019-11-08-11 + +$ docker run -i --rm -v $(pwd):/workdir pgbadger:latest -j 4 -f stderr -p "%t:%r:%u@%d:[%p]:" -L files_to_parse.txt --outfile report.html ```