-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (42 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
61 lines (42 loc) · 1.72 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
ARG PG_MAJOR=14
ARG PG_MINOR=21
ARG ALPINE_VERSION=3.23
FROM registry.cloudogu.com/official/base:3.23.3-6 AS base-image
FROM golang:1.26.1 AS gosu-builder
WORKDIR /gosu-src
# Clone the `gosu` source code and build it
RUN apt-get update && apt-get install -y git \
&& git clone https://github.com/tianon/gosu.git . \
&& git checkout 1.17 \
&& go build -o /usr/local/bin/gosu . \
&& chmod +x /usr/local/bin/gosu
FROM postgres:${PG_MAJOR}.${PG_MINOR}-alpine${ALPINE_VERSION}
ARG PG_MAJOR
LABEL NAME="official/postgresql" \
VERSION="14.21-2" \
maintainer="hello@cloudogu.com"
# change the UID and GID for the postgres-user to 1000 so it matches the volume-mounts
RUN set -eux; \
apk add --no-cache shadow; \
groupmod -g 1000 postgres; \
usermod -u 1000 -g 1000 postgres; \
chown -R 1000:1000 /var/lib/postgresql /var/run/postgresql; \
apk del shadow
# Upgrade all the alpine packages, because postgres base-image brings some cve's piggyback
RUN apk upgrade --no-cache
# === Copy doguctl ===
COPY --from=base-image /usr/local/bin/doguctl /usr/local/bin/
# Copy the `gosu` binary built with the latest Go version
COPY --from=gosu-builder /usr/local/bin/gosu /usr/local/bin/gosu
# Copy migrations scripts
COPY resources/migrations/ /docker-entrypoint-initdb.d/
RUN chmod +x /docker-entrypoint-initdb.d/*.sh
COPY resources/ /
RUN rm -rf /migrations
# Starting from PostgreSQL version 18 PGDATA will be set to be version specific - we already opt-in to
# facilitate migration later - with version 18 this statement can be removed.
ENV PGDATA /var/lib/postgresql/${PG_MAJOR}/docker
HEALTHCHECK --interval=5s CMD doguctl healthy postgresql || exit 1
EXPOSE 5432
ENTRYPOINT ["/startup.sh"]
CMD ["postgres"]