kind-of working
parent
72cdc42bc4
commit
514d0098ad
|
@ -20,17 +20,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get upgrade &
|
|||
|
||||
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
|
||||
# after each ``apt-get``
|
||||
# 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
|
||||
|
||||
# Create a PostgreSQL role named ``quassel`` with no password (UNIX sockets FTW!) and
|
||||
# then create a database `quassel` owned by the ``quassel`` role.
|
||||
#RUN /usr/lib/postgresql/9.3/bin/initdb /etc/postgresql/9.3/main/ && \
|
||||
|
||||
RUN /etc/init.d/postgresql start && \
|
||||
psql --command "CREATE USER quassel;" && \
|
||||
psql --command "CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';" && \
|
||||
/etc/init.d/postgresql stop
|
||||
|
||||
# Only quassel needs to connectm eh?
|
||||
#RUN echo "host quassel quassel quassel-docker-quassel trust" >> /etc/postgresql/9.3/main/pg_hba.conf
|
||||
|
@ -39,11 +28,20 @@ RUN echo "host quassel quassel 172.17.0.0/16 trust" >> /etc/postgresql/9.3/m
|
|||
# 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
|
||||
|
||||
# Expose the PostgreSQL port
|
||||
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/"]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/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
|
|
@ -9,9 +9,11 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade && apt-get
|
|||
libqca2-plugin-ossl libicu52 \
|
||||
postgresql-client
|
||||
|
||||
USER quasselcore
|
||||
# use ENTRYPOINT instead of CMD so that we can easily pass additional arguments to the run command
|
||||
ENTRYPOINT ["quasselcore", "--configdir=/var/lib/quassel/"]
|
||||
|
||||
VOLUME ["/var/lib/quassel"]
|
||||
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/"]
|
||||
|
|
|
@ -8,28 +8,100 @@ quassel_image="$project_name/quassel"
|
|||
quassel_container="$project_name-quassel"
|
||||
|
||||
# postgres data dir
|
||||
pgdata="`pwd`/postgres/data"
|
||||
postgresdata="`pwd`/postgres/data"
|
||||
quasselconf="`pwd`/quassel/quasselcore.conf"
|
||||
|
||||
# prep work
|
||||
|
||||
# build postgres image
|
||||
buildpostgres="docker build -t $postgres_image postgres"
|
||||
|
||||
# build postgres container
|
||||
buildquassel="docker build -t $quassel_image quassel"
|
||||
|
||||
# postgres docker
|
||||
runpostgres="docker run -h $postgres_container --name $postgres_container -v $pgdata:/var/lib/postgresql/ --rm $postgres_image"
|
||||
runpostgres="docker run -h $postgres_container --name $postgres_container -v $postgresdata:/var/lib/postgresql/ -d $postgres_image"
|
||||
|
||||
# quassel docker
|
||||
runquassel="docker run -h $quassel_container --link=$quassel_container:$postgres_container --name $quassel_container --rm $quassel_image"
|
||||
runquassel="docker run -h $quassel_container --link=$postgres_container:$postgres_container -v $quasselconf:/var/lib/quassel/quasselcore.conf --name $quassel_container -d $quassel_image"
|
||||
|
||||
echo """
|
||||
will run:
|
||||
- $runpostgres
|
||||
- $runquassel
|
||||
"""
|
||||
# kill all
|
||||
killall="docker kill $quassel_container $postgres_container"
|
||||
|
||||
echo "running the postgres container..."
|
||||
$runpostgres
|
||||
echo "running the quassel container..."
|
||||
$runquassel
|
||||
echo "all done"
|
||||
# remove all
|
||||
rmall="docker rm -v $quassel_container $postgres_container"
|
||||
|
||||
# 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=$quassel_container:$postgres_container -t -i --name $quassel_container --rm $quassel_image -c /bin/bash
|
||||
# do we want to build stuff?
|
||||
if [[ "$1" == "--build" ]]; then
|
||||
echo "
|
||||
|
||||
building
|
||||
|
||||
will run:
|
||||
- $buildpostgres
|
||||
- $buildquassel
|
||||
"
|
||||
|
||||
echo
|
||||
echo "building the postgres container..."
|
||||
$buildpostgres
|
||||
|
||||
echo
|
||||
echo "building the quassel container..."
|
||||
$buildquassel
|
||||
|
||||
echo "
|
||||
|
||||
all built. remember to prep the postgres environment if needed:
|
||||
- docker run --entrypoint /bin/bash -u root -t -i -v `pwd`/postgres/data:/var/lib/postgresql/ --rm $postgres_image
|
||||
|
||||
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 --name $quassel_container --rm $quassel_image -c /bin/bash
|
||||
"
|
||||
|
||||
fi
|
||||
|
||||
# do we want to clean stuff up?
|
||||
if [[ "$1" == "" || "$1" == "--clean-up" ]]; then
|
||||
echo "
|
||||
|
||||
cleaning up
|
||||
|
||||
will run:
|
||||
- $killall
|
||||
- $rmall
|
||||
"
|
||||
|
||||
$killall
|
||||
$rmall
|
||||
fi
|
||||
|
||||
# do we want to run stuff?
|
||||
if [[ "$1" == "" || "$1" == "--run" ]]; then
|
||||
|
||||
echo "
|
||||
|
||||
running the containers
|
||||
|
||||
will run:
|
||||
- $runpostgres
|
||||
- $runquassel
|
||||
"
|
||||
|
||||
echo
|
||||
echo "running the postgres container..."
|
||||
$runpostgres
|
||||
|
||||
echo
|
||||
echo "running the quassel container..."
|
||||
$runquassel
|
||||
|
||||
echo "
|
||||
|
||||
all done, containers running:
|
||||
- $postgres_container (`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $postgres_container`)
|
||||
- $quassel_container (`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $quassel_container`)
|
||||
"
|
||||
|
||||
fi
|
Loading…
Reference in New Issue