forked from OCA/maintainer-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-tx-bot
43 lines (35 loc) · 1.5 KB
/
Dockerfile-tx-bot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Run a tx_pull transifex->github each 12:59 dialy.
# Build a docker image executing:
# $ docker build -t tx-bot -f Dockerfile-tx-bot .
# Create a docker container executing:
# $ docker run -it -e GITHUB_TOKEN=### -e TRANSIFEX_USER= -e TRANSIFEX_PASSWORD= -e TRANSIFEX_ORGANIZATION= tx-bot
FROM ubuntu:14.04
MAINTAINER Moises Lopez <[email protected]>
ENV MT_DIR /root/mt
ADD ./tools ${MT_DIR}/tools
ADD ./requirements.txt ${MT_DIR}/mt_requirements.txt
ENV PYTHONPATH ${PYTHONPATH}:${MT_DIR}
RUN apt-get update
RUN apt-get install -y build-essential python-dev python-pip \
&& pip install --upgrade pip
RUN pip install -r ${MT_DIR}/mt_requirements.txt
RUN touch ${MT_DIR}/oca.cfg.tmpl && \
echo "[GitHub]\n"\
"username = \n"\
"token = \${GITHUB_TOKEN}\n"\
"\n[Transifex]\n"\
"username = \${TRANSIFEX_USER}\n"\
"password = \${TRANSIFEX_PASSWORD}\n"\
"num_retries = 3\n"\
"organization = \${TRANSIFEX_ORGANIZATION}\n"\
> ${MT_DIR}/oca.cfg.tmpl
WORKDIR ${MT_DIR}
RUN touch ${MT_DIR}/replace_env.sh && \
echo "#!/bin/sh\n"\
"perl -p -e 's/\\\$\\{([^}]+)\\}/defined \$ENV{\$1} ? \$ENV{\$1} : \$&/eg; s/\\\$\\{([^}]+)\\}//eg' \${MT_DIR}/oca.cfg.tmpl > \${MT_DIR}/oca.cfg"\
> ${MT_DIR}/replace_env.sh && chmod +x ${MT_DIR}/replace_env.sh
RUN touch /var/log/cron.log /var/log/syslog \
&& echo "59 12 * * * root cd ${MT_DIR}; python -m tools.tx_pull >> /var/log/cron.log 2>&1" \
> /etc/cron.d/tx_pull_wo_propagate_environ
CMD ${MT_DIR}/replace_env.sh \
&& rsyslogd && cron && tail -f /var/log/syslog /var/log/cron.log