mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Use discourse image for postgres in GitHub Actions (#15291)
The discourse base image already contains a postgres installation, so pulling a separate postgres image is a little wasteful. Using the copy of Postgres in the discourse image saves about 20 seconds on every GitHub actions run. This commit sets up Postgres with a few performance-improving flags, which we were already using for the `rake docker:test` task (used on our internal CI system).
This commit is contained in:
30
script/start_test_db.rb
Executable file
30
script/start_test_db.rb
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
BIN = "/usr/lib/postgresql/#{ENV["PG_MAJOR"]}/bin"
|
||||
DATA = "/tmp/test_data/pg"
|
||||
|
||||
def run(*args)
|
||||
system(*args, exception: true)
|
||||
end
|
||||
|
||||
should_exec = false
|
||||
while a = ARGV.pop
|
||||
if a == "--exec"
|
||||
should_exec = true
|
||||
else
|
||||
raise "Unknown argument #{a}"
|
||||
end
|
||||
end
|
||||
|
||||
run "#{BIN}/initdb -D #{DATA}"
|
||||
|
||||
run "echo fsync = off >> #{DATA}/postgresql.conf"
|
||||
run "echo full_page_writes = off >> #{DATA}/postgresql.conf"
|
||||
run "echo shared_buffers = 500MB >> #{DATA}/postgresql.conf"
|
||||
|
||||
if should_exec
|
||||
exec "#{BIN}/postmaster -D #{DATA}"
|
||||
else
|
||||
run "#{BIN}/pg_ctl -D #{DATA} start"
|
||||
end
|
Reference in New Issue
Block a user