diff options
Diffstat (limited to '')
-rw-r--r-- | .gitlab-ci.yml | 23 | ||||
-rw-r--r-- | Pipfile | 2 | ||||
-rw-r--r-- | docker/ci.Dockerfile | 24 | ||||
-rw-r--r-- | pysite/__init__.py | 13 |
4 files changed, 40 insertions, 22 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 960a7362..770312fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,22 +1,9 @@ -image: python:3.6-alpine3.7 +image: pythondiscord/site-ci:latest variables: - PIPENV_VENV_IN_PROJECT: 1 - PIPENV_IGNORE_VIRTUALENVS: 1 RABBITMQ_HOST: rabbit RETHINKDB_HOST: rethinkdb - -before_script: - - apk add --update tini - - apk add --update git - - apk add --update build-base - - apk add --update gcc - - apk add --update cmake - - apk add --update autoconf - - apk add --update automake - - apk add --update libtool - stages: - test - deploy @@ -39,10 +26,7 @@ test: - ".gem" script: - - apk add --update ruby ruby-dev ruby-rdoc ruby-irb - - pip install pipenv - - pipenv sync --dev --three - - gem install scss_lint + - pipenv sync --dev - pipenv run lint - pipenv run lintscss - pipenv run python gunicorn_config.py @@ -60,9 +44,8 @@ deploy: stage: deploy script: - - apk add docker curl - sh scripts/deploy.sh environment: name: Production - url: https://pythondiscord.com
\ No newline at end of file + url: https://pythondiscord.com @@ -49,5 +49,7 @@ lint = "python -m flake8" lintscss = "scss-lint scss/pysite" push = "docker push pythondiscord/site:latest" pushbase = "docker push pythondiscord/site-base:latest" +buildci = "docker build -t pythondiscord/site-ci:latest -f docker/ci.Dockerfile ." +pushci = "docker push pythondiscord/site-ci:latest" rundev = "python app.py" test = "py.test tests --cov pysite --cov-report term-missing -v" diff --git a/docker/ci.Dockerfile b/docker/ci.Dockerfile new file mode 100644 index 00000000..69a7e5ba --- /dev/null +++ b/docker/ci.Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.6-alpine3.7 + +RUN apk add --update tini \ + git \ + build-base \ + gcc \ + cmake \ + autoconf \ + automake \ + libtool \ + ruby \ + ruby-dev \ + ruby-rdoc \ + ruby-irb \ + docker \ + curl + +ENV PIPENV_VENV_IN_PROJECT=1 +ENV PIPENV_IGNORE_VIRTUALENVS=1 +ENV PIPENV_NOSPIN=1 +ENV PIPENV_HIDE_EMOJIS=1 + +RUN pip install pipenv +RUN gem install scss_lint diff --git a/pysite/__init__.py b/pysite/__init__.py index a8009f07..c02afd0d 100644 --- a/pysite/__init__.py +++ b/pysite/__init__.py @@ -1,6 +1,7 @@ import logging +import os import sys -from logging import Logger, StreamHandler +from logging import Logger, StreamHandler, handlers from logmatic import JsonFormatter @@ -37,7 +38,15 @@ if DEBUG_MODE: json_handler.formatter = JsonFormatter() logging_handlers.append(json_handler) else: - logging_handlers.append(logging.FileHandler(filename="log.txt", mode="w")) + logdir = "log" + logfile = logdir+os.sep+"site.log" + megabyte = 1048576 + + if not os.path.exists(logdir): + os.makedirs(logdir) + + filehandler = handlers.RotatingFileHandler(logfile, maxBytes=(megabyte*5), backupCount=7) + logging_handlers.append(filehandler) json_handler = logging.StreamHandler(stream=sys.stdout) json_handler.formatter = JsonFormatter() |