File: Dockerfile.debian

package info (click to toggle)
postgresql-set-user 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 272 kB
  • sloc: ansic: 675; sql: 250; makefile: 36; sh: 6
file content (39 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download
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
FROM ubuntu:latest

# Install packages
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo wget gnupg tzdata locales lsb-release apt-utils make gcc libssl-dev \
    libkrb5-dev

# PostgreSQL version
ARG PGVER=18

# Remove the default ubuntu user to reduce the chance of a conflict with the host user
RUN userdel ubuntu

# Create postgres user/group with specific IDs
ARG UID=1000
ARG GID=1000

RUN groupadd -g $GID -o postgres
RUN useradd -m -u $UID -g $GID -o -s /bin/bash postgres

# Add PostgreSQL repository
RUN apt-get install -y --no-install-recommends postgresql-common
RUN /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y -c 18

# Install PostgreSQL
RUN apt-get install -y postgresql-${PGVER?} postgresql-server-dev-${PGVER?}

# Create PostgreSQL cluster
ENV PGBIN=/usr/lib/postgresql/${PGVER}/bin
ENV PGDATA="/var/lib/postgresql/${PGVER}/test"
ENV PATH="${PATH}:${PGBIN}"

RUN sudo -u postgres ${PGBIN?}/initdb -A trust -k ${PGDATA?}
RUN echo "shared_preload_libraries = 'set_user'" >> ${PGDATA}/postgresql.conf

# Configure sudo
RUN echo 'postgres ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER postgres