1
0
mirror of https://github.com/linkedin/oncall.git synced 2025-11-29 23:38:17 +02:00

Merge branch 'master' into py3_merge

This commit is contained in:
Diego Cepeda
2020-01-15 15:43:06 -08:00
committed by GitHub
7 changed files with 22 additions and 137 deletions

View File

@@ -8,28 +8,32 @@ Test with Docker
````````````````
.. _Docker: https://www.docker.com/community-edition
.. _DockerCompose: https://docs.docker.com/compose/
A local test instance of Oncall can be setup with Docker_ in a few commands:
A local test instance of Oncall can be setup with Docker_ and
DockerCompose_ in a single command:
.. code-block:: bash
cd ./ops/packer
mkdir output
python gen_packer_cfg.py ./oncall.yaml | tail -n +2 > ./output/oncall.json
packer build -only=docker oncall.json
docker run -d --name oncall-mysql -e MYSQL_ROOT_PASSWORD='1234' mysql:5.7
docker run -d --link oncall-mysql:mysql -p 8080:8080 -e DOCKER_DB_BOOTSTRAP=1 quay.io/iris/oncall
docker-compose up
.. NOTE::
We pass a **DOCKER_DB_BOOTSTRAP** environment variable to the Oncall container
indicating to our setup script that the database needs to be initialized. This
will populate the database with a small amount of dummy data and set up the
proper schema so we can get up and running.
The above commands set up an Oncall service and MySQL database. Note that we
The above command sets up an Oncall service and MySQL database. Note that we
set the MySQL root password to '1234'; you may wish to change this to something
more secure.
Details about the container configuration are in ``docker-compose.yml`` and
``Dockerfile``. During the first run the database schema will be created and
populated with some dummy data. You can edit the dummy data in
``./db/dummy_data.sql``, but you will need to stop and recreate your containers
to load your new data.
.. code-block:: bash
docker-compose stop
docker-compose rm -f
docker-compose build
docker-compose up
The test instance of Oncall can be accessed at http://localhost:8080. Try
logging in as the user "jdoe", with any password (the Docker image defaults to
disable authentication, which authenticates all credentials so long as the user
@@ -100,6 +104,7 @@ You can deactivate this feature by setting the `import_user` option to `False`.
Here is an example of ldap auth configuration :
.. code-block:: yaml
auth:
debug: False
module: 'oncall.auth.modules.ldap_import'

View File

@@ -1,6 +0,0 @@
```mkdir output```
```python gen_packer_cfg.py ./oncall.yaml | tail -n +2 > ./output/oncall.json```
```packer build -only=docker ./output/oncall.json```
```docker run --name oncall-mysql -e MYSQL_ROOT_PASSWORD='1234' -d mysql --default-authentication-plugin=mysql_native_password```
```docker run -d --link oncall-mysql:mysql -p 8080:8080 -e DOCKER_DB_BOOTSTRAP=1 quay.io/iris/oncall```

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import re
import os
import yaml
import json
import sys
OUTPUT_DIR = 'output'
def main():
current_dir = os.path.dirname(os.path.realpath(__file__))
with open('%s/../../src/oncall/__init__.py' % current_dir, 'r') as fd:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)
print('Generating packer config for oncall v%s' % version)
yml_cfg = sys.argv[1]
with open(yml_cfg) as fp:
config = yaml.safe_load(fp)
if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
config['variables']['app_version'] = version
cfg_name = os.path.splitext(os.path.basename(yml_cfg))[0]
with open('%s/%s.json' % (OUTPUT_DIR, cfg_name), 'w') as fp:
json_str = json.dumps(config, indent=2)
print(json_str)
fp.write(json_str)
main()

View File

@@ -1,79 +0,0 @@
variables:
app_name: "oncall"
app_version: ""
git_tag: "master"
builders:
- type: "docker"
image: "ubuntu:16.04"
changes:
- 'EXPOSE 8080'
- 'CMD ["sudo", "-EHu", "oncall", "bash", "-c", "source /home/oncall/env/bin/activate && python /home/oncall/entrypoint.py"]'
commit: True
provisioners:
- type: "shell"
inline:
- mkdir /tmp/repo
- type: "file"
source: "../../src"
destination: "/tmp/repo"
- type: "file"
source: "../../setup.py"
destination: "/tmp/repo/setup.py"
- type: "file"
source: "../../db"
destination: "/tmp/repo"
- type: "file"
source: "../../ops"
destination: "/tmp/repo"
- type: "file"
source: "../../configs"
destination: "/tmp/repo"
- type: "shell"
only: ["docker"]
inline:
- "apt-get update && apt-get -y install sudo"
- type: "shell"
inline:
- sudo apt-get -y install curl python-pip uwsgi unzip virtualenv sudo python-dev libyaml-dev libsasl2-dev libldap2-dev nginx uwsgi-plugin-python mysql-client
- sudo rm -rf /var/cache/apt/archives/*
- sudo useradd -m -s /bin/bash oncall
- sudo chown -R oncall:oncall /home/oncall /var/log/nginx /var/lib/nginx
- sudo -Hu oncall mkdir -p /home/oncall/var/log/uwsgi /home/oncall/var/log/nginx /home/oncall/var/run
- sudo mv /tmp/repo /home/oncall/source
- "sudo chown -R oncall:oncall /home/oncall/source"
- sudo mv /home/oncall/source/ops/config/systemd/uwsgi-oncall.service /etc/systemd/system/uwsgi-oncall.service
- sudo mv /home/oncall/source/ops/config/systemd/nginx-oncall.service /etc/systemd/system/nginx-oncall.service
- sudo mv /home/oncall/source/ops/config/systemd/nginx-oncall.socket /etc/systemd/system/nginx-oncall.socket
- sudo -Hu oncall ln -s /home/oncall/source/ops/daemons /home/oncall/daemons
- sudo -Hu oncall ln -s /home/oncall/source/ops/entrypoint.py /home/oncall/entrypoint.py
- sudo -Hu oncall ln -s /home/oncall/source/db /home/oncall/db
- sudo -Hu oncall mkdir /home/oncall/config
- sudo -Hu oncall cp /home/oncall/source/configs/config.yaml /home/oncall/config/config.yaml
- sudo -Hu oncall virtualenv /home/oncall/env
- sudo -Hu oncall /bin/bash -c 'source /home/oncall/env/bin/activate && cd /home/oncall/source && pip install .'
- type: "shell"
only: ["docker"]
inline:
- "sudo -Hu oncall mv -f /home/oncall/daemons/uwsgi-docker.yaml /home/oncall/daemons/uwsgi.yaml"
- sudo -Hu oncall cp /home/oncall/source/configs/config.docker.yaml /home/oncall/config/config.yaml
post-processors:
- type: "docker-tag"
repository: "quay.io/iris/oncall"
tag: "{{ user `app_version` }}"
only: ["docker"]
- type: "docker-tag"
repository: "quay.io/iris/oncall"
tag: "latest"
only: ["docker"]

2
setup.py Normal file → Executable file
View File

@@ -30,7 +30,7 @@ setuptools.setup(
'python-ldap',
'pytz',
'irisclient',
'slackclient',
'slackclient==1.3.1',
'icalendar',
'pymsteams'
],