From 6d175d34d861cf2a8a656454ad64f1612d59f8f4 Mon Sep 17 00:00:00 2001 From: ngn Date: Sat, 20 Jul 2024 01:52:52 +0300 Subject: [PATCH] new: add docker and compose files --- .gitignore | 2 ++ Dockerfile | 29 +++++++++++++++++++++++++++++ Makefile | 1 - README.md | 6 ++++++ docker-compose.yml | 12 ++++++++++++ install/config.ini | 2 +- locale/tr/LC_MESSAGES/pooler.po | 2 +- src/main.c | 2 +- 8 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 02a836d..bc2fa06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +./config.ini +data *.pot *.mo dist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..92fbc7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM libmp as build + +RUN apt update +RUN apt install -y make gcc gettext libinih-dev libsqlite3-dev libarchive-dev + +WORKDIR /root + +COPY ./Makefile ./ +COPY ./install ./install +COPY ./locale ./locale +COPY ./src ./src + +RUN make +RUN make install + +FROM libmp as main + +RUN apt update +RUN apt install -y dumb-init +RUN mkdir -pv /var/lib/pooler + +# translations +COPY --from=build /usr/share/locale/tr/LC_MESSAGES/pooler.mo /usr/share/locale/tr/LC_MESSAGES/pooler.mo + +# binary and the configuration +COPY --from=build /etc/pooler/config.ini /etc/pooler/config.ini +COPY --from=build /usr/bin/pooler /usr/bin/pooler + +ENTRYPOINT ["dumb-init", "/usr/bin/pooler", "/etc/pooler/config.ini"] diff --git a/Makefile b/Makefile index fd05035..a8ae6d7 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,6 @@ uninstall: rm $(DESTDIR)/$(PREFIX)/share/$$po/pooler.mo ; \ done - format: clang-format -i -style=file src/*.c src/*.h diff --git a/README.md b/README.md index 962c323..38ac5fe 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ You can also build the program using docker: docker build --tag pooler . ``` +And for deployment you can use docker-compose, just make sure you read the compose file +and place the configuration file and the pools to the right place: +```bash +docker-compose up -d +``` + ### Usage To start a serving pools, specify a configuration file, default configuration file is installed in the `/etc/pooler` directory: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1e9ef21 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + pooler: + build: + context: ./ + ports: + - "5858:5858/udp" + volumes: + - "./config.ini:/etc/pooler/config.ini" + - "./data:/var/lib/pooler" + diff --git a/install/config.ini b/install/config.ini index 44c97c0..3f3446b 100644 --- a/install/config.ini +++ b/install/config.ini @@ -1,7 +1,7 @@ # default pooler configuration, please see the wiki page for more information # https://matterlinux.xyz/wiki/pooler -log = /var/lib/pooler/pooler.log +# log = /var/lib/pooler/pooler.log dir = /var/lib/pooler addr = 0.0.0.0:5858 diff --git a/locale/tr/LC_MESSAGES/pooler.po b/locale/tr/LC_MESSAGES/pooler.po index 2825b10..ef06480 100644 --- a/locale/tr/LC_MESSAGES/pooler.po +++ b/locale/tr/LC_MESSAGES/pooler.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-18 19:32+0300\n" +"POT-Creation-Date: 2024-07-20 01:23+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/main.c b/src/main.c index 3162ed6..2a0b476 100644 --- a/src/main.c +++ b/src/main.c @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) { goto end; if ((logfile = config_get_string("log")) != NULL) { - FILE *log = fopen(logfile, "r"); + FILE *log = fopen(logfile, "a"); if (NULL == log) error(_("Failed to open the log file: %s"), strerror(errno));