Started building Docker test environment

This commit is contained in:
Ben Merritt 2017-03-13 19:11:05 +00:00
parent 9772c52322
commit c73715bd65
3 changed files with 40 additions and 0 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
# TODO: make version variable?
FROM postgres:9.6
RUN apt-get update && apt-get install -y \
build-essential \
postgresql-server-dev-9.6 \
libphonenumber6 \
sudo
CMD ["/data/run-tests.sh"]
COPY ./ /data/
RUN chown -R postgres:postgres /data/
# Patch the entrypoint script so it always initializes the DB.
RUN patch /usr/local/bin/docker-entrypoint.sh < /data/docker-entrypoint.patch
WORKDIR /data
RUN make && make install

13
docker-entrypoint.patch Normal file
View File

@ -0,0 +1,13 @@
32c32,33
< if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
---
> #if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
> if [ "$(id -u)" = '0' ]; then
44c45
< if [ "$1" = 'postgres' ]; then
---
> #if [ "$1" = 'postgres' ]; then
130c131
< fi
---
> #fi

8
run-tests.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/sh
PGDATA=/var/lib/postgresql/data
# TODO: don't hard-code version here.
pg_ctl=/usr/lib/postgresql/9.6/bin/pg_ctl
gosu postgres $pg_ctl "--pgdata=$PGDATA" start -w
gosu postgres make installcheck
gosu postgres $pg_ctl "--pgdata=$PGDATA" stop