FROM postgres:17.2 ARG USER_ID ARG GROUP_ID RUN apt-get update && apt-get install -y sudo; RUN addgroup --gid ${GROUP_ID} postgres || \ groupmod --gid ${GROUP_ID} postgres RUN adduser --gecos 'PostGres' --uid ${USER_ID} --gid ${GROUP_ID} --disabled-password postgres || \ usermod --uid ${USER_ID} --gid ${GROUP_ID} postgres && passwd -d postgres RUN echo 'postgres ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN usermod -G root,sudo postgres RUN chown -R postgres:postgres /var/lib/postgresql \ && chown -R postgres:postgres /var/run/postgresql USER postgres LABEL "name"="postgresX"