dulhaver

Dockerfile

Jan 31st, 2022 (edited)
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.54 KB | None | 0 0
  1. ARG REGISTRY=docker-dev-local.intern.net
  2. ARG BASE_IMAGE_REPO=scm
  3. ARG BASE_IMAGE_NAME=debian-bullseye
  4. ARG BASE_IMAGE_TAG=latest
  5.  
  6. # Second stage - create runtime image
  7. # -----------------------------------
  8. #FROM debian:11 as base
  9. #FROM docker-dev-local.intern.net/scm/debian-bullseye:build-74 as base
  10. FROM $REGISTRY/$BASE_IMAGE_REPO/$BASE_IMAGE_NAME:$BASE_IMAGE_TAG
  11.  
  12. # Maintainer
  13. # ----------
  14. LABEL org.opencontainers.image.authors="<[email protected]>"
  15.  
  16. # Build Environment variables, change as needed
  17. # -------------------------------------------------------------
  18. ARG PG_MAJOR=14
  19. ARG PG_VERSION=14.1
  20. ARG DIST_VERSION=deb11
  21. ARG DVZ_BUILD=dvz1
  22. ENV DVZ_REPO_URL=http://dvzsn-rd1115.dbmon.intern.net/scb-repo
  23.  
  24. # Environment variables required for this build (do NOT change)
  25. # -------------------------------------------------------------
  26. ENV PG_MAJOR=${PG_MAJOR}
  27. ENV PG_VERSION=${PG_VERSION}
  28. ENV PGUSER=postgres
  29. ENV PGDATABASE=postgres
  30. ENV PGPORT=5432
  31. ENV DBBASE=/opt/db
  32. ENV PGBASE=$DBBASE/postgres
  33. ENV PGBIN=$PGBASE/bin
  34. ENV PGHOME=$PGBASE/postgresql
  35. ENV PGDATA=$DBBASE/data/postgres/data
  36. ENV PGLOG=$PGDATA/log
  37. ENV PGBACK=$DBBASE/backup/postgres/backups
  38. ENV PGARCH=$DBBASE/backup/postgres/archives
  39.  
  40. ENV PATH=$PGHOME/bin:$PATH
  41.  
  42. ENV LANG=de_DE.UTF-8
  43. ENV LC_MESSAGES=en_US.UTF-8
  44. ENV TZ=Europe/Berlin
  45.  
  46. RUN env | sort
  47.  
  48. # Install additional packages and dependencies
  49. # --------------------------------------------
  50. RUN set -ex; \
  51.     apt-get update && \
  52.     apt-get upgrade && \
  53.     apt-get install -y --no-install-recommends \
  54.         ca-certificates \
  55.         curl \
  56.         dirmngr \
  57.         gnupg \
  58.         iproute2 \
  59.         less \
  60.         libnss-wrapper \
  61.         libpam0g \
  62.         libreadline8 \
  63.         libselinux1 \
  64.         libsystemd0 \
  65.         libxml2 \
  66.         locales \
  67.         openssl \
  68.         procps \
  69.         vim-tiny \
  70.         wget \
  71.         xz-utils \
  72.         zlib1g \
  73.     && \
  74.     apt-get clean
  75.  
  76. # create locales for en_US and de_DE
  77. RUN localedef -i en_US -f UTF-8 en_US.UTF-8 && \
  78.     localedef -i de_DE -f UTF-8 de_DE.UTF-8 && \
  79.     locale -a
  80.  
  81. # Set up user and directories
  82. # ---------------------------
  83. RUN mkdir -p $PGBASE $PGBIN $PGDATA $PGBACK $PGARCH && \
  84.     useradd -d /home/postgres -m -s /bin/bash --no-log-init postgres && \
  85.     chown -R postgres:postgres $PGBASE $PGDATA $PGBACK $PGARCH $DBBASE/data && \
  86.     chmod a+xr $PGBASE
  87.  
  88. # set up user env
  89. # ---------------
  90. USER postgres
  91. COPY --chown=postgres:postgres ["files/.alias", "files/.bashrc", "files/postgresql.conf.${PG_MAJOR}", "files/conf.d/00-ina-default.conf", "/hom
  92. COPY ["files/docker-entrypoint.sh", "/"]
  93. ADD ["files/pg-docker-env.tar.gz", "$PGBASE/"]
  94.  
  95. # install postgres
  96. # --------------------
  97. # copy postgres package from builder stage
  98. #RUN mkdir -p $PGBASE/postgresql-$PG_VERSION-$DIST_VERSION-$DVZ_BUILD
  99. #COPY --from=build --chown=postgres:postgres ["$PGBASE/postgresql-$PG_VERSION-$DIST_VERSION-$DVZ_BUILD", "$PGBASE/postgresql-$PG_VERSION-$DIST_
  100. # download build of postgres
  101. WORKDIR $PGBASE
  102. RUN curl -sSL $DVZ_REPO_URL/postgres/Linux/$DIST_VERSION/postgresql-$PG_VERSION-$DIST_VERSION-dvz1.tar.gz | tar xzf - -C $PGBASE
  103. RUN ln -s $PGBASE/postgresql-$PG_VERSION-$DIST_VERSION-$DVZ_BUILD postgresql
  104.  
  105. # bindings
  106. # --------
  107. VOLUME ["$PGDATA", "$PGBACK", "$PGARCH"]
  108. STOPSIGNAL SIGINT
  109. EXPOSE 5432
  110. HEALTHCHECK --interval=1m --start-period=5m \
  111.    CMD pg_ctl status >/dev/null || exit 1
  112.  
  113. # Define default command to start Database.
  114. ENTRYPOINT ["/docker-entrypoint.sh"]
  115. CMD ["postgres", "-D", "/opt/db/data/postgres/data"]
Add Comment
Please, Sign In to add comment