File tree Expand file tree Collapse file tree 5 files changed +52
-22
lines changed Expand file tree Collapse file tree 5 files changed +52
-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 '; 
4244cmd : su - postgres -c 'psql discourse' 
4345
4446        raise_on_fail : false 
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+ 
2533file :
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/15/bin/postmaster -D /etc/postgresql/15/main 
3247
3348file :
Original file line number Diff line number Diff line change @@ -15,20 +15,35 @@ hooks:
1515    - replace :
1616       filename : /etc/service/unicorn/run 
1717       from : " # postgres" 
18-        to : | 
19-          if [ -f /root/install_postgres ]; then 
20-            /root/install_postgres 
21-            rm /root/install_postgres 
22-          fi 
23-          sv start postgres || exit 1 
18+        to : sv start postgres || exit 1 
2419
2520run :
21+   - file :
22+      path : /etc/service/config-postgres/run 
23+      chmod : " +x" 
24+      contents : | 
25+        #!/bin/sh 
26+        if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then 
27+          sleep 5 
28+          /usr/local/bin/create_db 
29+          if [ ! -z "$DISCOURSE_DB_PASSWORD" ]; then 
30+            echo "alter user discourse with password '$DISCOURSE_DB_PASSWORD';" | su - postgres -c 'psql $db_name' 
31+          fi 
32+        fi 
33+ 
2634file :
2735     path : /etc/service/postgres/run 
2836     chmod : " +x" 
2937     contents : | 
3038        #!/bin/sh 
3139        exec 2>&1 
40+         if [ -f /root/install_postgres ]; then 
41+           /root/install_postgres 
42+           rm /root/install_postgres 
43+         fi 
44+         if [ "$CREATE_DB_ON_BOOT" = "1" ]; then 
45+           sv once config-postgres 
46+         fi 
3247        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 
3348
3449file :
Original file line number Diff line number Diff line change 99     contents : | 
1010        #!/bin/sh 
1111        exec 2>&1 
12+         if [ ! -d /shared/redis_data ]; then 
13+           install -d -m 0755 -o redis -g redis /shared/redis_data 
14+         fi 
1215        exec thpoff chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf 
1316file :
1417     path : /etc/service/redis/log/run 
8790    - replace :
8891       filename : /etc/service/unicorn/run 
8992       from : " # redis" 
90-        to : | 
91-          if [ ! -d /shared/redis_data ]; then 
92-            install -d -m 0755 -o redis -g redis /shared/redis_data 
93-          fi 
94-          sv start redis || exit 1 
93+        to : sv start redis || exit 1 
Original file line number Diff line number Diff line change 6161        if [[ -z "$PRECOMPILE_ON_BOOT" ]]; then 
6262          PRECOMPILE_ON_BOOT=1 
6363        fi 
64-         if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then /usr/local/bin/create_db; fi; 
65-         if [ "$MIGRATE_ON_BOOT" = "1" ]; then su discourse -c 'bundle exec rake db:migrate'; fi 
66-         if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile'; fi 
64+         if [ "$MIGRATE_ON_BOOT" = "1" ]; then su discourse -c 'bundle exec rake db:migrate' || exit 1; fi 
65+         if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile' || exit 1; fi 
6766        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 
6867
6968file :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments