Skip to content

Commit 4e239aa

Browse files
author
Simon Berger
committed
Gisi Container:tm:
1 parent 466daf0 commit 4e239aa

17 files changed

Lines changed: 139 additions & 149 deletions

.docker/start.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /usr/bin/env bash
2+
set -e
3+
exec /usr/bin/supervisord

.docker/supervisord.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:gisi]
5+
priority=10
6+
directory=/gisi
7+
command=python run.py
8+
user=root
9+
autorestart=true
10+
stdout_logfile=/dev/stdout
11+
stdout_logfile_maxbytes=0
12+
stderr_logfile=/dev/stderr
13+
stderr_logfile_maxbytes=0

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
venv/
2+
tests/
3+
scripts/
4+
gh-pages/

Dockerfile

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
1-
FROM frolvlad/alpine-python3
2-
3-
RUN apk update && apk add \
4-
build-base \
5-
freetype-dev \
6-
fribidi-dev \
7-
harfbuzz-dev \
8-
jpeg-dev \
9-
lcms2-dev \
10-
libpng \
11-
openjpeg-dev \
12-
python3-dev \
13-
tcl-dev \
14-
tiff-dev \
15-
tk-dev \
16-
zlib-dev
17-
18-
WORKDIR /gisi
19-
ADD . /gisi
1+
FROM python:stretch
202

3+
LABEL maintainer=Simon
4+
5+
# Install required packages
6+
RUN apt-get -yqq update && \
7+
apt-get -yqq install curl unzip && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
# Install Chrome WebDriver
11+
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
12+
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
13+
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
14+
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
15+
rm /tmp/chromedriver_linux64.zip && \
16+
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
17+
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
18+
19+
# Install Google Chrome
20+
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
21+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
22+
apt-get -yqq update && \
23+
apt-get -yqq install google-chrome-stable && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
# Install Supervisord
27+
RUN apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
28+
COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
29+
30+
# Install Python requirements
31+
COPY ./requirements.txt ./
2132
RUN pip install -r requirements.txt
2233

23-
CMD ["python3", "run.py"]
34+
COPY gisi /gisi/gisi
35+
COPY run.py /gisi/
36+
COPY data /gisi/data
37+
RUN mkdir /gisi/logs
38+
39+
VOLUME /gisi/logs
40+
VOLUME /gisi/data
41+
42+
COPY .docker/start.sh /start.sh
43+
RUN chmod +x /start.sh
44+
45+
ENTRYPOINT ["/start.sh"]

data/logging.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
version: "3"
2-
services:
3-
gisi:
4-
image: siku2/Gisi:navi
5-
links:
6-
- mongo
7-
depends_on:
8-
- mongo
9-
environment:
10-
- MONGO_URL=mongodb://mongo/messageApp
11-
mongo:
12-
image: mongo:3.7
13-
volumes:
14-
- mongo:/data/db
15-
expose:
16-
- "27017"
17-
volumes:
18-
mongo:

gisi/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import logging.config
2+
3+
from . import __logging__
4+
logging.config.dictConfig(__logging__)
5+
6+
log = logging.getLogger(__name__)
7+
log.debug("logging setup")
8+
19
from .config import SetDefaults
210
from .gisi import Gisi
311
from .signals import GisiSignal

gisi/__logging__.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import sys
2+
3+
CONFIG = {
4+
"version": 1,
5+
"disable_existing_loggers": True,
6+
7+
"formatters": {
8+
"detailed": {
9+
"format": "{asctime} - <{name}> {message}",
10+
"style": "{"
11+
},
12+
"color": {
13+
"()": "colorlog.ColoredFormatter",
14+
"format": "{log_color}{levelname:8}{reset} {bg_blue}{name}{reset} {message}",
15+
"style": "{",
16+
"log_colors": {
17+
"DEBUG": "cyan",
18+
"INFO": "green",
19+
"WARNING": "yellow",
20+
"ERROR": "red",
21+
"CRITICAL": "red,bg_white"
22+
}
23+
}
24+
},
25+
26+
"handlers": {
27+
"console": {
28+
"class": "logging.StreamHandler",
29+
"formatter": "color"
30+
},
31+
"file": {
32+
"class": "logging.FileHandler",
33+
"filename": "logs/gisi.log",
34+
"mode": "w",
35+
"formatter": "detailed"
36+
}
37+
},
38+
39+
"loggers": {
40+
"gisi": {
41+
"level": "DEBUG",
42+
"propagate": False,
43+
"handlers": ["console", "file"]
44+
}
45+
},
46+
47+
"root": {
48+
"level": "WARN",
49+
"handlers": ["console", "file"]
50+
}
51+
}
52+
53+
sys.modules[__name__] = CONFIG

gisi/cogs/eventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from gisi.constants import FileLocations
66

7-
eventory.load_ext("inktory")
7+
# eventory.load_ext("inktory")
88

99

1010
def setup(bot: Bot):

gisi/cogs/web.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import logging
12
from io import BytesIO
23

3-
import logging
44
from aiohttp import ClientConnectorError, ClientResponseError
55
from discord import Embed, File
66
from discord.ext.commands import command
77

88
from gisi.constants import Colours
99
from gisi.utils import UrlConverter
10+
from gisi.utils.browser import UserAgents
1011

1112
log = logging.getLogger(__name__)
1213

@@ -26,8 +27,7 @@ async def show(self, ctx, url: UrlConverter):
2627
"""
2728
await ctx.message.edit(content=f"checking {url}...")
2829
try:
29-
headers = {
30-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0"}
30+
headers = {"User-Agent": UserAgents.DESKTOP.value}
3131
async with self.bot.aiosession.head(url, headers=headers, allow_redirects=True) as resp:
3232
resp.raise_for_status()
3333
embed_image_url = None

0 commit comments

Comments
 (0)