diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index da3adca..0000000 --- a/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -FROM ubuntu:bionic -ENV container docker -ENV DEBIAN_FRONTEND noninteractive -ADD https://www.postgresql.org/media/keys/ACCC4CF8.asc keyring.asc -RUN echo 'APT::Install-Recommends "0"; \n\ -APT::Get::Assume-Yes "true"; \n\ -APT::Get::allow-downgrades "true"; \n\ -APT::Install-Suggests "0";' > /etc/apt/apt.conf.d/01buildconfig && \ - apt-get update && \ - apt-get install -qq --no-install-recommends gpg gpg-agent && \ - apt-key add keyring.asc - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ - apt-get update && apt-get install wget gnupg ca-certificates locales && \ - locale-gen en_US.UTF-8 && \ - apt-get update && \ - apt-get install \ - openjdk-11-jre-headless \ - less \ - bind9-host \ - net-tools \ - iputils-ping \ - sudo \ - telnet \ - git \ - pgbouncer \ - python3-dev \ - python3-pip \ - python3-venv \ - python3-wheel \ - python3-setuptools \ - openssh-server \ - libpq-dev \ - gcc \ - faketime \ - rsync \ - openssl \ - iptables \ - coreutils && \ - pip3 install git+https://github.com/Supervisor/supervisor.git@4619168a4d820b37641a4719e211cf867bd7f49d && \ - pip3 install wheel && \ - rm -rf /var/run && \ - ln -s /dev/shm /var/run -COPY ./ /var/lib/dist -COPY tests/generate_certs.sh /usr/local/bin/generate_certs.sh -RUN chmod 755 /usr/local/bin/generate_certs.sh -RUN mkdir /root/.ssh && \ - chmod 700 /root/.ssh && \ - cp /var/lib/dist/test_ssh_key.pub /root/.ssh/authorized_keys && \ - mkdir -p /etc/supervisor/conf.d && \ - cp /var/lib/dist/tests/conf/supervisord.conf /etc/supervisor/supervisord.conf && \ - cp /var/lib/dist/docker/base/ssh.conf /etc/supervisor/conf.d/ssh.conf -CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/Makefile b/Makefile index aaa821c..9c36f8d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ PGCONSUL_IMAGE=pgconsul:behave PROJECT=pgconsul ZK_VERSION=3.7.1 export ZK_VERSION -INSTALL_DIR=$(DESTDIR)opt/yandex/pgconsul +INSTALL_DIR=$(DESTDIR)/opt/yandex/pgconsul REPLICATION_TYPE=quorum clean_report: @@ -27,8 +27,7 @@ install: mkdir -p $(DESTDIR)/etc/pgconsul/plugins # Make venv python3 -m venv $(INSTALL_DIR) -# echo `git rev-list HEAD --count`-`git rev-parse --short HEAD` > $(INSTALL_DIR)/package.release - echo "1-0303030" > $(INSTALL_DIR)/package.release + echo `git rev-list HEAD --count`-`git rev-parse --short HEAD` > $(INSTALL_DIR)/package.release # Install dependencies and pgconsul as python packages in venv $(INSTALL_DIR)/bin/pip install wheel $(INSTALL_DIR)/bin/pip install --pre -r requirements.txt @@ -38,15 +37,17 @@ install: mkdir -p $(DESTDIR)/etc/pgconsul/plugins # Fix "ValueError: bad marshal data (unknown type code)" find $(INSTALL_DIR) -name __pycache__ -type d -exec rm -rf {} + + +install_local: install # Make symlinks in /usr/local/bin ln -s /opt/yandex/pgconsul/bin/pgconsul $(DESTDIR)/usr/local/bin ln -s /opt/yandex/pgconsul/bin/pgconsul-util $(DESTDIR)/usr/local/bin # Replace redundant paths with actual ones # E.g. /tmp/build/opt/yandex/pgconsul -> /opt/yandex/pgconsul test -n '$(DESTDIR)' \ - && grep -l -r -F '$(INSTALL_DIR)' $(INSTALL_DIR) \ - | xargs sed -i -e 's|$(INSTALL_DIR)|/opt/yandex/pgconsul|' \ - || true + && grep -l -r -F '$(INSTALL_DIR)' $(INSTALL_DIR) \ + | xargs sed -i -e 's|$(INSTALL_DIR)|/opt/yandex/pgconsul|' \ + || true build: cp -f docker/base/Dockerfile . diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..43c5d7b --- /dev/null +++ b/debian/control @@ -0,0 +1,19 @@ +Source: pgconsul +Section: unknown +Priority: optional +Maintainer: Evgeny Dyukov +Build-Depends: + debhelper (>= 8.0.0), + python3.10, python3.10-venv, python3-pip, + python-setuptools, + libpq-dev, + git +Standards-Version: 3.9.4 +Homepage: https://github.com/yandex/pgconsul +#Vcs-Git: git://github.com:yandex/pgconsul.git +#Vcs-Browser: https://github.com/yandex/pgconsul + +Package: pgconsul +Architecture: any +Depends: ${misc:Depends}, python3.10 +Description: Automatic failover of PostgreSQL with help of ZK diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c910694 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,19 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pgconsul +Upstream-Contact: Vladimir Borodin +Source: + +Files: * +Copyright: 2023 Yandex LLC +License: + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..fcbc969 --- /dev/null +++ b/debian/install @@ -0,0 +1,4 @@ +/opt/yandex/pgconsul/bin/pgconsul +/opt/yandex/pgconsul/bin/pgconsul-util +/etc/logrotate.d/pgconsul +/etc/pgconsul/plugins diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..82dfbfe --- /dev/null +++ b/debian/links @@ -0,0 +1,2 @@ +/opt/yandex/pgconsul/bin/pgconsul /usr/local/bin/pgconsul +/opt/yandex/pgconsul/bin/pgconsul-util /usr/local/bin/pgconsul-util diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..b044e80 --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f + +clean: + dh clean + +build: + dh build + +override_dh_auto_install: + dh_auto_install --destdir=debian/tmp + +binary: + dh binary diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/docker/pgconsul/Dockerfile b/docker/pgconsul/Dockerfile index 64b4d67..0f64f2b 100644 --- a/docker/pgconsul/Dockerfile +++ b/docker/pgconsul/Dockerfile @@ -30,7 +30,7 @@ RUN pg_dropcluster --stop $PG_MAJOR main && \ ln -s /usr/lib/postgresql/$PG_MAJOR/bin /usr/bin/postgresql && \ mkdir -p /etc/pgconsul/plugins && \ cd /var/lib/dist && \ - DESTDIR=/ make install && \ + DESTDIR=/ make install_local && \ cp /var/lib/dist/docker/pgconsul/pgconsul_${replication_type}.conf /etc/pgconsul.conf && \ cp /var/lib/dist/docker/pgconsul/gen_rec_conf.sh /usr/local/bin/gen_rec_conf.sh && \ echo "*:*:*:repl:repl" > /var/lib/postgresql/.pgpass && \ diff --git a/tests/Dockerfile b/tests/Dockerfile index d5e9b40..d2cc983 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -94,7 +94,7 @@ CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] RUN mkdir /repo COPY ./ /repo/ -RUN cd /repo && DESTDIR=/ make install +RUN cd /repo && DESTDIR=/ make install_local RUN ln -s /repo/src/plugins/upload_wals.py /etc/pgconsul/plugins/upload_wals.py RUN chown -R postgres:postgres /opt/yandex/pgconsul /etc/pgconsul/plugins /repo/src/plugins