comparison docker/sat_pubsub/Dockerfile @ 21:0e78c8a4626e

Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
author Goffi <goffi@goffi.org>
date Sun, 19 Oct 2014 15:14:40 +0200
parents
children 686a8c982c3f
comparison
equal deleted inserted replaced
20:703a394b9780 21:0e78c8a4626e
1 ###############################################################
2 # #
3 # Salut à Toi/sat_pubsub #
4 # This Dockerfile build a SàT Pubsub service for SàT #
5 # Salut à Toi is a multi-frontends multi-purposes XMPP client #
6 # #
7 ###############################################################
8
9 FROM salutatoi/base:latest
10
11 MAINTAINER Goffi <goffi@goffi.org>
12
13 ########
14 # BASE #
15 ########
16
17 RUN apt-get install -y --no-install-recommends postgresql
18 RUN apt-get install -y --no-install-recommends python-psycopg2
19 RUN apt-get clean
20
21 # This script launch SàT PubSub with domain and secret gotten from prosody container
22 # it make the configuration more easy
23 RUN echo '#!/usr/bin/env python2\n\
24 import os, xmlrpclib\n\
25 os.chdir("/usr/share/sat_pubsub")\n\
26 proxy = xmlrpclib.ServerProxy("http://prosody:9999/")\n\
27 domain = proxy.getenv("DOMAIN")\n\
28 secret = proxy.getenv("SAT_PUBSUB_SECRET")\n\
29 os.execlp("twistd", "twistd", "-n", "sat_pubsub", "--rhost", "prosody",\
30 "--jid", "sat-pubsub.%s" % domain, "--secret", secret)\n\
31 ' > /usr/local/bin/sat_pubsub && chmod 0555 /usr/local/bin/sat_pubsub
32
33 WORKDIR /usr/share
34
35 RUN hg clone http://repos.goffi.org/sat_pubsub && chown -R sat:sat sat_pubsub
36
37 ############
38 # DATABASE #
39 ############
40
41 WORKDIR sat_pubsub/db
42
43 # To simplify installation, we integrate our own PostgreSQL
44 # future alternate version may use an external PostgreSQL container
45
46 USER root
47
48 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
49
50 ##########
51 # LAUNCH #
52 ##########
53
54 # we need to launch PostgreSQL, so we launch as root then switch to sat user
55 ENTRYPOINT ["/bin/sh","-c", "service postgresql start && su -c sat_pubsub sat"]