Skip to content

Commit

Permalink
Move all docker testing tools to its own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme committed Jun 13, 2019
1 parent 94dbb79 commit 227e84f
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 29 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
!sql
!src
!test
!entrypoint.sh
!h3.control
!Makefile
25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

29 changes: 29 additions & 0 deletions docker/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG UBUNTU=xenial
FROM ubuntu:${UBUNTU}
ARG UBUNTU
ARG POSTGRESQL=10
ARG POSTGIS=2.4
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git

# xenial needs gnupg-curl for https support
RUN if [ "$UBUNTU" = "xenial" ] ; then apt-get install -y gnupg-curl; fi

# Setup PostgreSQL apt repository
RUN apt-key adv --fetch-keys https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ ${UBUNTU}-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
RUN apt-get update

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-${POSTGRESQL}-postgis-${POSTGIS}-scripts \
postgresql-${POSTGRESQL}-postgis-${POSTGIS} \
postgresql-server-dev-${POSTGRESQL} \
postgresql-${POSTGRESQL}

# Set workdir
WORKDIR /tmp/h3-pg
15 changes: 15 additions & 0 deletions docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG UBUNTU
FROM h3-pg:base-${UBUNTU}
ARG UBUNTU
ARG POSTGRESQL
ARG POSTGIS

COPY . /tmp/h3-pg

RUN make install

USER postgres

CMD service postgresql start && \
psql -c "CREATE EXTENSION postgis;" && \
make installcheck
8 changes: 8 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BASEDIR=$(dirname $(realpath "$0"))
cd $BASEDIR

docker build -f base.Dockerfile -t h3-pg:base ..
docker build -f build.Dockerfile -t h3-pg:build ..

cd ..
docker run --rm -v "$PWD":/tmp/h3-pg h3-pg:build
18 changes: 18 additions & 0 deletions docker/develop.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG UBUNTU
FROM h3-pg:base-${UBUNTU}
ARG UBUNTU
ARG POSTGRESQL
ARG POSTGIS

# Hacky solution to non-root user in CMD
RUN chmod -R a+w \
/usr/share/postgresql/${POSTGRESQL} \
/usr/lib/postgresql/${POSTGRESQL}/lib

USER postgres

CMD service postgresql start && \
psql -c "CREATE EXTENSION postgis;" && \
make install && \
make installcheck && \
make clean
18 changes: 18 additions & 0 deletions docker/pgxn.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG UBUNTU
FROM h3-pg:base-${UBUNTU}
ARG UBUNTU
ARG POSTGRESQL
ARG POSTGIS

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
pgxnclient

RUN pgxnclient install h3

USER postgres

CMD service postgresql start && \
psql -c "CREATE EXTENSION postgis;" && \
pgxnclient load h3 && \
pgxnclient check h3
38 changes: 38 additions & 0 deletions docker/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
BASEDIR=$(dirname $(realpath "$0"))
cd $BASEDIR
cd ..

for UBUNTU in bionic xenial
do
echo "Testing on Ubuntu ${UBUNTU}"

echo " - Building Docker images"
for IMAGE in base build pgxn
do
echo -n " * $IMAGE... "
result=$(docker build \
--build-arg UBUNTU=${UBUNTU} \
-f docker/${IMAGE}.Dockerfile \
-t h3-pg:${IMAGE}-${UBUNTU} \
. 2> /dev/null)
if [[ $? -eq 0 ]] ; then
echo "success"
else
echo "fail:"
echo "$result"
fi
done

echo " - Testing Docker images"
for IMAGE in build pgxn
do
echo -n " * $IMAGE... "
result=$(docker run --rm h3-pg:${IMAGE}-${UBUNTU} 2> /dev/null)
if [[ $? -eq 0 ]] ; then
echo "success"
else
echo "fail:"
echo "$result"
fi
done
done
3 changes: 0 additions & 3 deletions entrypoint.sh

This file was deleted.

0 comments on commit 227e84f

Please sign in to comment.