feat: Fix Docker test image

This commit is contained in:
Ben Merritt 2017-07-06 10:07:28 -07:00
parent f84f7bb4b8
commit 4179c4d1ff
3 changed files with 27 additions and 15 deletions

View File

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

View File

@ -1,4 +1,4 @@
# pg-libphonenumber # pg_libphonenumber
A (partially implemented!) PostgreSQL extension that provides access to A (partially implemented!) PostgreSQL extension that provides access to
[Google's `libphonenumber`](https://github.com/googlei18n/libphonenumber) [Google's `libphonenumber`](https://github.com/googlei18n/libphonenumber)
@ -31,9 +31,10 @@ First you'll need to install `libphonenumber-dev` and the corresponding
`postgresql-server-dev` package. `postgresql-server-dev` package.
```shell-script ```shell-script
sudo apt-get install build-essential sudo apt-get update && sudo apt-get install \
sudo apt-get install postgresql-server-dev-9.5 build-essential \
sudo apt-get install libphonenumber-dev postgresql-server-dev-9.6 \
libphonenumber-dev
``` ```
Then clone this repository and build. Then clone this repository and build.
@ -44,3 +45,12 @@ cd pg-libphonenumber
make make
sudo make install sudo make install
``` ```
## Running tests
For convenience, we provide a Docker image that sets up a test environment.
```shell-script
make docker-image
docker run pg_libphonenumber
```

View File

@ -1,8 +1,10 @@
#!/bin/sh #!/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
# Used in the Docker image to run tests
PGDATA=/var/lib/postgresql/data
# Reads PG_MAJOR from the environment
pg_ctl=/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl
$pg_ctl "--pgdata=${PGDATA}" start -w
make installcheck
$pg_ctl "--pgdata=${PGDATA}" stop