Move data to the root directory, for simplification

master
Tim Möhlmann 6 years ago
parent 436055f02c
commit e3a503a559
No known key found for this signature in database
GPG Key ID: 8677988D8072E8DE

@ -17,11 +17,11 @@ COPY conf /conf
ENV LANG en_US.UTF-8 ENV LANG en_US.UTF-8
RUN mkdir -p /var/lib/postgresql/data /run/postgresql \ RUN mkdir -p /data /run/postgresql \
&& chown -R postgres:postgres /var/lib/postgresql/data /run/postgresql \ && chown -R postgres:postgres /data /run/postgresql \
&& chmod 2777 /run/postgresql && chmod 2777 /run/postgresql
VOLUME /var/lib/postgresql/data VOLUME /data
EXPOSE 5432 EXPOSE 5432
CMD /start.py CMD /start.py

@ -27,18 +27,18 @@ def setup():
conn.close() conn.close()
# Bootstrap the database if postgresql is running for the first time # Bootstrap the database if postgresql is running for the first time
if not os.path.exists('/var/lib/postgresql/data/pg_wal'): if not os.path.exists('/data/pg_wal'):
os.system("chown -R postgres:postgres /var/lib/postgresql") os.system("chown -R postgres:postgres /data")
os.system("su - postgres -c 'initdb -D /var/lib/postgresql/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)) convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
for pg_file in glob.glob("/conf/*.conf"): 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 # 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() 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 # Run postgresql service
os.system("su - postgres -c 'postgres -D /var/lib/postgresql/data -h \*'") os.system("su - postgres -c 'postgres -D /data -h \*'")

Loading…
Cancel
Save