Updated dockerfile with added user and updated constants
buildbot/travis_bionic Build done. Details

This commit is contained in:
kuldeep.k@cisinlabs.com 2022-02-11 22:44:20 +05:30
parent 44df0eed25
commit ae2b959c9e
2 changed files with 13 additions and 6 deletions

View File

@ -13,6 +13,10 @@ RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# add user
RUN adduser --disabled-password --gecos '' newuser
USER newuser
# copy project
COPY . .
ENTRYPOINT ["/usr/src/app/entrypoint.sh", "--user"]
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

13
main.py
View File

@ -25,7 +25,7 @@ class SMTPWebhookApp:
req_body = json.loads(rawbody)
subject = req_body['subject']
body = req_body['body']
client = smtplib.SMTP(host=SERVER_HOST, port=SERVER_PORT)
client = smtplib.SMTP(host=SMTP_SERVER_HOST, port=SMTP_SERVER_PORT)
msg = MIMEText(body, 'plain', 'utf-8')
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = FROM_MAIL
@ -51,10 +51,13 @@ class SMTPWebhookApp:
ROOT = SMTPWebhookApp()
SMTP_SERVER_PORT = 587
CHERRYPY_SERVER_HOST = "0.0.0.0"
CHERRYPY_SERVER_PORT = 8081
if __name__ == "__main__":
try:
SERVER_HOST = os.environ["server_host"]
SERVER_PORT = os.environ["server_port"]
SMTP_SERVER_HOST = os.environ["smtp_server_host"]
TO_MAIL = os.environ["to_mail"]
FROM_MAIL = os.environ["from_mail"]
FROM_MAIL_PASSWORD = os.environ["from_mail_password"]
@ -62,8 +65,8 @@ if __name__ == "__main__":
raise KeyError("Please check missing environment variables: to_mail, "
"from_mail, from_mail_password")
cherrypy.server.socket_host = "0.0.0.0"
cherrypy.server.socket_port = 8081
cherrypy.server.socket_host = CHERRYPY_SERVER_HOST
cherrypy.server.socket_port = CHERRYPY_SERVER_PORT
ENGINE = cherrypy.engine
cherrypy.tree.mount(ROOT, config={})