diff --git a/images/postgres/Dockerfile b/images/postgres/Dockerfile index 7ae7a1e..f0c2fbb 100644 --- a/images/postgres/Dockerfile +++ b/images/postgres/Dockerfile @@ -35,15 +35,13 @@ RUN mkdir -p \ && cp /lib64/ld-linux-x86-64.so.2 ~/rootfs/lib64 \ && cp /bin/sh ~/rootfs/bin \ && cp -a ~/out/. ~/rootfs/ \ - && chmod -R 700 ~/rootfs/data/ \ - && echo "listen_addresses='*'" > ~/rootfs/config/postgresql.conf \ - && echo "data_directory='/data'" >> ~/rootfs/config/postgresql.conf + && chmod -R 700 ~/rootfs/data/ FROM scratch COPY --from=build --chown=100:100 /home/build/rootfs / STOPSIGNAL SIGQUIT EXPOSE 5432 USER 100:100 -ENV PGDATA=/config +ENV PGDATA=/data ENV PATH=/bin ENTRYPOINT ["/bin/postgres"] diff --git a/pods/userdb/deployment.yaml b/pods/userdb/deployment.yaml index 1965c0b..4cffd24 100644 --- a/pods/userdb/deployment.yaml +++ b/pods/userdb/deployment.yaml @@ -46,14 +46,13 @@ spec: command: ["/bin/sh", "-c"] args: - set -e; - [ -z "$(ls -A /data )" ] || exit 0; + [ -f "/data/PG_VERSION" ] && exit 0; initdb /data; + postgres & + until pg_isready >/dev/null 2>&1; do true; done; echo 'create database userdb;' > /tmp/createdb.sql; - postgres --single -Ej "postgres" < /tmp/createdb.sql; - postgres --single -Ej "userdb" < /schema/bundle.sql; - securityContext: - runAsUser: 100 - runAsGroup: 100 + psql -d "postgres" < /tmp/createdb.sql; + psql -d "userdb" < /schema/bundle.sql; containers: - name: postgres image: registry.localhost:5000/postgres @@ -61,11 +60,10 @@ spec: - name: tcp containerPort: 5432 volumeMounts: - - mountPath: /data - name: userdb-data - volumeMounts: - - mountPath: /schema - name: userdb-schema + - name: userdb-data + mountPath: /data + - name: userdb-schema + mountPath: /schema env: - name: PGPASSWORD valueFrom: