Last active
July 7, 2021 13:13
-
-
Save wlad/90ecad897a2975ec4d7f40a38e8b29ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(wlad㉿pc)-[~/…/vs/github/docker/dockerfiles] | |
└─$ docker build -t ehrbase/ehrbase-postgres:13.3 -f ehrbase-postgresql-db.dockerfile . | |
Sending build context to Docker daemon 13.31kB | |
Step 1/12 : FROM postgres:13.3-alpine | |
---> d3a70afcf848 | |
Step 2/12 : RUN postgres -V && psql -V | |
---> Using cache | |
---> 0a07737e239e | |
Step 3/12 : RUN mkdir -p ${PGDATA} | |
---> Using cache | |
---> f2a1930757df | |
Step 4/12 : RUN chown postgres: ${PGDATA} | |
---> Using cache | |
---> 05cea4ce3fab | |
Step 5/12 : RUN chmod 0700 ${PGDATA} | |
---> Using cache | |
---> 2b856b89e2f5 | |
Step 6/12 : ENV PGDATA="/var/lib/postgresql/pgdata" | |
---> Using cache | |
---> 62050ee42b50 | |
Step 7/12 : RUN su - postgres -c "initdb -D ${PGDATA}" | |
---> Using cache | |
---> 98f815d07ef2 | |
Step 8/12 : COPY scripts/db-setup.sql /postgres/db-setup.sql | |
---> cd2307ea32bc | |
Step 9/12 : RUN su - postgres -c "pg_ctl -D ${PGDATA} -w start" && su - postgres -c "psql < /postgres/db-setup.sql" | |
---> Running in 46f3f88d6fa0 | |
waiting for server to start....2021-07-07 12:54:09.801 UTC [11] LOG: starting PostgreSQL 13.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit | |
2021-07-07 12:54:09.801 UTC [11] LOG: listening on IPv4 address "0.0.0.0", port 5432 | |
2021-07-07 12:54:09.801 UTC [11] LOG: listening on IPv6 address "::", port 5432 | |
2021-07-07 12:54:09.809 UTC [11] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" | |
2021-07-07 12:54:09.818 UTC [12] LOG: database system was shut down at 2021-07-07 12:26:53 UTC | |
2021-07-07 12:54:09.824 UTC [11] LOG: database system is ready to accept connections | |
done | |
server started | |
CREATE ROLE | |
CREATE DATABASE | |
GRANT | |
You are now connected to database "ehrbase" as user "postgres". | |
CREATE SCHEMA | |
CREATE SCHEMA | |
CREATE EXTENSION | |
CREATE EXTENSION | |
ALTER DATABASE | |
GRANT | |
CREATE FUNCTION | |
Removing intermediate container 46f3f88d6fa0 | |
---> 864fad7bcafe | |
Step 10/12 : RUN echo "host all all 0.0.0.0/0 scram-sha-256" >> ${PGDATA}/pg_hba.conf | |
---> Running in 6f0d58ed918e | |
Removing intermediate container 6f0d58ed918e | |
---> 459324b7cd3f | |
Step 11/12 : RUN echo "listen_addresses='*'" >> ${PGDATA}/postgresql.conf | |
---> Running in 4fa253a0257b | |
Removing intermediate container 4fa253a0257b | |
---> 21cae13f7219 | |
Step 12/12 : EXPOSE 5432 | |
---> Running in 23033756710e | |
Removing intermediate container 23033756710e | |
---> 1a4e1a6fb506 | |
Successfully built 1a4e1a6fb506 | |
Successfully tagged ehrbase/ehrbase-postgres:13.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM postgres:13.3-alpine | |
# SHOW POSTGRES DB AND CLIENT VERSION | |
RUN postgres -V && \ | |
psql -V | |
# # SET DEFAULT VALUES FOR DATABASE USER AND PASSWORDS | |
# ARG EHRBASE_USER="ehrbase" | |
# ARG EHRBASE_PASSWORD="ehrbase" | |
# ENV EHRBASE_USER=${EHRBASE_USER} | |
# ENV EHRBASE_PASSWORD=${EHRBASE_PASSWORD} | |
# CREATE CUSTOM DATA DIRECTORY AND CHANGE OWNERSHIP TO POSTGRES USER | |
# SET POSTGRES DATA DIRECTORY TO CUSTOM FOLDER AND INITIALIZE DB | |
RUN mkdir -p ${PGDATA} | |
RUN chown postgres: ${PGDATA} | |
RUN chmod 0700 ${PGDATA} | |
ENV PGDATA="/var/lib/postgresql/pgdata" | |
RUN su - postgres -c "initdb -D ${PGDATA}" | |
# COPY DB SETUP SCRIPT | |
# START DB AND LET THE SCRIPT DO ALL REQUIRED CONFIGURATION | |
COPY scripts/db-setup.sql /postgres/db-setup.sql | |
RUN su - postgres -c "pg_ctl -D ${PGDATA} -w start" && \ | |
su - postgres -c "psql < /postgres/db-setup.sql" | |
# ALLOW CONNECTIONS FROM ALL ADRESSES & LISTEN TO ALL INTERFACES | |
RUN echo "host all all 0.0.0.0/0 scram-sha-256" >> ${PGDATA}/pg_hba.conf | |
RUN echo "listen_addresses='*'" >> ${PGDATA}/postgresql.conf | |
EXPOSE 5432 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output of EHRbase docker container trying to start using above PostgresQSL DB