File tree Expand file tree Collapse file tree 5 files changed +53
-22
lines changed Expand file tree Collapse file tree 5 files changed +53
-22
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ templates:
99# any extra arguments for Docker?
1010# docker_args:
1111
12+ # TODO: SOME_SECRET to a password for the discourse user
1213params :
1314 db_default_text_search_config : " pg_catalog.english"
15+ db_password : SOME_SECRET
1416
1517 # # Set db_shared_buffers to a max of 25% of the total memory.
1618 # # will be set automatically by bootstrap based on detected RAM, or you can override
2426 LC_ALL : en_US.UTF-8
2527 LANG : en_US.UTF-8
2628 LANGUAGE : en_US.UTF-8
29+ DISCOURSE_DB_PASSWORD : $db_password
2730
2831volumes :
2932 - volume :
@@ -33,12 +36,11 @@ volumes:
3336 host : /var/discourse/shared/data/log/var-log
3437 guest : /var/log
3538
36- # TODO: SOME_SECRET to a password for the discourse user
3739hooks :
3840 after_postgres :
3941 - exec :
4042 stdin : |
41- alter user discourse with password 'SOME_SECRET ';
43+ alter user discourse with password '$db_password ';
4244 cmd : su - postgres -c 'psql discourse'
4345
4446 raise_on_fail : false
Original file line number Diff line number Diff line change @@ -14,22 +14,38 @@ hooks:
1414 - replace :
1515 filename : /etc/service/unicorn/run
1616 from : " # postgres"
17- to : |
18- if [ -f /root/install_postgres ]; then
19- /root/install_postgres
20- rm /root/install_postgres
21- fi
22- sv start postgres || exit 1
17+ to : sv start postgres || exit 1
2318
2419run :
2520 - exec : DEBIAN_FRONTEND=noninteractive apt-get purge -y postgresql-13 postgresql-client-13 postgresql-contrib-13 postgresql-13-pgvector
2621 - exec : apt-get update && apt-get install -y postgresql-15 postgresql-client-15 postgresql-contrib-15 postgresql-15-pgvector
22+
23+ - file :
24+ path : /etc/service/config-postgres/run
25+ chmod : " +x"
26+ contents : |
27+ #!/bin/sh
28+ if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then
29+ sleep 5
30+ /usr/local/bin/create_db
31+ if [ ! -z "$DISCOURSE_DB_PASSWORD" ]; then
32+ echo "alter user discourse with password '$DISCOURSE_DB_PASSWORD';" | su - postgres -c 'psql $db_name'
33+ fi
34+ fi
35+
2736 - file :
2837 path : /etc/service/postgres/run
2938 chmod : " +x"
3039 contents : |
3140 #!/bin/sh
3241 exec 2>&1
42+ if [ -f /root/install_postgres ]; then
43+ /root/install_postgres
44+ rm /root/install_postgres
45+ fi
46+ if [ "$CREATE_DB_ON_BOOT" = "1" ]; then
47+ sv once config-postgres
48+ fi
3349 HOME=/var/lib/postgresql USER=postgres exec thpoff chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main
3450
3551 - file :
Original file line number Diff line number Diff line change @@ -14,20 +14,35 @@ hooks:
1414 - replace :
1515 filename : /etc/service/unicorn/run
1616 from : " # postgres"
17- to : |
18- if [ -f /root/install_postgres ]; then
19- /root/install_postgres
20- rm /root/install_postgres
21- fi
22- sv start postgres || exit 1
17+ to : sv start postgres || exit 1
2318
2419run :
20+ - file :
21+ path : /etc/service/config-postgres/run
22+ chmod : " +x"
23+ contents : |
24+ #!/bin/sh
25+ if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then
26+ sleep 5
27+ /usr/local/bin/create_db
28+ if [ ! -z "$DISCOURSE_DB_PASSWORD" ]; then
29+ echo "alter user discourse with password '$DISCOURSE_DB_PASSWORD';" | su - postgres -c 'psql $db_name'
30+ fi
31+ fi
32+
2533 - file :
2634 path : /etc/service/postgres/run
2735 chmod : " +x"
2836 contents : |
2937 #!/bin/sh
3038 exec 2>&1
39+ if [ -f /root/install_postgres ]; then
40+ /root/install_postgres
41+ rm /root/install_postgres
42+ fi
43+ if [ "$CREATE_DB_ON_BOOT" = "1" ]; then
44+ sv once config-postgres
45+ fi
3146 HOME=/var/lib/postgresql USER=postgres exec thpoff chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
3247
3348 - file :
Original file line number Diff line number Diff line change 88 contents : |
99 #!/bin/sh
1010 exec 2>&1
11+ if [ ! -d /shared/redis_data ]; then
12+ install -d -m 0755 -o redis -g redis /shared/redis_data
13+ fi
1114 exec thpoff chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
1215 - file :
1316 path : /etc/service/redis/log/run
8689 - replace :
8790 filename : /etc/service/unicorn/run
8891 from : " # redis"
89- to : |
90- if [ ! -d /shared/redis_data ]; then
91- install -d -m 0755 -o redis -g redis /shared/redis_data
92- fi
93- sv start redis || exit 1
92+ to : sv start redis || exit 1
Original file line number Diff line number Diff line change 6060 if [[ -z "$PRECOMPILE_ON_BOOT" ]]; then
6161 PRECOMPILE_ON_BOOT=1
6262 fi
63- if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then /usr/local/bin/create_db; fi;
64- if [ "$MIGRATE_ON_BOOT" = "1" ]; then su discourse -c 'bundle exec rake db:migrate'; fi
65- if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile'; fi
63+ if [ "$MIGRATE_ON_BOOT" = "1" ]; then su discourse -c 'bundle exec rake db:migrate' || exit 1; fi
64+ if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile' || exit 1; fi
6665 LD_PRELOAD=$RUBY_ALLOCATOR HOME=/home/discourse USER=discourse exec thpoff chpst -u discourse:www-data -U discourse:www-data bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
6766
6867 - file :
You can’t perform that action at this time.
0 commit comments