-
Notifications
You must be signed in to change notification settings - Fork 7
Dockerització del Mailtoticket #196
base: master
Are you sure you want to change the base?
Changes from all commits
0bde212
fcda577
6f28faf
54b13d4
9df166e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set logfile "/tmp/fetchmail.log" | ||
poll imap.upc.edu protocol imap: | ||
|
||
username "suport.unitat" | ||
password "contrasenya" | ||
folder "mailtoticket" | ||
mda "/bin/sh -c 'cat | /usr/local/bin/python /mailtoticket/mailtoticket.py'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per què caldria posar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per alguna raó no em funcionava amb la info de la wiki i esbrinant exemples de configuració de fetchmail, aquesta opció em va funcionar. Puc tornar a provar per si va ser una falsa impressió. |
||
ssl | ||
nokeep | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jo anomenaria l'exemple de configuració del fetchmail d'una altra manera que:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tens raó, es millor així. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:2.7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En general s'acostuma a anomenar el fixer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Es fàcil de solucionar. |
||
RUN git clone --single-branch --branch feature_api_rest_identitat https://github.com/UPC/mailtoticket.git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crec que és mala idea clonar el repositori durant la construcció de la imatge, sobretot si el motiu és generar la imatge amb el codi d'una branca concreta. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. La meva idea era generar una imatge out-of-the-box (mínim de passos), de cara a fer les proves m'anava bé. |
||
|
||
WORKDIR /mailtoticket | ||
|
||
COPY settings_default.py . | ||
COPY entrypoint.sh . | ||
COPY .fetchmailrc /root/ | ||
|
||
RUN apt-get update | ||
RUN apt-get upgrade -y | ||
RUN apt-get install -y fetchmail | ||
RUN apt-get install -y cron | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Podem debatre si el fetchmail hauria d'estar dins el mateix contenidor que el mailtoticket (jo penso que haurien d'estar en contenidors separats) però el que segur que no té sentit és tenir un contenidor amb un cron només per executar el fetchmail. Si el contenidor s'executa a un servidor, aquest ja tindrà un cron des del que es pot executar el contenidor amb docker run. Si el contenidor està a mycontainers, allà ja hi ha serveis de tipus cron que poden executar contenidors periòdicament. A més a més, el fetchmail té un mode dimoni que també podria ser interessant de valorar. Com més senzill sigui el contenidor més fàcil serà de mantenir, debuggar, operar i escalar, per tant crec que el cron sobra. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No et sabria dir quina configuració implicaria tenir el fetchmail i el mailtoticket en dockers separats per que la cosa funcioni. Jo apostaria per tenir els dos en el mateix docker, sigui tirant del dimoni de fetchmail o bé pensant en el temporitzador que teniu muntat en mycontainers. Tinc pendent demanar l'accés a aquest servei per a fer proves. |
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
RUN chmod 755 entrypoint.sh | ||
RUN chmod 600 /root/.fetchmailrc | ||
|
||
|
||
ENTRYPOINT /mailtoticket/entrypoint.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
echo "Mailtoticket has been started" | ||
|
||
# Setup a cron schedule | ||
echo "[email protected] | ||
*/5 * * * * /usr/bin/fetchmail --silent | ||
# This extra line makes it a valid cron" > scheduler.txt | ||
|
||
crontab scheduler.txt | ||
cron -f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En un contenidor de docker els logs han d'anar a stdout i stderr perquè el sistema de fitxers és efímer. Per tant crec que aquesta línia no hi hauria de ser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tinc controlat el tema del logging en contenidors. Si treient l'entrada "set logfile" ja s'envien els errors per stdout, doncs es fàcil de solucionar.