comparison docker/sat_pubsub/Dockerfile @ 105:b69056368901

docker: images optimisation: - reduced the number of layers by grouping many instructions - moved stuff which don't change a lot at the beginning, and hg/apt at the end - scripts are not now in scripts/ subdirectories - prosody.cfg.lua is added using ADD instead of getting it online - .hg/dirstate is copied in base (backend) and libervia, so mercurial revision is known - removed lot of useless WORKDIR instruction, they are replaced by "cd" inside RUN instructions - cleaning (apt-clean, rm) is done on the same instruction as the one than generate the data, to avoid useless data in layers
author Goffi <goffi@goffi.org>
date Sun, 28 Feb 2016 02:01:20 +0100
parents 8dd32aa49614
children d0a5db5b9bdf
comparison
equal deleted inserted replaced
104:b59491821a8a 105:b69056368901
8 8
9 FROM salutatoi/base:latest 9 FROM salutatoi/base:latest
10 10
11 MAINTAINER Goffi <goffi@goffi.org> 11 MAINTAINER Goffi <goffi@goffi.org>
12 12
13 ############################
14 # AUTOMATIC CONFIGURATION #
15 ############################
16
17
18 COPY scripts/sat_pubsub /usr/local/bin/
19 RUN chown root:root /usr/local/bin/sat_pubsub && \
20 chmod 0555 /usr/local/bin/sat_pubsub && \
21
13 ######## 22 ########
14 # BASE # 23 # BASE #
15 ######## 24 ########
16 25
17 RUN apt-get install -y --no-install-recommends postgresql 26 apt-get install -y --no-install-recommends postgresql && \
18 RUN apt-get install -y --no-install-recommends python-psycopg2 27 apt-get install -y --no-install-recommends python-psycopg2 && \
19 RUN apt-get clean 28 apt-get clean && \
20 29 cd /usr/share && \
21 # This script launch SàT PubSub with domain and secret gotten from prosody container 30 hg clone https://repos.goffi.org/sat_pubsub && chown -R sat:sat sat_pubsub && \
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", "--pidfile", "/tmp/sat_pubsub.pid", "sat_pubsub", "--rhost", "prosody",\
30 "--jid", "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 https://repos.goffi.org/sat_pubsub && chown -R sat:sat sat_pubsub
36 31
37 ############ 32 ############
38 # DATABASE # 33 # DATABASE #
39 ############ 34 ############
40 35
41 WORKDIR sat_pubsub/db 36 cd sat_pubsub/db && \
42 37
43 # To simplify installation, we integrate our own PostgreSQL 38 # To simplify installation, we integrate our own PostgreSQL
44 # future alternate version may use an external PostgreSQL container 39 # future alternate version may use an external PostgreSQL container
45 40
46 USER root 41 service postgresql start; \
47 42 su -c "createuser -d -w sat" postgres; \
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 43 su -c "createdb pubsub" postgres; \
44 su -c "psql pubsub < pubsub.sql" sat; \
45 service postgresql stop
49 46
50 ########## 47 ##########
51 # LAUNCH # 48 # LAUNCH #
52 ########## 49 ##########
53 50