postgres gotowy do działania, linki pomiędzy nginxami, php-fpmami i postgresem pododawane

master
Michał 'rysiek' Woźniak 2015-01-05 02:59:29 +01:00
parent 677a446ae0
commit ee45f6505f
3 changed files with 27 additions and 23 deletions

View File

@ -22,17 +22,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get upgrade &
#RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# prep script
ADD prep.sh /root/prep.sh
# just in case this is a test drive -- production environments will need to re-run prep.sh for the external volume
RUN ls -l /root && /bin/bash /root/prep.sh
RUN echo " \n\
\n\
******************************************************** \n\
REMEMBER TO RUN THE PREP SCRIPT: \n\
docker run --entrypoint /bin/sh -u root -t -i -v <volume>:/var/lib/postgresql/ --rm <plug/postgres> -c /root/prep.sh \n\
******************************************************** \n\
"
ADD start.sh /var/lib/start
# Expose the PostgreSQL port
EXPOSE 5432
@ -40,9 +30,6 @@ EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/var/lib/postgresql/"]
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Set the default command to run when starting the container
CMD []
ENTRYPOINT ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/etc/postgresql/9.3/main/"]
CMD ["/var/lib/start"]
ENTRYPOINT ["/bin/bash"]

View File

@ -11,17 +11,21 @@ fi
# work the directory
cd /var/lib/postgresql
chown postgres:postgres ./
chmod 0700 ./
chown -R postgres:postgres ./
chmod -R 0700 ./
# initdb as postgres
su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres
# config
# TODO: this needs to be much mroe specific for production!
echo "host any any 172.17.0.0/16 trust" >> /etc/postgresql/9.3/main/pg_hba.conf
# create the needed databases
#/etc/init.d/postgresql start
/etc/init.d/postgresql start
#su -c 'psql --command "CREATE USER some_user;"' postgres
#su -c "psql --command \"CREATE DATABASE some_db WITH OWNER some_user TEMPLATE template0 ENCODING 'UTF8';\"" postgres
#/etc/init.d/postgresql stop
/etc/init.d/postgresql stop
# run postgres as user postgres
su -c '/usr/lib/postgresql/9.3/bin/postgres -D /etc/postgresql/9.3/main/' postgres

View File

@ -103,9 +103,13 @@ docker rm -v $cnt_postgres $cnt_nginx_public $cnt_nginx_internal $cnt_phpfpm_fro
# odpalamy kolejno dockery
#
set -x
# postgres wpierw, inne się doń łączą
#docker run -d \
# -v "$static_data_dir/data/postgres":/var/lib/postgresql/
docker run -d \
-v "$static_data_dir/data/postgres":/var/lib/postgresql/ \
--name $cnt_postgres \
$img_postgres
# czas na nginxy
# - publiczny
@ -116,6 +120,7 @@ docker run -d \
-v "$static_data_dir/data/php-fpm/":/opt/php/ \
--name $cnt_nginx_public \
$img_nginx
# - wewnętrzny
docker run -d \
-v "$static_data_dir/configs/nginx-internal/":/etc/nginx/sites-enabled:ro \
@ -131,25 +136,31 @@ docker run -d \
-v "$static_data_dir/data/php-fpm/frontend/":/opt/php/frontend/ \
-v "$static_data_dir/logs/php-fpm/":/var/log/php-fpm \
-v "$static_data_dir/run/php-fpm/":/var/run/php-fpm \
--link $cnt_nginx_internal:rest \
-e "APP_NAME=frontend" \
--name $cnt_phpfpm_frontend \
$img_phpfpm
# - rest
docker run -d \
-v "$static_data_dir/data/php-fpm/rest/":/opt/php/rest/ \
-v "$static_data_dir/logs/php-fpm/":/var/log/php-fpm \
-v "$static_data_dir/run/php-fpm/":/var/run/php-fpm \
--link $cnt_postgres:$cnt_postgres \
-e "APP_NAME=rest" \
--name $cnt_phpfpm_rest \
$img_phpfpm
# - pgadmin
docker run -d \
-v "$static_data_dir/data/php-fpm/pgadmin/":/opt/php/pgadmin/ \
-v "$static_data_dir/logs/php-fpm/":/var/log/php-fpm \
-v "$static_data_dir/run/php-fpm/":/var/run/php-fpm \
--link $cnt_postgres:$cnt_postgres \
-e "APP_NAME=pgadmin" \
--name $cnt_phpfpm_pgadmin \
$img_phpfpm
# - ldapadmin
#docker run -d \
# -v "$static_data_dir/data/php-fpm/ldapadmin/":/opt/php/ldapadmin/ \
@ -157,4 +168,6 @@ docker run -d \
# -v "$static_data_dir/run/php-fpm/":/var/run/php-fpm \
# -e "APP_NAME=ldapadmin" \
# --name $cnt_phpfpm_ldapadmin \
# $img_phpfpm
# $img_phpfpm
set +x