cleanups and fixups for postgres, quassel dockers

master
Michał 'rysiek' Woźniak 2015-01-05 17:14:25 +01:00
parent 8f79928837
commit b5a5c5f918
8 changed files with 73 additions and 51 deletions

View File

@ -18,20 +18,11 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get upgrade && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# clear the data dir
RUN rm -rf /var/lib/postgresql/9.3/
# Only quassel needs to connectm eh?
#RUN echo "host quassel quassel quassel-docker-quassel trust" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "host quassel quassel 172.17.0.0/16 trust" >> /etc/postgresql/9.3/main/pg_hba.conf
# Well...
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
# prep script -- will be run each time the container is started
ADD start.sh /var/lib/start
# Expose the PostgreSQL port
EXPOSE 5432
@ -39,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"]

0
postgres/data/.gitignore vendored Normal file → Executable file
View File

View File

@ -1,24 +0,0 @@
#!/bin/bash
# removing the database cluster if it exists and prepping everything for posgresql operation
# be careful, Will Robinson!
# we need to be root for this
if [[ `whoami` != 'root' ]]; then
echo "we need to be root for this, quitting"
exit 1
fi
# work the directory
cd /var/lib/postgresql
chown postgres:postgres ./
chmod 0700 ./
# initdb as postgres
su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres
# let quassel db
/etc/init.d/postgresql start
su -c 'psql --command "CREATE USER quassel;"' postgres
su -c "psql --command \"CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';\"" postgres
/etc/init.d/postgresql stop

36
postgres/start.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
# removing the database cluster if it exists and prepping everything for posgresql operation
# be careful, Will Robinson!
# we need to be root for this
if [[ `whoami` != 'root' ]]; then
echo "we need to be root for this, quitting"
exit 1
fi
# work the directory
cd /var/lib/postgresql
chown -R postgres:postgres ./
chmod -R 0700 ./
# do we need to init the db?
if [ ! -e /var/lib/postgresql/9.3/main ]; then
# initdb as postgres
su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres
# config
echo "host all all `hostname -I | sed 's/ //g'`/16 trust" >> /var/lib/postgresql/9.3/main/pg_hba.conf
echo "listen_addresses='*'" >> /var/lib/postgresql/9.3/main/postgresql.conf
# let quassel db
/etc/init.d/postgresql start
su -c 'psql --command "CREATE USER quassel;"' postgres
su -c "psql --command \"CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';\"" postgres
/etc/init.d/postgresql stop
fi
# run postgres as user postgres
su -c '/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main' postgres

View File

@ -9,11 +9,13 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade && apt-get
libqca2-plugin-ossl libicu52 \
postgresql-client
# prep script
ADD start.sh /var/lib/start
# volume and expose
VOLUME ["/var/lib/quassel/quasselcore.conf"]
EXPOSE 4242
USER quasselcore
# use ENTRYPOINT instead of CMD so that we can easily pass additional arguments to the run command
CMD []
ENTRYPOINT ["quasselcore", "--configdir=/var/lib/quassel/"]
CMD ["/var/lib/start"]
ENTRYPOINT ["/bin/bash"]

View File

@ -0,0 +1,6 @@
[Config]
Version=1
[Core]
CoreState=@Variant(\0\0\0\b\0\0\0\x2\0\0\0 \0\x43\0o\0r\0\x65\0S\0t\0\x61\0t\0\x65\0V\0\x65\0r\0s\0i\0o\0n\0\0\0\x2\0\0\0\x1\0\0\0\x1c\0\x41\0\x63\0t\0i\0v\0\x65\0S\0\x65\0s\0s\0i\0o\0n\0s\0\0\0\t\0\0\0\0)
StorageSettings="@Variant(\0\0\0\b\0\0\0\x2\0\0\0(\0\x43\0o\0n\0n\0\x65\0\x63\0t\0i\0o\0n\0P\0r\0o\0p\0\x65\0r\0t\0i\0\x65\0s\0\0\0\b\0\0\0\x5\0\0\0\x10\0U\0s\0\x65\0r\0n\0\x61\0m\0\x65\0\0\0\n\0\0\0\xe\0q\0u\0\x61\0s\0s\0\x65\0l\0\0\0\b\0P\0o\0r\0t\0\0\0\x2\0\0\x15\x38\0\0\0\x10\0P\0\x61\0s\0s\0w\0o\0r\0\x64\0\0\0\n\0\0\0\0\0\0\0\x10\0H\0o\0s\0t\0n\0\x61\0m\0\x65\0\0\0\n\0\0\0,\0q\0u\0\x61\0s\0s\0\x65\0l\0\x64\0o\0\x63\0k\0\x65\0r\0-\0p\0o\0s\0t\0g\0r\0\x65\0s\0\0\0\x10\0\x44\0\x61\0t\0\x61\0\x62\0\x61\0s\0\x65\0\0\0\n\0\0\0\xe\0q\0u\0\x61\0s\0s\0\x65\0l\0\0\0\xe\0\x42\0\x61\0\x63\0k\0\x65\0n\0\x64\0\0\0\n\0\0\0\x14\0P\0o\0s\0t\0g\0r\0\x65\0S\0Q\0L)"

16
quassel/start.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# quasseldocker quaselcore wrapper
#
# we need to be root for this
if [[ `whoami` != 'root' ]]; then
echo "we need to be root for this, quitting"
exit 1
fi
# make sure permissions are okay
chown -R quasselcore:quassel /var/lib/quassel/
# run the damn thing
su -s /bin/bash -c 'quasselcore --configdir=/var/lib/quassel/' quasselcore

View File

@ -30,6 +30,7 @@ if [ "$setup_volumes" = true ]; then
fi
# should we set-up the port forwarding to the host system?
quassel_port=""
if [ "$setup_ports" = true ]; then
quassel_port="-p 4242:4242"
fi
@ -53,10 +54,7 @@ killall="docker kill $quassel_container $postgres_container"
rmall="docker rm -v $quassel_container $postgres_container"
# info
info="remember to prep both environments if needed (e.g. after clean build):
- docker run --entrypoint /bin/sh -u root -t -i $postgres_volume --rm $postgres_image -c /root/prep.sh
- docker run --entrypoint /bin/sh -u root -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c 'chown quasselcore:quassel /var/lib/quassel/quasselcore.conf'
info="
root access to both containers:
- docker run --entrypoint /bin/sh -u root -h $postgres_container -t -i --name $postgres_container --rm $postgres_image -c /bin/bash
- docker run --entrypoint /bin/sh -u root -h $quassel_container --link=$postgres_container:$postgres_container -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c /bin/bash"
@ -149,4 +147,4 @@ if [[ "$1" == "" || "$1" == "--run" ]]; then
- $quassel_container (`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $quassel_container`)
"
fi
fi