view docker/libervia/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 b27e7f9ad479
children bcba1966e6db
line wrap: on
line source

####################################################################
#                                                                  #
#                       Salut à Toi/Libervia                       #
# This Dockerfile build Libervia, the web frontend for Salut à Toi #
#   Salut à Toi is a multi-frontends multi-purposes XMPP client    #
#                                                                  #
####################################################################

FROM salutatoi/media:latest

MAINTAINER Goffi <goffi@goffi.org>

##############
# txJSON-RPC #
##############

RUN pip install txJSON-RPC

###########
# PYJAMAS #
###########

WORKDIR /usr/share

# as the situation with pyjamas is complicated, we get the archive from our own ftp
RUN python -c 'import urllib2,tarfile,cStringIO;tar=tarfile.open(fileobj=cStringIO.StringIO(urllib2.urlopen("https://ftp.goffi.org/pyjamas/pyjamas.tar.bz2").read()));tar.extractall()'

WORKDIR pyjamas

RUN python bootstrap.py

RUN ln -s /usr/share/pyjamas/bin/pyjsbuild /usr/local/bin/pyjsbuild

############
# LIBERVIA #
############

WORKDIR /tmp

RUN apt-get install -y --no-install-recommends python-jinja2

RUN hg clone https://repos.goffi.org/libervia

WORKDIR libervia

RUN python setup.py install

WORKDIR /tmp

RUN rm -rf libervia

#####################
# FIRST LAUNCH TEST #
#####################

# this script check if libervia and admin accounts exist, and create them if necessary
# then it launch libervia
RUN echo '#!/usr/bin/env python2\n\
import os, sys, subprocess, string, random\n\
from sat.plugins import plugin_misc_account as account\n\
from sat.tools import config\n\
from sat_frontends.bridge import DBus\n\
def generate_pwd():\n\
    chars = string.letters + string.digits\n\
    length = 12\n\
    return "".join(random.choice(chars) for _ in range(length))\n\
sat=DBus.DBusBridgeFrontend()\n\
sat.getReady()\n\
admin_email = sat.getConfig(account.CONFIG_SECTION, "admin_email") or account.default_conf["admin_email"]\n\
for profile in ["libervia", "admin"]:\n\
    try:\n\
        sat.getProfileName(profile)\n\
    except Exception as e:\n\
        print "{} profile doesn'\''t exists, creating it".format(profile)\n\
        print "registering {}@{}".format(profile, sat.getNewAccountDomain())\n\
        pwd = generate_pwd()\n\
        if profile == "libervia":\n\
            config.fixConfigOption("libervia", "passphrase", pwd)\n\
        elif profile == "admin":\n\
            with open("/home/sat/ADMIN_PWD", "w") as f:\n\
                f.write("%s\\n" % pwd)\n\
        sat.registerSatAccount(admin_email, pwd, profile)\n\
os.execvp("libervia", ["libervia"] + sys.argv[1:])\n\
' > /usr/bin/libervia_cont_launch && chmod 555 /usr/bin/libervia_cont_launch

#########
# D-Bus #
#########

RUN cp /usr/local/bin/dbus_wrap /usr/local/bin/libervia_cont_launch && chmod 555 /usr/local/bin/libervia_cont_launch

#########
# Ports #
#########

# HTTP
EXPOSE 8080

# HTTPS
EXPOSE 8443

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

USER sat

ENTRYPOINT ["libervia_cont_launch", "fg"]
CMD ["-t", "http"]