From 36613df924bf114720b7cc3a0568ee75785580eb Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 12 Dec 2016 17:36:15 +1100 Subject: [PATCH] correct issues with dev image --- image/discourse_dev/Dockerfile | 4 +++ image/discourse_dev/ensure-database | 2 ++ image/discourse_dev/postgres_dev.template.yml | 29 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 image/discourse_dev/postgres_dev.template.yml diff --git a/image/discourse_dev/Dockerfile b/image/discourse_dev/Dockerfile index 071f894..266713e 100644 --- a/image/discourse_dev/Dockerfile +++ b/image/discourse_dev/Dockerfile @@ -25,6 +25,10 @@ ENV LC_ALL en_US.UTF-8 ADD postgres.template.yml /pups/postgres.yml RUN LANG=en_US.UTF-8 /pups/bin/pups /pups/postgres.yml +# add dev databases +ADD postgres_dev.template.yml /pups/postgres_dev.yml +RUN /pups/bin/pups /pups/postgres_dev.yml + # move default postgres_data out of the way RUN mv /shared/postgres_data /shared/postgres_data_orig diff --git a/image/discourse_dev/ensure-database b/image/discourse_dev/ensure-database index e69414e..ec327ef 100755 --- a/image/discourse_dev/ensure-database +++ b/image/discourse_dev/ensure-database @@ -5,4 +5,6 @@ if [ ! -f /shared/postgres_data/PG_VERSION ]; then chown -R postgres:postgres /shared/postgres_data chmod 700 /shared/postgres_data cp -R /shared/postgres_data_orig/* /shared/postgres_data + chown -R postgres:postgres /shared/postgres_data + chmod 700 /shared/postgres_data fi diff --git a/image/discourse_dev/postgres_dev.template.yml b/image/discourse_dev/postgres_dev.template.yml new file mode 100644 index 0000000..91d47a5 --- /dev/null +++ b/image/discourse_dev/postgres_dev.template.yml @@ -0,0 +1,29 @@ +run: + - exec: + background: true + # use fast shutdown for pg + stop_signal: INT + cmd: HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.5/bin/postmaster -D /etc/postgresql/9.5/main + + - exec: + background: true + cmd: exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf + + # give db a few secs to start up + - exec: "sleep 5" + + - exec: su postgres -c 'createdb discourse_development' || true + - exec: su postgres -c 'psql discourse_development -c "grant all privileges on database discourse_development to discourse;"' || true + - exec: su postgres -c 'psql discourse_development -c "alter schema public owner to discourse;"' + - exec: su postgres -c 'psql discourse_development -c "create extension if not exists hstore;"' + - exec: su postgres -c 'psql discourse_development -c "create extension if not exists pg_trgm;"' + + - exec: su postgres -c 'createdb discourse_test' || true + - exec: su postgres -c 'psql discourse_test -c "grant all privileges on database discourse_test to discourse;"' || true + - exec: su postgres -c 'psql discourse_test -c "alter schema public owner to discourse;"' + - exec: su postgres -c 'psql discourse_test -c "create extension if not exists hstore;"' + - exec: su postgres -c 'psql discourse_test -c "create extension if not exists pg_trgm;"' + - exec: cd tmp && git clone https://github.com/discourse/discourse.git --depth=1 && cd /tmp/discourse && sudo -u discourse bundle install + - exec: chown -R discourse /tmp/discourse + - exec: cd /tmp/discourse && sudo -u discourse bundle exec rake db:migrate + - exec: rm -fr /tmp/discourse -- 2.25.1