Skip to content

Commit 32b07bd

Browse files
feat: add pgTAP and pg_prove (CircleCI-Public#81)
* feat: add pgTAP and pg_prove * feat: reduce layer count, optimize git clone
1 parent 9e106bf commit 32b07bd

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Dockerfile.template

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ENV POSTGRES_HOST_AUTH_METHOD=trust
1616
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
1717
ENV PGDATA /var/lib/postgresql/data
1818
ENV POSTGRES_DB=circle_test
19+
ENV PGTAP_VERSION 1.2.0
1920

2021
USER root
2122
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -79,22 +80,30 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7980

8081
# clones pg_cron extension for local use, this is not available wihout installing
8182
# run this as a separate layer so it caches better
82-
RUN git clone https://github.com/citusdata/pg_cron.git /pg_cron && \
83+
RUN git clone --depth 1 https://github.com/citusdata/pg_cron.git /pg_cron && \
8384
cd /pg_cron && make && PATH=$PATH make install
8485

85-
RUN mkdir /docker-entrypoint-initdb.d
86+
# Install pgTAP & pg_prove utility.
87+
RUN git clone --depth 1 -b "v$PGTAP_VERSION" https://github.com/theory/pgtap.git /pgtap && \
88+
cd /pgtap && make && make install && \
89+
curl -sL https://cpanmin.us | perl - App::cpanminus && \
90+
cpanm -n TAP::Parser::SourceHandler::pgTAP
8691

92+
# Enable extensions
93+
RUN mkdir /docker-entrypoint-initdb.d && \
94+
echo "CREATE EXTENSION pgtap;" > /docker-entrypoint-initdb.d/pgtap.sql
8795
COPY pg_cron.sh /docker-entrypoint-initdb.d/
96+
8897
COPY custom-postgresql.conf /etc/postgresql/custom-postgresql.conf
8998
COPY docker-entrypoint.sh /usr/local/bin/
99+
# Backwards compatibility
100+
RUN ln -s usr/local/bin/docker-entrypoint.sh /
90101

91-
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
92-
93-
RUN chmod +x /usr/local/bin/docker-entrypoint.sh /docker-entrypoint-initdb.d/pg_cron.sh
94-
RUN mkdir -p /var/lib/postgresql && \
102+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh /docker-entrypoint-initdb.d/pg_cron.sh && \
103+
mkdir -p /var/lib/postgresql && \
95104
chown -R postgres:postgres /var/lib/postgresql && \
96105
chown -R postgres:postgres /usr/local/bin/docker-entrypoint.sh && \
97-
rm -rf /pg_cron
106+
rm -rf /pg_cron /pgtap
98107

99108
ENTRYPOINT ["docker-entrypoint.sh"]
100109
STOPSIGNAL SIGINT

0 commit comments

Comments
 (0)