From e3a503a559af4c1415c53b708ce2d5dd6fd5dec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Wed, 21 Nov 2018 12:30:35 +0200 Subject: [PATCH] Move data to the root directory, for simplification --- optional/postgresql/Dockerfile | 6 +++--- optional/postgresql/start.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/optional/postgresql/Dockerfile b/optional/postgresql/Dockerfile index f8d5dced..54d833c3 100644 --- a/optional/postgresql/Dockerfile +++ b/optional/postgresql/Dockerfile @@ -17,11 +17,11 @@ COPY conf /conf ENV LANG en_US.UTF-8 -RUN mkdir -p /var/lib/postgresql/data /run/postgresql \ - && chown -R postgres:postgres /var/lib/postgresql/data /run/postgresql \ +RUN mkdir -p /data /run/postgresql \ + && chown -R postgres:postgres /data /run/postgresql \ && chmod 2777 /run/postgresql -VOLUME /var/lib/postgresql/data +VOLUME /data EXPOSE 5432 CMD /start.py diff --git a/optional/postgresql/start.py b/optional/postgresql/start.py index 58c94006..18295776 100755 --- a/optional/postgresql/start.py +++ b/optional/postgresql/start.py @@ -27,18 +27,18 @@ def setup(): conn.close() # Bootstrap the database if postgresql is running for the first time -if not os.path.exists('/var/lib/postgresql/data/pg_wal'): - os.system("chown -R postgres:postgres /var/lib/postgresql") - os.system("su - postgres -c 'initdb -D /var/lib/postgresql/data'") +if not os.path.exists('/data/pg_wal'): + os.system("chown -R postgres:postgres /data") + os.system("su - postgres -c 'initdb -D /data'") convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) for pg_file in glob.glob("/conf/*.conf"): - convert(pg_file, os.path.join("/var/lib/postgresql/data", os.path.basename(pg_file))) + convert(pg_file, os.path.join("/data", os.path.basename(pg_file))) # Run postgresql locally for DB and user creation -os.system("su - postgres -c 'pg_ctl start -D /var/lib/postgresql/data -o \"-h localhost\"'") +os.system("su - postgres -c 'pg_ctl start -D /data -o \"-h localhost\"'") setup() -os.system("su - postgres -c 'pg_ctl stop -m smart -w -D /var/lib/postgresql/data'") +os.system("su - postgres -c 'pg_ctl stop -m smart -w -D /data'") # Run postgresql service -os.system("su - postgres -c 'postgres -D /var/lib/postgresql/data -h \*'") +os.system("su - postgres -c 'postgres -D /data -h \*'")