-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (67 loc) · 2.51 KB
/
Dockerfile
File metadata and controls
84 lines (67 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM ubuntu:jammy AS base
ARG PG_VERSION
# Install packages
RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
ca-certificates curl gnupg make sudo gcc \
&& rm -rf /var/lib/apt/lists/*
# Install PostgreSQL
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt jammy-pgdg main ${PG_VERSION}" > /etc/apt/sources.list.d/pgdg.list
RUN if [ "${PG_VERSION}" = "18" ] ; then \
echo "deb http://apt.postgresql.org/pub/repos/apt jammy-pgdg-snapshot main ${PG_VERSION}" >> /etc/apt/sources.list.d/pgdg.list; \
echo "Package: *\nPin: release a=jammy-pgdg-snapshot\nPin-Priority: 900" > /etc/apt/preferences.d/99pgdg; \
fi
# Install PostgreSQL
RUN apt update \
&& DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
libcurl4-gnutls-dev libhttp-server-simple-perl libipc-run-perl \
postgresql-server-dev-${PG_VERSION} \
postgresql-${PG_VERSION} \
&& rm -rf /var/lib/apt/lists/*
RUN adduser postgres sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
#
# Build pg_tracing for a given --build-arg PG_VERSION target version of
# PostgreSQL.
#
FROM base AS build
ARG PG_VERSION
USER postgres
WORKDIR /usr/src/pg_tracing
RUN mkdir src
# Copy sources and compile
COPY --chown=postgres common.mk ./
COPY --chown=postgres Makefile ./
COPY --chown=postgres Makefile.dist ./
COPY --chown=postgres META.json.in ./
COPY --chown=postgres typedefs.list ./
COPY --chown=postgres *.sql ./
COPY --chown=postgres pg_tracing.control ./
COPY --chown=postgres ./src/*.c ./src
COPY --chown=postgres ./src/*.h ./src
COPY --chown=postgres pg_tracing.conf ./pg_tracing.conf
# Copy test files
COPY --chown=postgres ./sql/ ./sql
COPY --chown=postgres ./t/ ./t
COPY --chown=postgres ./regress/ ./regress
COPY --chown=postgres ./expected/ ./expected
# Create empty results for mount bind
# Used to copy test results and update expected output
RUN mkdir results
RUN chown postgres:postgres results
# Compile
RUN make -s
# And install
RUN sudo make -s install -j8
# Create test cluster
RUN /usr/lib/postgresql/${PG_VERSION}/bin/initdb -D /usr/src/pg_tracing/test_db/ -Atrust
COPY --chown=postgres tests/postgresql.conf /usr/src/pg_tracing/test_db/
#
# Given the build image above, we can now run our test suite targetting a
# given version of Postgres.
#
FROM build AS test
ARG PG_VERSION
USER postgres
ENV PATH=/usr/lib/postgresql/${PG_VERSION}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin