mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-14 02:34:22 +02:00
Move data to the root directory, for simplification
This commit is contained in:
parent
436055f02c
commit
e3a503a559
@ -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
|
||||
|
@ -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 \*'")
|
||||
|
Loading…
Reference in New Issue
Block a user