-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile_Db
More file actions
52 lines (52 loc) · 2.02 KB
/
Dockerfile_Db
File metadata and controls
52 lines (52 loc) · 2.02 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#
FROM ubuntu:24.04
WORKDIR /home/app
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y sudo
RUN apt-get install -y apt-utils
ENV TZ=America/Denver
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
RUN apt-get install -y tzdata
RUN echo "=== Done installing Ubuntu."
#
###
RUN apt-get install -y postgresql-16
RUN apt-cache policy postgresql-16
RUN apt-get install -y postgresql-server-dev-16
RUN apt-get install -y postgresql-16-rdkit
COPY conf/postgresql/pg_hba.conf /etc/postgresql/16/main/
RUN chmod 640 /etc/postgresql/16/main/pg_hba.conf
RUN chown postgres /etc/postgresql/16/main/pg_hba.conf
COPY conf/postgresql/postgresql.conf /etc/postgresql/16/main/
RUN chmod 644 /etc/postgresql/16/main/postgresql.conf
RUN chown postgres /etc/postgresql/16/main/postgresql.conf
RUN echo "=== Done installing PostgreSQL."
#
RUN mkdir -p /home/data/BiomarkerDB
COPY data/biomarkerdb.pgdump /home/data/BiomarkerDB/
RUN echo "=== Done copying db data."
#
# Note that user postgres must start db differently than user root.
USER postgres
RUN pg_config
ENV dbname=biomarkerdb
ENV dbusr=bio
ENV dbpw=marker
RUN /etc/init.d/postgresql start && \
psql -c "CREATE ROLE ${dbusr} WITH LOGIN PASSWORD '${dbpw}'" && \
createdb -O postgres ${dbname} && \
pg_restore -v --no-owner --schema public -d ${dbname} /home/data/BiomarkerDB/${dbname}.pgdump && \
psql -d ${dbname} -c "GRANT USAGE ON SCHEMA public TO ${dbusr}" && \
psql -d ${dbname} -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${dbusr}" && \
psql -d ${dbname} -c "GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO ${dbusr}" && \
psql -d ${dbname} -c "GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO ${dbusr}" && \
echo "=== Done loading ${dbname}." && \
psql -l
USER root
RUN service postgresql stop
RUN echo "=== Done instantiating and loading dbs."
#
# CMD must be in foreground.
CMD ["sudo", "-u", "postgres", "/usr/lib/postgresql/16/bin/postgres", "-D", "/var/lib/postgresql/16/main", "-c", "config_file=/etc/postgresql/16/main/postgresql.conf"]
#