Skip to content

Commit b3106ad

Browse files
authored
Merge pull request #1 from HackSoc/master
updating cause I forked this ages ago
2 parents f2d381a + b62c1fd commit b3106ad

File tree

137 files changed

+2163
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+2163
-951
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Exclude everything by default
2+
*
3+
4+
# Whitelist specific files
5+
!src/**/*
6+
!tests/**/*
7+
!setup.py
8+
!requirements.txt
9+
!pytest.ini
10+
!csbot.*.cfg
11+
12+
# Exclude Python temp files
13+
**/__pycache__
14+
**/*.pyc

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cabal-dev
2727
*.egg
2828
*.egg-info
2929
dist
30-
build
30+
build/
3131
eggs
3232
parts
3333
bin
@@ -58,3 +58,9 @@ htmlcov
5858

5959
# Linters
6060
.ropeproject/
61+
62+
# Project-specific files
63+
csbot.cfg
64+
.env
65+
deploy.env
66+
mongodb-data/

.travis.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
sudo: false
22
dist: xenial
33
language: python
4-
python:
5-
- 3.6
6-
- 3.7
7-
84
install:
9-
- pip install -r requirements.txt
5+
- pip install tox
106

11-
script:
12-
- pytest -v --cov
7+
matrix:
8+
include:
9+
- python: '3.6'
10+
env: TOXENV=py36-coveralls
11+
- python: '3.7'
12+
env: TOXENV=py37-coveralls
1313

14-
after_success:
15-
- coveralls
14+
script: tox
1615

1716
cache:
1817
directories:
@@ -24,12 +23,3 @@ notifications:
2423
- irc.freenode.org#cs-york-dev
2524
skip_join: true
2625
use_notice: true
27-
28-
deploy:
29-
provider: heroku
30-
api_key:
31-
secure: jHzS/L/cN/6gCNJrmVCVDb0V4+Zc1b/PnTYcVfoaAw7/USIb2ZQbU6uwPCpGZ8EL/dQlgOCwJY1UYzowm5d6xvXw+9+iHOIBAAgPe0VEmJ2GMPd1/n8cl5CiJ+LF3NXyBml/F4BL/2wm+kZUxINeZfJaim2OAd9g8PfgpHUey5A=
32-
app: csyorkbot
33-
on:
34-
repo: HackSoc/csbot
35-
python: '3.6'

Dockerfile

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
FROM ubuntu:18.04
1+
FROM python:3.7
22

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

6-
VOLUME /app
7-
WORKDIR /app
8-
9-
# Update base OS
10-
RUN apt-get -y update && apt-get -y upgrade
11-
# Install Python 3(.4)
12-
RUN apt-get -y install python3 python3-dev python-virtualenv
13-
# Install dependencies for Python libs
14-
RUN apt-get -y install libxml2-dev libxslt1-dev zlib1g-dev
6+
RUN groupadd -g $GID app \
7+
&& useradd -u $UID -g $GID --no-create-home app
158

16-
# Copy needed files to build docker image
17-
ADD requirements.txt docker-entrypoint.sh ./
18-
19-
# Create virtualenv
20-
RUN virtualenv -p python3 /venv
21-
# Populate virtualenv
22-
RUN ./docker-entrypoint.sh pip install --upgrade pip
23-
RUN ./docker-entrypoint.sh pip install -r requirements.txt
9+
COPY --chown=app:app . /app
10+
WORKDIR /app
11+
RUN pip install -r requirements.txt
2412

25-
ENTRYPOINT ["./docker-entrypoint.sh"]
26-
CMD ["./run_csbot.py", "csbot.cfg"]
13+
ARG SOURCE_COMMIT
14+
ENV SOURCE_COMMIT $SOURCE_COMMIT
15+
USER app:app
16+
CMD ["csbot", "csbot.cfg"]

README.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and running [1]_::
1414
$ python3 -m venv venv3
1515
$ source venv3/bin/activate
1616
$ pip install -r requirements.txt
17-
$ ./run_csbot.py --help
17+
$ csbot --help
1818

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

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

3030
$ docker-compose up
3131

32+
This will use the `published image`_. To build locally::
33+
34+
$ docker build -t alanbriolat/csbot:latest .
35+
36+
Environment variables to expose to the bot, e.g. for sensitive configuration
37+
values, should be defined in ``deploy.env``. Environment variables used in
38+
``docker-compose.yml`` should be defined in ``.env``:
39+
40+
========================== ================== ===========
41+
Variable Default Description
42+
========================== ================== ===========
43+
``CSBOT_CONFIG_LOCAL`` ``./csbot.cfg`` Path to config file in host filesystem to mount at ``/app/csbot.cfg``
44+
``CSBOT_CONFIG`` ``csbot.cfg`` Path to config file in container, relative to ``/app``
45+
``CSBOT_WATCHTOWER`` ``false`` Set to ``true`` to use Watchtower_ to auto-update when published container is updated
46+
========================== ================== ===========
47+
3248
Backup MongoDB once services are running::
3349

3450
$ docker-compose exec -T mongodb mongodump --archive --gzip --quiet > foo.mongodump.gz
@@ -73,3 +89,5 @@ We're also using Travis-CI for continuous integration and continuous deployment.
7389
.. _asyncio: https://docs.python.org/3/library/asyncio.html
7490
.. _lxml: http://lxml.de/
7591
.. _Docker Compose: https://docs.docker.com/compose/
92+
.. _published image: https://hub.docker.com/r/alanbriolat/csbot
93+
.. _Watchtower: https://containrrr.github.io/watchtower/

csbot.deploy.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[@bot]
2+
ircv3 = true
23
nickname = Mathison
34
auth_method = sasl_plain
45
channels = #cs-york #cs-york-dev #compsoc-uk #hacksoc #hacksoc-bottest
56
plugins = logger linkinfo hoogle imgur csyork usertrack auth topic helix calc mongodb termdates whois xkcd youtube last webserver webhook github
7+
client_ping = 60
68

79
[linkinfo]
810
scan_limit = 2
@@ -47,7 +49,7 @@ end =
4749

4850
[webserver]
4951
host = 0.0.0.0
50-
port = 80
52+
port = 8000
5153

5254
[github]
5355
# Re-usable format strings

0 commit comments

Comments
 (0)