add pgtap on docker

This commit is contained in:
fpellet 2020-01-19 19:59:27 +01:00
parent c619c0235d
commit 2e4255f35e
3 changed files with 42 additions and 11 deletions

View File

@ -10,14 +10,35 @@ ENV PGDATA /var/lib/postgresql/data_local
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
ADD ./*.sh /app/
ADD ./src /app/src
# PGUNIT
FROM base as pgunit
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates wget \ && apt-get install -y --no-install-recommends ca-certificates wget \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ADD ./*.sh /app/
ADD ./src /app/src
ADD ./pgunit/initialize.sh /app/ ADD ./pgunit/initialize.sh /app/
ADD ./pgunit/*.sql /app/ ADD ./pgunit/*.sql /app/
RUN chmod +x ./*.sh \ RUN chmod +x ./*.sh \
&& ./initializeDocker.sh && ./initializeDocker.sh
# PGTAP
FROM base as pgtap
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates build-essential git-core libv8-dev curl postgresql-server-dev-12 \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /tmp/pgtap \
&& cd /tmp/pgtap \
&& git clone https://github.com/theory/pgtap.git /tmp/pgtap \
&& make \
&& make install \
&& cpan TAP::Parser::SourceHandler::pgTAP
ADD ./pgtap/initialize.sh /app/
RUN chmod +x ./*.sh \
&& ./initializeDocker.sh

View File

@ -1,16 +1,20 @@
version: '3' version: '3.4'
services: services:
database: pgunit:
build: . build:
context: .
target: pgunit
ports: ports:
- "5432:5432" - "5432:5432"
volumes: volumes:
- .:/app/:z - .:/app/:z
admin: pgtap:
image: adminer build:
links: context: .
- database target: pgtap
ports: ports:
- "8081:8080" - "5432:5432"
volumes:
- .:/app/:z

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ex
echo "Enable extension"
psql -d kata -c 'CREATE EXTENSION IF NOT EXISTS pgtap;'