1
0
Fork 0
forked from s3lph/matemat

Merged staging/deployment configuration (Dockerfiles and CI config) into a branch derived from master.

This commit is contained in:
s3lph 2018-07-16 22:35:35 +02:00
commit 87f65c84b0
5 changed files with 58 additions and 15 deletions

2
.gitignore vendored
View file

@ -9,5 +9,5 @@
*.sqlite3
*.db
**/matemat.conf
static/upload/
**/matemat.conf

View file

@ -1,20 +1,40 @@
---
image: s3lph/matemat-ci:20180619-01
image: s3lph/matemat-ci:20180711-02
stages:
- test
- codestyle
- build
- staging
test:
stage: test
script:
- pip3 install -r requirements.txt
- python3-coverage run --branch -m unittest discover matemat
- python3-coverage report -m --include 'matemat/*' --omit '*/test_*.py'
- sudo -u matemat python3-coverage run --branch -m unittest discover matemat
- sudo -u matemat python3-coverage report -m --include 'matemat/*' --omit '*/test_*.py'
codestyle:
stage: codestyle
stage: test
script:
- pip3 install -r requirements.txt
- pycodestyle matemat
# - mypy --ignore-missing-imports --strict -p matemat
- sudo -u matemat pycodestyle matemat
# - sudo -u matemat mypy --ignore-missing-imports --strict -p matemat
build:
stage: build
script:
- docker build -t "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com
- docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)"
staging:
stage: staging
script:
- eval $(ssh-agent -s)
- ssh-add - <<<"$STAGING_SSH_PRIVATE_KEY"
- echo "$(git rev-parse HEAD)" | ssh -p 20022 -oStrictHostKeyChecking=no matemat@kernelpanic.lol
environment:
name: staging
url: https://matemat.kernelpanic.lol/
only:
- /^staging-.*$/

View file

@ -1,10 +1,9 @@
FROM debian:buster
FROM python:3.6-alpine
RUN useradd -d /home/matemat -m matemat
RUN apt-get update -qy
RUN apt-get install -y --no-install-recommends python3-dev python3-pip python3-coverage python3-setuptools build-essential
RUN pip3 install wheel pycodestyle mypy
RUN mkdir -p /var/matemat/db /var/matemat/upload
ADD . /
RUN pip3 install -r /requirements.txt
WORKDIR /home/matemat
USER matemat
EXPOSE 80/tcp
CMD [ "/usr/local/bin/python3", "-m", "matemat", "/etc/matemat.conf", "/matemat.docker.conf" ]

13
matemat.docker.conf Normal file
View file

@ -0,0 +1,13 @@
[Matemat]
Address=::
Port=80
StaticPath=/static
TemplatePath=/templates
LogTarget=stdout
[Pagelets]
UploadDir=/static/upload
DatabaseFile=/var/matemat/db/test.db

11
testing/Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM debian:buster
RUN useradd -d /home/matemat -m matemat
RUN mkdir -p /var/matemat/db && chown matemat:matemat -R /var/matemat/db
RUN mkdir -p /var/matemat/upload && chown matemat:matemat -R /var/matemat/upload
RUN apt-get update -qy
RUN apt-get install -y --no-install-recommends sudo openssh-client git docker.io python3-dev python3-pip python3-coverage python3-setuptools build-essential
RUN pip3 install wheel pycodestyle mypy
WORKDIR /home/matemat