1
0
Fork 0
forked from s3lph/matemat

Merge branch 'deployment-to-master' into 'master'

Improved CI Pipeline and Dockerfiles

Closes #8

See merge request s3lph/matemat!17
This commit is contained in:
s3lph 2018-07-17 18:51:07 +00:00
commit e11205c36d
6 changed files with 63 additions and 16 deletions

2
.gitignore vendored
View file

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

View file

@ -1,20 +1,44 @@
---
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 tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" registry.gitlab.com/s3lph/matemat:latest-staging
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com
- docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)"
- docker push registry.gitlab.com/s3lph/matemat:latest-staging
only:
- /^staging-.*$/
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" ]

2
doc

@ -1 +1 @@
Subproject commit c68df9d86af1d8d0ebb6b6609efeef14f7103761
Subproject commit 92e168a288b396a7a97d200b80affdf8690bd03d

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