From 105dc1581298eebccdecf2ee46d908aabeecc9ab Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 26 Nov 2018 22:09:37 +0100 Subject: [PATCH] fix: [postgres] don't rely on host. We were using ``lsof`` and ``pgm`` on host for some managing purpose. As we want to be able to use ``compose`` from a docker container, these got removed in favor of portable solutions. --- postgres/build/Dockerfile | 40 +++++++++++++++++++++++++++++ postgres/lib/common | 54 +++++++++++++++------------------------ postgres/metadata.yml | 1 - 3 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 postgres/build/Dockerfile diff --git a/postgres/build/Dockerfile b/postgres/build/Dockerfile new file mode 100644 index 0000000..763160a --- /dev/null +++ b/postgres/build/Dockerfile @@ -0,0 +1,40 @@ +## is a simple copy of postgres:10-alpine +FROM docker.0k.io/postgres:10-alpine as common + + +FROM common AS builder + + +RUN apk -U add alpine-sdk curl +RUN adduser -D packager && addgroup packager abuild + +ENV MBUFFER_APKBUILD_URL=https://git.alpinelinux.org/cgit/aports/plain/testing/mbuffer/APKBUILD?id=026cabf316eb477b2ae3e26dadc3e9c30ff26626 + + +USER packager + +RUN mkdir -p /tmp/build && \ + curl -L "${MBUFFER_APKBUILD_URL}" > /tmp/build/APKBUILD + +RUN cd /tmp/build && \ + sed -ri 's/^(\s+make -j1 check.*)/#\1/g' APKBUILD && \ + abuild-keygen -a -i && \ + abuild -r + +USER root + +RUN apk add curl + +RUN curl -L https://github.com/0k/pgm/raw/master/bin/pgm > /bin/pgm && \ + chmod +x /bin/pgm + +FROM common + +RUN apk -U add pv python file + +COPY --from=builder /home/packager/packages/tmp/x86_64/*.apk /tmp/ +COPY --from=builder /bin/pgm /bin + +RUN apk add /tmp/mbuffer-2018*.apk --allow-untrusted + +RUN ln -sf /usr/bin/mbuffer /usr/bin/buffer \ No newline at end of file diff --git a/postgres/lib/common b/postgres/lib/common index 67bcbf0..cfff3b4 100644 --- a/postgres/lib/common +++ b/postgres/lib/common @@ -8,27 +8,7 @@ export DB_PASSFILE=/root/.pgpass is_db_locked() { - require lsof || apt-get install -y lsof &2 + + docker run -i --rm \ + $db_docker_opts -e prefix_pg_local_command=' ' \ + --entrypoint pgm "$DOCKER_BASE_IMAGE" $db_cmd_opts "$@" + +} + db_grant_rights () { local dbname="$1" user="$2" - require psql || apt-get install -y postgresql-client " -docker-image: docker.0k.io/postgres:10-alpine data-resources: - /var/lib/postgresql/data