view docker/sat_pubsub/Dockerfile @ 103:e69883c1ec30

docker (libervia_cont): added a "status" command: - if libervia container is not running, it exits with error code 1 - if libervia container is running but no server is launched, it exits with error code 2 - if libervia container is running and server is launcher, it exits with error code 0 (success) server detection is done by doing a simple grep on logs, that's not perfectly reliable (ports can be changed in configuration, even if that doesn't really make sense in Docker context) but should be good enough for this purpose.
author Goffi <goffi@goffi.org>
date Sat, 27 Feb 2016 00:45:40 +0100
parents 8dd32aa49614
children b69056368901
line wrap: on
line source

###############################################################
#                                                             #
#                   Salut à Toi/sat_pubsub                    #
#     This Dockerfile build a SàT Pubsub service for SàT      #
# Salut à Toi is a multi-frontends multi-purposes XMPP client #
#                                                             #
###############################################################

FROM salutatoi/base:latest

MAINTAINER Goffi <goffi@goffi.org>

########
# BASE #
########

RUN apt-get install -y --no-install-recommends postgresql
RUN apt-get install -y --no-install-recommends python-psycopg2
RUN apt-get clean

# This script launch SàT PubSub with domain and secret gotten from prosody container
# it make the configuration more easy
RUN echo '#!/usr/bin/env python2\n\
import os, xmlrpclib\n\
os.chdir("/usr/share/sat_pubsub")\n\
proxy = xmlrpclib.ServerProxy("http://prosody:9999/")\n\
domain = proxy.getenv("DOMAIN")\n\
secret = proxy.getenv("SAT_PUBSUB_SECRET")\n\
os.execlp("twistd", "twistd", "-n", "--pidfile", "/tmp/sat_pubsub.pid", "sat_pubsub", "--rhost", "prosody",\
 "--jid", "pubsub.%s" % domain, "--secret", secret)\n\
' > /usr/local/bin/sat_pubsub && chmod 0555 /usr/local/bin/sat_pubsub

WORKDIR /usr/share

RUN hg clone https://repos.goffi.org/sat_pubsub && chown -R sat:sat sat_pubsub

############
# DATABASE #
############

WORKDIR sat_pubsub/db

# To simplify installation, we integrate our own PostgreSQL
# future alternate version may use an external PostgreSQL container

USER root

RUN service postgresql start; su -c "createuser -d -w sat" postgres; su -c "createdb pubsub" postgres; su -c "psql pubsub < pubsub.sql" sat; service postgresql stop

##########
# LAUNCH #
##########

# we need to launch PostgreSQL, so we launch as root then switch to sat user
ENTRYPOINT ["/bin/sh","-c", "service postgresql start && su -c sat_pubsub sat"]