comparison docker/libervia/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 b27e7f9ad479
comparison
equal deleted inserted replaced
20:703a394b9780 21:0e78c8a4626e
1 ####################################################################
2 # #
3 # Salut à Toi/Libervia #
4 # This Dockerfile build Libervia, the web frontend for Salut à Toi #
5 # Salut à Toi is a multi-frontends multi-purposes XMPP client #
6 # #
7 ####################################################################
8
9 FROM salutatoi/media:latest
10
11 MAINTAINER Goffi <goffi@goffi.org>
12
13 ##############
14 # txJSON-RPC #
15 ##############
16
17 WORKDIR /tmp/txjsonrpc
18
19 # wget and tar are not installed, so we use python
20 RUN python -c 'import urllib2,tarfile,cStringIO;tar=tarfile.open(fileobj=cStringIO.StringIO(urllib2.urlopen("https://pypi.python.org/packages/source/t/txJSON-RPC/txJSON-RPC-0.3.1.tar.gz").read()));tar.extractall()'
21
22 # we don't need setuptools, so we just install through python
23 RUN cd tx*; sed -i "s/from setuptools/from distutils.core/" setup.py; python setup.py install
24
25 WORKDIR /tmp
26
27 RUN rm -rf txjsonrpc
28
29 ###########
30 # PYJAMAS #
31 ###########
32
33 WORKDIR /usr/share
34
35 # as the situation with pyjamas is complicated, we get the archive from our own ftp
36 RUN python -c 'import urllib2,tarfile,cStringIO;tar=tarfile.open(fileobj=cStringIO.StringIO(urllib2.urlopen("http://ftp.goffi.org/pyjamas/pyjamas.tar.bz2").read()));tar.extractall()'
37
38 WORKDIR pyjamas
39
40 RUN python bootstrap.py
41
42 RUN ln -s /usr/share/pyjamas/bin/pyjsbuild /usr/local/bin/pyjsbuild
43
44 ############
45 # LIBERVIA #
46 ############
47
48 WORKDIR /tmp
49
50 RUN hg clone http://repos.goffi.org/libervia
51
52 WORKDIR libervia
53
54 RUN python setup.py install
55
56 WORKDIR /tmp
57
58 RUN rm -rf libervia
59
60 #####################
61 # FIRST LAUNCH TEST #
62 #####################
63
64 # this script check if libervia and admin accounts exist, and create them if necessary
65 # then it launch libervia
66 RUN echo '#!/usr/bin/env python2\n\
67 import os, sys, subprocess, string, random\n\
68 from sat.plugins import plugin_misc_account as account\n\
69 from sat.tools import config\n\
70 from sat_frontends.bridge import DBus\n\
71 def generate_pwd():\n\
72 chars = string.letters + string.digits\n\
73 length = 12\n\
74 return "".join(random.choice(chars) for _ in range(length))\n\
75 sat=DBus.DBusBridgeFrontend()\n\
76 sat.getReady()\n\
77 admin_email = sat.getConfig(account.CONFIG_SECTION, "admin_email") or account.default_conf["admin_email"]\n\
78 for profile in ["libervia", "admin"]:\n\
79 if not sat.getProfileName(profile):\n\
80 print "{} profile doesn'\''t exists, creating it".format(profile)\n\
81 print "registering {}@{}".format(profile, sat.getNewAccountDomain())\n\
82 pwd = generate_pwd()\n\
83 if profile == "libervia":\n\
84 config.fixConfigOption("libervia", "passphrase", pwd)\n\
85 elif profile == "admin":\n\
86 with open("/home/sat/ADMIN_PWD", "w") as f:\n\
87 f.write(pwd)\n\
88 sat.registerSatAccount(admin_email, pwd, profile)\n\
89 os.execvp("libervia", ["libervia"] + sys.argv[1:])\n\
90 ' > /usr/bin/libervia_cont_launch && chmod 555 /usr/bin/libervia_cont_launch
91
92 #########
93 # D-Bus #
94 #########
95
96 RUN cp /usr/local/bin/dbus_wrap /usr/local/bin/libervia_cont_launch && chmod 555 /usr/local/bin/libervia_cont_launch
97
98 #########
99 # Ports #
100 #########
101
102 # HTTP
103 EXPOSE 8080
104
105 # HTTPS
106 EXPOSE 8443
107
108 ##########
109 # LAUNCH #
110 ##########
111
112 USER sat
113
114 ENTRYPOINT ["libervia_cont_launch", "fg"]
115 CMD ["-t", "http"]