diff --git a/postgresql/Dockerfile b/postgresql/Dockerfile index 2836be8..13e718b 100644 --- a/postgresql/Dockerfile +++ b/postgresql/Dockerfile @@ -1,6 +1,5 @@ -FROM ubuntu:rolling -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update;apt-get install sudo postgresql -y +FROM alpine +RUN apk update;apk add bash sudo postgresql postgresql-contrib WORKDIR /tmp ENV SHELL="/bin/bash" @@ -14,7 +13,7 @@ RUN crontab /crontab ADD backup.sh / #POSTGRES Tweaks -ADD postgresql.conf /etc/postgresql/13/main/ -RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/13/main/pg_hba.conf +COPY postgresql.conf /etc/ +#RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/main/pg_hba.conf CMD bash /start.sh diff --git a/postgresql/backup.sh b/postgresql/backup.sh index 9241efb..274c796 100644 --- a/postgresql/backup.sh +++ b/postgresql/backup.sh @@ -1,3 +1,3 @@ #!/bin/bash -su postgres -s /bin/bash -lc "/usr/lib/postgresql/12/bin/pg_dumpall > /saves/pleroma-`date +%Y-%m-%d-%H-%M`.pgdump" +su postgres -s /bin/bash -lc "/usr/lib/postgresql/13/bin/pg_dumpall > /saves/pleroma-`date +%Y-%m-%d-%H-%M`.pgdump" diff --git a/postgresql/postgresql.conf b/postgresql/postgresql.conf index 5c81b87..fef22cb 100644 --- a/postgresql/postgresql.conf +++ b/postgresql/postgresql.conf @@ -38,15 +38,15 @@ # The default values of these variables are driven from the -D command-line # option or PGDATA environment variable, represented here as ConfigDir. -data_directory = '/var/lib/postgresql/13/main' # use data in another directory +data_directory = '/var/lib/postgresql/data' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/13/main/pg_hba.conf' # host-based authentication file +hba_file = '/var/lib/postgresql/data/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/13/main/pg_ident.conf' # ident configuration file +ident_file = '/var/lib/postgresql/data/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. -external_pid_file = '/var/run/postgresql/13-main.pid' # write an extra PID file +external_pid_file = '/run/postgresql/data/main.pid' # write an extra PID file # (change requires restart) @@ -64,7 +64,7 @@ listen_addresses = '*' port = 5432 # (change requires restart) max_connections = 200 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) -unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories +#unix_socket_directories = '/run/postgresql' # comma-separated list of directories # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation @@ -98,7 +98,7 @@ unix_socket_directories = '/var/run/postgresql' # comma-separated list of direct # - SSL - -ssl = on +ssl = off #ssl_ca_file = '' ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' #ssl_crl_file = '' @@ -543,7 +543,7 @@ log_timezone = 'Etc/UTC' # PROCESS TITLE #------------------------------------------------------------------------------ -cluster_name = '12/main' # added to process titles if nonempty +cluster_name = '13/main' # added to process titles if nonempty # (change requires restart) #update_process_title = on @@ -559,7 +559,7 @@ cluster_name = '12/main' # added to process titles if nonempty #track_io_timing = off #track_functions = none # none, pl, all #track_activity_query_size = 1024 # (change requires restart) -stats_temp_directory = '/var/run/postgresql/12-main.pg_stat_tmp' +#stats_temp_directory = '/run/postgresql/main.pg_stat_tmp' # - Monitoring - @@ -738,7 +738,7 @@ default_text_search_config = 'pg_catalog.english' # default postgresql.conf. Note that these are directives, not variable # assignments, so they can usefully be given more than once. -include_dir = 'conf.d' # include files ending in '.conf' from +#include_dir = '.' # include files ending in '.conf' from # a directory, e.g., 'conf.d' #include_if_exists = '...' # include file only if it exists #include = '...' # include file diff --git a/postgresql/setup.sh b/postgresql/setup.sh index 1fb3b4f..b294456 100644 --- a/postgresql/setup.sh +++ b/postgresql/setup.sh @@ -3,13 +3,16 @@ export SHELL="/bin/bash" #Database Setup mkdir /run/postgresql -mkdir -p /var/lib/postgresql/13/main +#mkdir -p /var/lib/postgresql/13/main chown -R postgres:postgres /run/postgresql/ chown -R postgres:postgres /var/lib/postgresql chown -R postgres:postgres /var/log/postgresql -su postgres -s $SHELL -lc "mkdir /var/lib/postgresql/data;chmod 0700 /var/lib/postgresql/data" - -/etc/init.d/postgresql start +#su postgres -s $SHELL -lc "mkdir /var/lib/postgresql/data;chmod 0700 /var/lib/postgresql/13/main" +su postgres -s $SHELL -lc "initdb --auth-host=trust -D /var/lib/postgresql/data" +cp -f /etc/postgresql.conf /var/lib/postgresql/data/ +echo "host all all 0.0.0.0/0 md5" >> /var/lib//postgresql/data/pg_hba.conf +chown -R postgres:postgres /var/lib/postgresql +su postgres -s $SHELL -lc "pg_ctl start -D /var/lib/postgresql/data" sleep 5 echo "CREATE USER pleroma WITH ENCRYPTED PASSWORD 'sql';" | su postgres -s $SHELL -lc psql echo "create user root with encrypted password 'sql';"| su postgres -s $SHELL -lc psql diff --git a/postgresql/start.sh b/postgresql/start.sh index e570dee..8e33add 100644 --- a/postgresql/start.sh +++ b/postgresql/start.sh @@ -9,8 +9,8 @@ chmod -R 777 /saves cp -f /usr/share/zoneinfo/US/Mountain /etc/localtime #Start Cron and Postgresql -/etc/init.d/cron start -/etc/init.d/postgresql start +crond +su postgres -s $SHELL -lc "pg_ctl start -D /var/lib/postgresql/data" #Restore latest Database if container is new if [ ! -f "$FILE" ]