Difference between revisions of "Dockerfile.isodb.vanilla"

From Cactus Howto
Jump to navigationJump to search
Line 5: Line 5:
# Add the PostgreSQL PGP key to verify their Debian packages.
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8


# Add PostgreSQL's repository. It contains the most recent stable release of PostgreSQL, 9.3.
# Add PostgreSQL's repository. It contains the most recent stable release of PostgreSQL, 9.3.
#RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list


# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
#RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
RUN apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
#RUN apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3


# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
COPY install /install
USER postgres
USER postgres
ENV ISODB isodb
ENV ISODB isodb
ENV SQLDIR /install/database/stored-procedures
ENV SQLDIR /install/database/stored-procedures
ENV DATADIR /install/database/csv-data
ENV DATADIR /install/database/csv-data

RUN /etc/init.d/postgresql start && psql -c "CREATE USER itsecorg WITH PASSWORD 'xxx';" && createdb --owner itsecorg $ISODB
COPY install /install
RUN cat /install/database/conf/pg_hba.conf >> /etc/postgresql/9.3/main/pg_hba.conf
RUN cat /install/database/conf/pg_hba.conf >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
EXPOSE 5432


#RUN createlang -d $ISODB plpgsql
# && createlang -d $ISODB plpgsql && \
#RUN psql -d $ISODB -c "\i $SQLDIR/itsecorg-db-model.sql"
RUN /etc/init.d/postgresql start && psql -c "CREATE USER itsecorg WITH PASSWORD 'ixüpsz';" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-basic-procs.sql"
&& createdb --owner itsecorg $ISODB && psql -d $ISODB -c "\i $SQLDIR/itsecorg-db-model.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-basic-procs.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-import-main.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-obj-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-import-main.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-obj-refs.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-obj-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-svc-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-obj-refs.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-svc-refs.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-svc-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-usr-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-svc-refs.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-usr-refs.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-usr-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-rule-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-usr-refs.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-rule-refs.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-rule-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-zone-import.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-rule-refs.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-report.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-zone-import.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-report-basics.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-report.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-views-drop.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-report-basics.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-views.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-views-drop.sql" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-grants.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-views.sql" \
&& psql -d $ISODB -c "\i $SQLDIR/iso-grants.sql" \
#
#RUN psql -d $ISODB -c "\copy stm_color (color_name,color_rgb) FROM '$DATADIR/color.csv' DELIMITER ';' CSV"
&& psql -d $ISODB -c "\copy stm_color (color_name,color_rgb) FROM '$DATADIR/color.csv' DELIMITER ';' CSV" \
#RUN psql -d $ISODB -c "\copy error (error_id,error_lvl,error_txt_ger,error_txt_eng) FROM '$DATADIR/error.csv' DELIMITER ';' CSV"
&& psql -d $ISODB -c "\copy error (error_id,error_lvl,error_txt_ger,error_txt_eng) FROM '$DATADIR/error.csv' DELIMITER ';' CSV" \
#RUN psql -d $ISODB -c "\copy stm_ip_proto (ip_proto_id,ip_proto_name,ip_proto_comment) FROM '$DATADIR/ip-protocol-list.csv' DELIMITER ';' CSV"
&& psql -d $ISODB -c "\copy stm_ip_proto (ip_proto_id,ip_proto_name,ip_proto_comment) FROM '$DATADIR/ip-protocol-list.csv' DELIMITER ';' CSV" \
#RUN psql -d $ISODB -c "\copy text_msg (text_msg_id,text_msg_ger,text_msg_eng) FROM '$DATADIR/text_msg.csv' DELIMITER ';' CSV"
&& psql -d $ISODB -c "\copy text_msg (text_msg_id,text_msg_ger,text_msg_eng) FROM '$DATADIR/text_msg.csv' DELIMITER ';' CSV" \
#RUN psql -d $ISODB -c "\i $SQLDIR/iso-fill-stm.sql"
&& psql -d $ISODB -c "\i $SQLDIR/iso-fill-stm.sql"
#RUN psql -d $ISODB -c "\i $SAMPLEDIR/iso-fill-samples.sql"
# && psql -d $ISODB -c "\i $SAMPLEDIR/iso-fill-samples.sql" \
#RUN psql -d $ISODB -c "\i $SAMPLEDIR/iso-user.sql"
# && psql -d $ISODB -c "\i $SAMPLEDIR/iso-user.sql"


EXPOSE 5432


# Add VOLUMEs to allow backup of config, logs and databases
# Add VOLUMEs to allow backup of config, logs and databases

Revision as of 17:55, 20 December 2014

FROM ubuntu:14.04.1
MAINTAINER itsecorg@cactus.de

# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8

# Add PostgreSQL's repository. It contains the most recent stable release of PostgreSQL, 9.3.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list

# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
#  There are some warnings (in red) that show up during the build. You can hide
#  them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
#RUN apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3

# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
COPY install /install
USER postgres
ENV ISODB isodb
ENV SQLDIR /install/database/stored-procedures
ENV DATADIR /install/database/csv-data
RUN cat /install/database/conf/pg_hba.conf >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf

#   && createlang -d $ISODB plpgsql && \
RUN /etc/init.d/postgresql start && psql -c "CREATE USER itsecorg WITH PASSWORD 'ixüpsz';" \
   && createdb --owner itsecorg $ISODB && psql -d $ISODB -c "\i $SQLDIR/itsecorg-db-model.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-basic-procs.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-import-main.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-obj-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-obj-refs.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-svc-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-svc-refs.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-usr-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-usr-refs.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-rule-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-rule-refs.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-zone-import.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-report.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-report-basics.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-views-drop.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-views.sql" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-grants.sql" \
   && psql -d $ISODB -c "\copy stm_color (color_name,color_rgb) FROM '$DATADIR/color.csv' DELIMITER ';' CSV" \
   && psql -d $ISODB -c "\copy error (error_id,error_lvl,error_txt_ger,error_txt_eng) FROM '$DATADIR/error.csv' DELIMITER ';' CSV" \
   && psql -d $ISODB -c "\copy stm_ip_proto (ip_proto_id,ip_proto_name,ip_proto_comment) FROM '$DATADIR/ip-protocol-list.csv' DELIMITER ';' CSV" \
   && psql -d $ISODB -c "\copy text_msg (text_msg_id,text_msg_ger,text_msg_eng) FROM '$DATADIR/text_msg.csv' DELIMITER ';' CSV" \
   && psql -d $ISODB -c "\i $SQLDIR/iso-fill-stm.sql"
#   && psql -d $ISODB -c "\i $SAMPLEDIR/iso-fill-samples.sql" \
#   && psql -d $ISODB -c "\i $SAMPLEDIR/iso-user.sql"

EXPOSE 5432

# Add VOLUMEs to allow backup of config, logs and databases
VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]

# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
tim@ubuntu:~/docker/isodb$