Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ba71112
Create Docker image and Docker Compose configuration
alanbriolat Apr 17, 2016
3f00ba9
Update all the docker bits
alanbriolat Jan 31, 2019
df91305
Don't use unstable release of MongoDB...
alanbriolat Feb 1, 2019
33a355b
Add oauth2client dependency that google-api-python-client dropped
alanbriolat Feb 1, 2019
d0592c2
Fix mongodump instructions
alanbriolat Feb 1, 2019
9676006
Updated docker-compose.yml for working deployment
alanbriolat Feb 1, 2019
effb0de
Merge remote-tracking branch 'origin/master' into docker
alanbriolat Feb 16, 2019
5736423
Enable client PING
alanbriolat Feb 16, 2019
f81af00
Add IRCClient.wait_for() to allow synchronising on IRC server responses
alanbriolat May 22, 2019
dd47684
Allow IRCClient.wait_for() to pass through predicate exceptions
alanbriolat May 22, 2019
eab87e8
Make connection_made()/connection_lost() async, to allow for wait_for()
alanbriolat May 23, 2019
ad93236
Rename wait_for to wait_for_message, let callback decide future result
alanbriolat May 23, 2019
83c7c3a
Make IRCv3 features optional, synchronise on capability requests
alanbriolat May 24, 2019
6ada389
Wait for SASL authentication response
alanbriolat May 24, 2019
65d01a4
Remove less useful capability negotiation methods
alanbriolat May 27, 2019
bc97082
WIP: add tests for event ordering
alanbriolat May 26, 2019
a4522f6
Implement and test HybridEventRunner
alanbriolat May 28, 2019
5b67318
Move event handler calling into HybridEventRunner for consistent exce…
alanbriolat May 28, 2019
f52d94a
Use HybridEventRunner in Bot
alanbriolat May 28, 2019
8de21c5
Make LinkInfo.get_link_info() async, fix up tests
alanbriolat May 28, 2019
11315cf
Use aiohttp instead of requests, for async LinkInfo behaviour
alanbriolat May 29, 2019
5d68091
Test non-blocking behaviour of linkinfo plugin
alanbriolat May 29, 2019
867058b
Oops, forgot aresponses dependency...
alanbriolat May 29, 2019
51194a8
Use aioresponses instead of aresponses (where possible)
alanbriolat May 29, 2019
da1ba36
Simplify HTTP request code with simple_http_get_async
alanbriolat May 29, 2019
4b1ab7e
Make XKCD plugin async, update tests
alanbriolat May 29, 2019
45ee669
Support async LinkInfo integration handlers
alanbriolat May 29, 2019
8cec9bc
Make !hoogle async (untested)
alanbriolat May 29, 2019
73c1caf
Make Imgur plugin async
alanbriolat May 29, 2019
6c0cf33
Make Youtube plugin async
alanbriolat May 30, 2019
7c79d1c
Merge pull request #153 from FromAnkyra/master
LordAro May 30, 2019
e2cdb9a
Use Python 3.6 compatible fork of aiogoogle
alanbriolat May 30, 2019
b43399f
Replace remainder of aresponses usage with fork of aioresponses
alanbriolat May 30, 2019
736fea7
Do Rollbar deploy notification on container start
alanbriolat May 31, 2019
91a9dba
Merge remote-tracking branch 'upstream/master' into docker
alanbriolat May 31, 2019
c373004
Don't force commands to be coroutines, but allow coroutine commands
alanbriolat Jun 1, 2019
7edb990
Unify behaviour for code that accepts both functions & coroutines
alanbriolat Jun 1, 2019
b1e7ae7
Docstrings for HybridEventRunner
alanbriolat Jun 1, 2019
3e02e99
Simplify docker build
alanbriolat Jun 1, 2019
30ed663
Bake git commit ID into container build
alanbriolat Jun 1, 2019
6b20a2c
Update deployment docker-compose.yml to pull from docker hub and auto…
alanbriolat Jun 1, 2019
ea9ce1a
Control bot config location in docker-compose.yml with environment va…
alanbriolat Jun 1, 2019
eee7c36
Make Watchtower optional, update README
alanbriolat Jun 2, 2019
9e1cc50
Enable automated testing on docker hub
alanbriolat Jun 2, 2019
4686647
Avoid some problems with local docker builds by removing .pyc files
alanbriolat Jun 2, 2019
771d237
Merge remote-tracking branch 'upstream/master' into fix-race-conditions
alanbriolat Jun 2, 2019
39d4988
Remove heroku deployment from travis config
alanbriolat Jun 2, 2019
e660c3d
Move rollbar deploy notification to bot startup code
alanbriolat Jun 2, 2019
94131e1
Add GitHub deploy notification
alanbriolat Jun 2, 2019
f4194b2
Upstream PR to aiogoogle now released
alanbriolat Jun 3, 2019
de5b687
Fix some lint
alanbriolat Jun 3, 2019
dde4d5b
Remove commented broken feature
alanbriolat Jun 3, 2019
9887a44
Merge pull request #155 from alanbriolat/fix-race-conditions
alanbriolat Jun 3, 2019
2cbc25f
Enable IRCv3 option for deployment
alanbriolat Jun 3, 2019
d9f5bee
Test and fix maybe_future/maybe_future_result
alanbriolat Jun 4, 2019
8491eaf
Include current event and recent messages in rollbar reports
alanbriolat Jun 6, 2019
b00f4ef
Only send client PING during silence from the server
alanbriolat Jun 6, 2019
5ff5385
Refactor project layout: source code in src/, tests in tests/
alanbriolat Jun 7, 2019
c4d9b7a
Install as package, create `csbot` entrypoint
alanbriolat Jun 7, 2019
c597818
Move runtime requirements to setup.py
alanbriolat Jun 7, 2019
343bc54
Use tox in Travis CI
alanbriolat Jun 7, 2019
97e7eb5
Fix up docker build for new layout
alanbriolat Jun 7, 2019
a82ebd5
Don't build image twice on docker hub, re-use built image for tests
alanbriolat Jun 7, 2019
137588c
Re-enable coveralls in Travis
alanbriolat Jun 7, 2019
88ba430
Remove redundant docker-entrypoint.sh
alanbriolat Jun 7, 2019
481701e
Actually fix coveralls this time?
alanbriolat Jun 7, 2019
e356d81
docker: run as non-root user, reduce context with .dockerignore white…
alanbriolat Jun 8, 2019
260a652
Bump version (somewhat arbitrarily), use setuptools not distutils...
alanbriolat Jun 8, 2019
d78c71b
Add --version option to csbot command
alanbriolat Jun 8, 2019
9f7c69c
Tweaks
alanbriolat Jun 8, 2019
918dd42
Merge pull request #159 from alanbriolat/packaging-etc
alanbriolat Jun 8, 2019
b62c1fd
Change webhook port, can't listen on port 80 as non-root user
alanbriolat Jun 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Exclude everything by default
*

# Whitelist specific files
!src/**/*
!tests/**/*
!setup.py
!requirements.txt
!pytest.ini
!csbot.*.cfg

# Exclude Python temp files
**/__pycache__
**/*.pyc
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cabal-dev
*.egg
*.egg-info
dist
build
build/
eggs
parts
bin
Expand Down Expand Up @@ -58,3 +58,9 @@ htmlcov

# Linters
.ropeproject/

# Project-specific files
csbot.cfg
.env
deploy.env
mongodb-data/
26 changes: 8 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
sudo: false
dist: xenial
language: python
python:
- 3.6
- 3.7

install:
- pip install -r requirements.txt
- pip install tox

script:
- pytest -v --cov
matrix:
include:
- python: '3.6'
env: TOXENV=py36-coveralls
- python: '3.7'
env: TOXENV=py37-coveralls

after_success:
- coveralls
script: tox

cache:
directories:
Expand All @@ -24,12 +23,3 @@ notifications:
- irc.freenode.org#cs-york-dev
skip_join: true
use_notice: true

deploy:
provider: heroku
api_key:
secure: jHzS/L/cN/6gCNJrmVCVDb0V4+Zc1b/PnTYcVfoaAw7/USIb2ZQbU6uwPCpGZ8EL/dQlgOCwJY1UYzowm5d6xvXw+9+iHOIBAAgPe0VEmJ2GMPd1/n8cl5CiJ+LF3NXyBml/F4BL/2wm+kZUxINeZfJaim2OAd9g8PfgpHUey5A=
app: csyorkbot
on:
repo: HackSoc/csbot
python: '3.6'
34 changes: 12 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
FROM ubuntu:18.04
FROM python:3.7

# From python:3.5 docker image, set locale
ENV LANG C.UTF-8
ARG UID=9000
ARG GID=9000

VOLUME /app
WORKDIR /app

# Update base OS
RUN apt-get -y update && apt-get -y upgrade
# Install Python 3(.4)
RUN apt-get -y install python3 python3-dev python-virtualenv
# Install dependencies for Python libs
RUN apt-get -y install libxml2-dev libxslt1-dev zlib1g-dev
RUN groupadd -g $GID app \
&& useradd -u $UID -g $GID --no-create-home app

# Copy needed files to build docker image
ADD requirements.txt docker-entrypoint.sh ./

# Create virtualenv
RUN virtualenv -p python3 /venv
# Populate virtualenv
RUN ./docker-entrypoint.sh pip install --upgrade pip
RUN ./docker-entrypoint.sh pip install -r requirements.txt
COPY --chown=app:app . /app
WORKDIR /app
RUN pip install -r requirements.txt

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["./run_csbot.py", "csbot.cfg"]
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT $SOURCE_COMMIT
USER app:app
CMD ["csbot", "csbot.cfg"]
20 changes: 19 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and running [1]_::
$ python3 -m venv venv3
$ source venv3/bin/activate
$ pip install -r requirements.txt
$ ./run_csbot.py --help
$ csbot --help

Look at ``csbot.deploy.cfg`` for an example of a bot configuration.

Expand All @@ -29,6 +29,22 @@ Docker containers (a MongoDB instance and the bot)::

$ docker-compose up

This will use the `published image`_. To build locally::

$ docker build -t alanbriolat/csbot:latest .

Environment variables to expose to the bot, e.g. for sensitive configuration
values, should be defined in ``deploy.env``. Environment variables used in
``docker-compose.yml`` should be defined in ``.env``:

========================== ================== ===========
Variable Default Description
========================== ================== ===========
``CSBOT_CONFIG_LOCAL`` ``./csbot.cfg`` Path to config file in host filesystem to mount at ``/app/csbot.cfg``
``CSBOT_CONFIG`` ``csbot.cfg`` Path to config file in container, relative to ``/app``
``CSBOT_WATCHTOWER`` ``false`` Set to ``true`` to use Watchtower_ to auto-update when published container is updated
========================== ================== ===========

Backup MongoDB once services are running::

$ docker-compose exec -T mongodb mongodump --archive --gzip --quiet > foo.mongodump.gz
Expand Down Expand Up @@ -73,3 +89,5 @@ We're also using Travis-CI for continuous integration and continuous deployment.
.. _asyncio: https://docs.python.org/3/library/asyncio.html
.. _lxml: http://lxml.de/
.. _Docker Compose: https://docs.docker.com/compose/
.. _published image: https://hub.docker.com/r/alanbriolat/csbot
.. _Watchtower: https://containrrr.github.io/watchtower/
4 changes: 3 additions & 1 deletion csbot.deploy.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[@bot]
ircv3 = true
nickname = Mathison
auth_method = sasl_plain
channels = #cs-york #cs-york-dev #compsoc-uk #hacksoc #hacksoc-bottest
plugins = logger linkinfo hoogle imgur csyork usertrack auth topic helix calc mongodb termdates whois xkcd youtube last webserver webhook github
client_ping = 60

[linkinfo]
scan_limit = 2
Expand Down Expand Up @@ -47,7 +49,7 @@ end =

[webserver]
host = 0.0.0.0
port = 80
port = 8000

[github]
# Re-usable format strings
Expand Down
Loading