Mercurial > sat_docs
view docker/base/Dockerfile @ 80:686a8c982c3f
docker: updated Dockerfiles:
- use HTTPS URLs instead of HTTP
- prosody image know use prosody Debian repository instead of Debian Jessie version, prosody 0.10 is used
- prosody configuration is now in prosody directory next to Dockerfile, instead of using difficult to maintain sed calls
- community modules are downloaded from mercurial, and only needed ones are kept
- no more remote-roster hack \o/
- pubsub component is not at pubsub.[domain] (was sat-pubsub before)
- SàT media are gotten from hg instead of ftp, so they are up-to-date with SàT version
- libervia image now use pip for txJSON-RPC
- fixed now needed jinja2 installation
- fixed libervia/admin accounts auto-creation script
- fixed uid/gid for prosody in data image
- removed not needed anymore nox option in base image
- added python-pip in base image
- docker images now work with current dev version (0.6.0D)
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Feb 2016 20:24:24 +0100 |
parents | 0e78c8a4626e |
children | 8dd32aa49614 |
line wrap: on
line source
############################################################### # # # Salut à Toi/base # # This Dockerfile build a « Salut à Toi » base image # # Salut à Toi is a multi-frontends multi-purposes XMPP client # # # ############################################################### FROM debian:jessie MAINTAINER Goffi <goffi@goffi.org> ######## # BASE # ######## ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get upgrade -y RUN apt-get install -y --no-install-recommends locales dbus-x11 python python-gobject-2 python-dbus python-lxml python-mutagen python-pil python-crypto python-feed python-potr python-twisted-core python-twisted-mail python-twisted-web python-twisted-words python-wokkel python-xdg python-xe python-zope.interface python-gi python-urwid python-markdown python-html2text mercurial python-pip RUN apt-get clean # we need UTF-8 locale RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen RUN locale-gen ENV LC_ALL en_US.UTF-8 # it's better to have a dedicated user RUN useradd -m sat # will be used to put many SàT specific data RUN mkdir -p /usr/share/sat ################ # URWID SÀTEXT # ################ WORKDIR /tmp RUN hg clone https://repos.goffi.org/urwid-satext WORKDIR urwid-satext RUN python setup.py install --prefix /usr --install-lib /usr/lib/python2.7/dist-packages WORKDIR /tmp RUN rm -rf urwid-satext ##################### # CORE INSTALLATION # ##################### WORKDIR /tmp RUN hg clone https://repos.goffi.org/sat WORKDIR sat RUN python setup.py install --prefix /usr --install-lib /usr/lib/python2.7/dist-packages WORKDIR /tmp RUN rm -rf sat ###################### # SàT CONFIGURATION # ###################### # Following scripts make the configuration as automatic and easy as possible # we auto-create libervia account if it doesn't exists in Libervia container # so we remove it from reserved_list in plugin account RUN echo '[plugin account]\nreserved_list=' >> /etc/sat.conf # This script set account domain in sat.conf if not already set # if not set, domain is got from prosody container or DOMAIN environment variable RUN echo '#!/usr/bin/env python2\n\ import os, xmlrpclib, ConfigParser, socket, subprocess\n\ from sat.core.constants import Const as C\n\ from sat.tools import config as sat_config\n\ SECTION = "plugin account"\n\ OPTION = "new_account_domain"\n\ CONFIG_PATH = "/home/sat/sat.conf"\n\ config = ConfigParser.SafeConfigParser()\n\ config.read(C.CONFIG_FILES)\n\ domain = sat_config.getConfig(config, SECTION, OPTION)\n\ if domain is None:\n\ os.getenv("DOMAIN")\n\ if domain is None:\n\ proxy = xmlrpclib.ServerProxy("http://prosody:9999/")\n\ try:\n\ if "prosody" not in open("/etc/hosts").read():\n\ raise socket.gaierror # this avoid waiting for timeout if prosody is not linked\n\ domain = proxy.getenv("DOMAIN")\n\ except socket.gaierror:\n\ print "No prosody container connected or known domain, using \"localhost\" for new domains"\n\ domain = "localhost"\n\ config = ConfigParser.SafeConfigParser()\n\ config.readfp(open(CONFIG_PATH, "a+"))\n\ try:\n\ config.add_section(SECTION)\n\ except ConfigParser.DuplicateSectionError:\n\ pass\n\ config.set(SECTION, OPTION, domain)\n\ config.write(open(CONFIG_PATH, "w"))\n\ subprocess.call(["add_host", domain, "prosody"])\n\ ' > /usr/local/bin/set_account_domain && chmod 0555 /usr/local/bin/set_account_domain # account domain is set, then sat is launched with D-Bus activated RUN echo '#!/bin/sh\n\ chmod a+w /etc/hosts\n\ su -c "set_account_domain && dbus-launch /usr/bin/sat $@" sat\n\ '> /usr/local/bin/sat && chmod 0500 /usr/local/bin/sat # this script add aliases to /etc/hosts RUN echo '#!/usr/bin/env python2\n\ import sys, re\n\ if len(sys.argv) < 2 or len(sys.argv) > 3:\n\ sys.exit(1)\n\ host = sys.argv[1]\n\ alias = sys.argv[2] if len(sys.argv) == 3 else "localhost"\n\ if host == "localhost" or host == alias:\n\ sys.exit(0)\n\ print "Adding host {} as an alias of {}".format(host, alias)\n\ with open("/etc/hosts", "r+") as f:\n\ buf = re.sub(r"\\b{}\\b".format(alias), "{}\\t{}".format(alias, host), f.read(), 1)\n\ f.seek(0)\n\ f.write(buf)\ ' > /usr/local/bin/add_host && chmod 0555 /usr/local/bin/add_host # This script simulate prosodyctl adduser/passwd/deluser and call it on the prosody container RUN echo '#!/usr/bin/env python2\n\ import sys, xmlrpclib\n\ proxy = xmlrpclib.ServerProxy("http://prosody:9999/")\n\ def pwd():\n\ pwd1=raw_input(); pwd2=raw_input(); assert pwd1==pwd2\n\ return pwd1\n\ password = pwd() if sys.argv[1] in ["adduser", "passwd"] else ""\n\ sys.exit(proxy.prosodyctl(sys.argv[1], sys.argv[2], password))\n\ ' > /usr/local/bin/prosodyctl ######### # D-Bus # ######### # we need a TCP socket RUN sed -i "s&<listen>unix:tmpdir=/tmp</listen>&\0\n <listen>tcp:host=localhost,bind=*,port=55555,family=ipv4</listen>\n <auth>ANONYMOUS</auth>\n <allow_anonymous/>&" /etc/dbus-1/session.conf # this script will launch the command with good D-BUS parameters # it needs to be copied and made executable by frontends RUN echo "#!/bin/sh\nexport DBUS_SESSION_BUS_ADDRESS=tcp:host=sat,port=55555,family=ipv4\nexec /usr/bin/\$(basename \$0) \$@" > /usr/local/bin/dbus_wrap ########## # LAUNCH # ########## WORKDIR /home/sat ENTRYPOINT ["/bin/bash"]