diff --git a/.gitignore b/.gitignore index 925c5c5..ea15acd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,5 @@ *.sqlite3 *.db -**/matemat.conf static/upload/ +**/matemat.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9adc47d..72bd21c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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-.*$/ diff --git a/Dockerfile b/Dockerfile index 126a06f..83514a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/doc b/doc index c68df9d..92e168a 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit c68df9d86af1d8d0ebb6b6609efeef14f7103761 +Subproject commit 92e168a288b396a7a97d200b80affdf8690bd03d diff --git a/matemat.docker.conf b/matemat.docker.conf new file mode 100644 index 0000000..ccb8451 --- /dev/null +++ b/matemat.docker.conf @@ -0,0 +1,13 @@ +[Matemat] + +Address=:: +Port=80 + +StaticPath=/static +TemplatePath=/templates + +LogTarget=stdout + +[Pagelets] +UploadDir=/static/upload +DatabaseFile=/var/matemat/db/test.db diff --git a/testing/Dockerfile b/testing/Dockerfile new file mode 100644 index 0000000..c51e01b --- /dev/null +++ b/testing/Dockerfile @@ -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