Skip to content

Commit

Permalink
Working Docker setup with python3 (#684)
Browse files Browse the repository at this point in the history
* Docker changes

* working changes

* update noauth.py

* Docker setup

* changing passwrod

* Revert "changing passwrod"

This reverts commit 62cd1dd.

* Healthcheck & Freshping addition

* removing mysql password

* config changes
  • Loading branch information
allwyn-pradip authored Mar 23, 2022
1 parent 7a72bcc commit 3c8ffac
Show file tree
Hide file tree
Showing 17 changed files with 21,334 additions and 8 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get -y dist-upgrade \
&& apt-get -y install libffi-dev libsasl2-dev python3-dev libyaml-dev sudo \
libldap2-dev libssl-dev python3-pip python3-setuptools python3-venv \
mysql-client nginx uwsgi uwsgi-plugin-python3 uwsgi-plugin-gevent-python3 \
&& pip3 install mysql-connector-python \
&& rm -rf /var/cache/apt/archives/*

RUN useradd -m -s /bin/bash iris

COPY src /home/iris/source/src
COPY setup.py /home/iris/source/setup.py
COPY MANIFEST.in /home/iris/source/MANIFEST.in
COPY README.md /home/iris/source/README.md

WORKDIR /home/iris

RUN chown -R iris:iris /home/iris/source /var/log/nginx /var/lib/nginx \
&& sudo -Hu iris mkdir -p /home/iris/var/log/uwsgi /home/iris/var/log/nginx /home/iris/var/run /home/iris/var/relay \
&& sudo -Hu iris python3 -m venv /home/iris/env \
&& sudo -Hu iris /bin/bash -c 'source /home/iris/env/bin/activate && python3 -m pip install -U pip wheel && cd /home/iris/source && pip install .'

COPY . /home/iris
COPY ops/config/systemd /etc/systemd/system
COPY ops/daemons /home/iris/daemons
COPY ops/daemons/uwsgi-docker.yaml /home/iris/daemons/uwsgi.yaml
COPY db /home/iris/db
COPY configs /home/iris/config
COPY healthcheck /tmp/status
COPY ops/entrypoint.py /home/iris/entrypoint.py

RUN chown -R iris:iris /home/iris/

EXPOSE 16649

CMD ["sudo", "-EHu", "iris", "bash", "-c", "source /home/iris/env/bin/activate && python -u /home/iris/entrypoint.py"]
5 changes: 3 additions & 2 deletions configs/config.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ db: &db
user: root
password: ""
host: 127.0.0.1
port: 3306
database: iris
charset: utf8
str: "%(scheme)s://%(user)s:%(password)s@%(host)s/%(database)s?charset=%(charset)s"
str: "%(scheme)s://%(user)s:%(password)s@%(host)s:%(port)s/%(database)s?charset=%(charset)s"
query_limit: 500
kwargs:
pool_recycle: 3600
Expand All @@ -35,7 +36,7 @@ db: &db
# host: 127.0.0.1
# database: iris
# charset: utf8
# str: "%(scheme)s://%(user)s:%(password)s@%(host)s/%(database)s?charset=%(charset)s"
# str: "%(scheme)s://%(user)s:%(password)s@%(host)s:%(port)s/%(database)s?charset=%(charset)s"
# kwargs:
# pool_recycle: 3600
# echo: False
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'

services:
iris-web:
build: .
ports:
- "16649:16649"
environment:
- DOCKER_DB_BOOTSTRAP=1
volumes:
- ./configs/config.dev.yaml:/home/iris/config/config.yaml

iris-mysql:
image: mysql:5.5
environment:
- MYSQL_ROOT_PASSWORD=1234
1 change: 1 addition & 0 deletions healthcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOOD
2 changes: 1 addition & 1 deletion ops/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def main():
os.execv('/usr/bin/uwsgi',
# first array element is ARGV0, since python 3.6 it cannot be empty, using space
# https://bugs.python.org/issue28732
[' ', '--yaml', os.environ.get('UWSGI_CONFIG', '/home/iris/daemons/uwsgi.yaml:prod')])
['/usr/bin/uwsgi', '--yaml', '/home/iris/daemons/uwsgi.yaml:prod'])


if __name__ == '__main__':
Expand Down
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'twilio==6.25.0',
'google-api-python-client==1.4.2',
'oauth2client==1.4.12',
'slackclient==0.16',
'slackclient',
'PyYAML',
'greenlet==0.4.16',
'gevent==1.5.0',
Expand All @@ -49,15 +49,16 @@
'msgpack==1.0.0',
'cssmin',
'beaker',
'cryptography==2.3',
'cryptography==3.2',
'webassets',
'python-ldap==3.1.0',
'exchangelib==2.2.0',
'setproctitle',
'pyfcm==1.4.3',
'oncallclient==1.0.0',
'idna==2.7',
'pyqrcode==1.2.1'
'oncallclient==1.1.0',
'idna==3.0',
'pyqrcode==1.2.1',
'plivo==4.18.1'
],
extras_require={
'kazoo': ['kazoo==2.6.1'],
Expand Down
Loading

0 comments on commit 3c8ffac

Please sign in to comment.