-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
146 lines (108 loc) · 5.59 KB
/
Copy pathDockerfile.alpine
File metadata and controls
146 lines (108 loc) · 5.59 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# renovate: datasource=repology depName=homebrew/postgresql@18 versioning=loose
ARG PGTARGET=18.0
# renovate: datasource=docker depName=alpine versioning=loose
ARG ALPINE_VERSION=3.23
### Things we need in all build containers
FROM alpine:${ALPINE_VERSION} AS base-build
# renovate: datasource=repology depName=homebrew/postgresql@13 versioning=loose
ENV PG13=13.23
# renovate: datasource=repology depName=homebrew/postgresql@14 versioning=loose
ENV PG14_VERSION=14.23
# renovate: datasource=repology depName=homebrew/postgresql@15 versioning=loose
ENV PG15_VERSION=15.18
# renovate: datasource=repology depName=homebrew/postgresql@16 versioning=loose
ENV PG16_VERSION=16.14
# renovate: datasource=repology depName=homebrew/postgresql@17 versioning=loose
ENV PG17_VERSION=17.10
# Where we'll do all our compiling and similar
ENV BUILD_ROOT=/buildroot
# Make the directory for building, and set it as the default for the following Docker commands
RUN mkdir ${BUILD_ROOT}
WORKDIR ${BUILD_ROOT}
# Install things needed for development
# We might want to install "alpine-sdk" instead of "build-base", if build-base
# doesn't have everything we need
RUN apk update && \
apk add --update build-base icu-data-full icu-dev linux-headers lz4-dev musl musl-locales musl-utils tzdata zlib-dev zstd-dev && \
apk cache clean
### PostgreSQL 13
FROM base-build AS build-13
RUN wget https://ftp.postgresql.org/pub/source/v${PG13}/postgresql-${PG13}.tar.bz2 && \
tar -xf postgresql-13*.tar.bz2
RUN cd postgresql-13.* && \
./configure --prefix=/usr/local-pg13 --with-openssl=no --without-readline --with-icu --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) world-bin && \
make install-world-bin && \
rm -rf /usr/local-pg13/include
### PostgreSQL 14
FROM base-build AS build-14
RUN wget https://ftp.postgresql.org/pub/source/v${PG14_VERSION}/postgresql-${PG14_VERSION}.tar.bz2 && \
tar -xf postgresql-14*.tar.bz2
RUN cd postgresql-14.* && \
./configure --prefix=/usr/local-pg14 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) world-bin && \
make install-world-bin && \
rm -rf /usr/local-pg14/include
### PostgreSQL 15
FROM base-build AS build-15
RUN wget https://ftp.postgresql.org/pub/source/v${PG15_VERSION}/postgresql-${PG15_VERSION}.tar.bz2 && \
tar -xf postgresql-15*.tar.bz2
RUN cd postgresql-15.* && \
./configure --prefix=/usr/local-pg15 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) world-bin && \
make install-world-bin && \
rm -rf /usr/local-pg15/include
### PostgreSQL 16
FROM base-build AS build-16
RUN wget https://ftp.postgresql.org/pub/source/v${PG16_VERSION}/postgresql-${PG16_VERSION}.tar.gz && \
tar -xf postgresql-16*.tar.gz
RUN cd postgresql-16.* && \
./configure --prefix=/usr/local-pg16 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) world-bin && \
make install-world-bin && \
rm -rf /usr/local-pg16/include
### PostgreSQL 17
FROM base-build AS build-17
RUN apk add --no-cache bison flex perl
RUN wget https://ftp.postgresql.org/pub/source/v${PG17_VERSION}/postgresql-${PG17_VERSION}.tar.gz && \
tar -xf postgresql-17*.tar.gz
RUN cd postgresql-17.* && \
./configure --prefix=/usr/local-pg17 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) world-bin && \
make install-world-bin && \
rm -rf /usr/local-pg17/include
# Use the PostgreSQL Alpine image as our output image base
FROM postgres:${PGTARGET}-alpine${ALPINE_VERSION}
# Copy default configuration in case the original container does not provide it (Bitnami ...)
RUN mkdir -p /opt/pgautoupgrade && \
chmod 660 /opt/pgautoupgrade && \
chown 999:999 /opt/pgautoupgrade
COPY --chown=999 postgresql.conf pg_hba.conf /opt/pgautoupgrade/
# We need to define this here, to make the above PGTARGET available after the FROM
ARG PGTARGET
# Copy across our compiled files
COPY --from=build-13 /usr/local-pg13 /usr/local-pg13
COPY --from=build-14 /usr/local-pg14 /usr/local-pg14
COPY --from=build-15 /usr/local-pg15 /usr/local-pg15
COPY --from=build-16 /usr/local-pg16 /usr/local-pg16
COPY --from=build-17 /usr/local-pg17 /usr/local-pg17
# Remove any left over PG directory stubs. Doesn't help with image size, just with clarity on what's in the image.
RUN if [ "${PGTARGET}" == "${PG14_VERSION}" ]; then rm -rf /usr/local-pg14 /usr/local-pg15 /usr/local-pg16 /usr/local-pg17; fi
RUN if [ "${PGTARGET}" == "${PG15_VERSION}" ]; then rm -rf /usr/local-pg15 /usr/local-pg16 /usr/local-pg17; fi
RUN if [ "${PGTARGET}" == "${PG16_VERSION}" ]; then rm -rf /usr/local-pg16 /usr/local-pg17; fi
RUN if [ "${PGTARGET}" == "${PG17_VERSION}" ]; then rm -rf /usr/local-pg17; fi
# Install locale
RUN apk update && \
apk add --update icu-data-full musl musl-utils musl-locales tzdata && \
apk cache clean
## FIXME: Only useful while developing this Dockerfile
##RUN apk add man-db man-pages-posix
# Pass the PG build target through to the running image
ENV PGTARGET=${PGTARGET}
# Copy across all our shell scripts
COPY pgautoupgrade-healthcheck.sh postgres-docker-entrypoint.sh docker-entrypoint.sh /usr/local/bin/
# Set up the script run by the container when it starts
WORKDIR /var/lib/postgresql
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
HEALTHCHECK CMD /usr/local/bin/pgautoupgrade-healthcheck.sh
CMD ["postgres"]