Skip to content

Commit 874845d

Browse files
committed
Initial commit
0 parents  commit 874845d

39 files changed

Lines changed: 1032 additions & 0 deletions

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEBUG=1

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
*$py.class
2+
*,cover
3+
*.egg
4+
*.egg-info/
5+
*.log
6+
*.manifest
7+
*.mo
8+
*.pid
9+
*.pot
10+
*.py[cod]
11+
*.pyc
12+
*.seed
13+
*.so
14+
*.spec
15+
*.stTheme.cache
16+
*.sublime-workspace
17+
*.tmlanguage.cache
18+
*.tmPreferences.cache
19+
._*
20+
.AppleDouble
21+
.cache
22+
.coverage
23+
.coverage.*
24+
.DS_Store
25+
.eggs/
26+
.env
27+
.grunt
28+
.hypothesis/
29+
.idea
30+
.installed.cfg
31+
.ipynb_checkpoints
32+
.lock-wscript
33+
.LSOverride
34+
.node_repl_history
35+
.npm
36+
.nyc_output
37+
.Python
38+
.python-version
39+
.ropeproject
40+
.scrapy
41+
.spyderproject
42+
.tox/
43+
__pycache__/
44+
_build
45+
bower_components
46+
build/
47+
build/Release
48+
celerybeat-schedule
49+
coverage
50+
coverage.xml
51+
develop-eggs/
52+
dist/
53+
docs/_build/
54+
downloads/
55+
eggs/
56+
env/
57+
ENV/
58+
htmlcov/
59+
instance/
60+
jspm_packages
61+
lib-cov
62+
lib//Users/tuomas/.pyenv/shims/python
63+
lib64/
64+
local_settings.py
65+
logs
66+
node_modules
67+
nosetests.xml
68+
npm-debug.log*
69+
parts/
70+
pids
71+
pip-delete-this-directory.txt
72+
pip-log.txt
73+
repo_name
74+
sdist/
75+
sftp-config.json
76+
target/
77+
var/
78+
venv/
79+
.pytest_cache/
80+
docker-compose.env.yaml

.gitlab-ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Mandatory include
2+
include:
3+
- project: 'city-of-helsinki/kuva/ci-cd-config/ci-configuration'
4+
ref: v2
5+
file: '/.gitlab-ci-template.yml'
6+
7+
# These variables are available for all stages
8+
variables:
9+
APP_MIGRATE_COMMAND: /app/.prod/on_deploy.sh
10+
SERVICE_PORT: "8000"
11+
12+
# Build stage must be included and it must extend .build.
13+
build:
14+
extends: .build
15+
16+
review:
17+
# These variables are available only for review env and are merged with the general variables defined above.
18+
variables:
19+
K8S_SECRET_ALLOWED_HOSTS: "*"
20+
K8S_SECRET_DEBUG: 1
21+
K8S_SECRET_TOKEN_AUTH_AUTHSERVER_URL: "https://tunnistamo.test.kuva.hel.ninja/openid"
22+
K8S_SECRET_CORS_ORIGIN_ALLOW_ALL: 1
23+
24+
staging:
25+
# By default the staging environment is created from the master-branch.
26+
# Here we define that it should be created from the branch called "develop" instead.
27+
only:
28+
refs:
29+
- develop
30+
# These variables are available only for staging env and are merged with the general variables defined above.
31+
variables:
32+
K8S_SECRET_ALLOWED_HOSTS: "*"
33+
K8S_SECRET_CORS_ORIGIN_ALLOW_ALL: 1
34+
K8S_SECRET_SECRET_KEY: "$GL_QA_DJANGO_SECRET_KEY"
35+
K8S_SECRET_SKIP_DATABASE_CHECK: 1
36+
K8S_SECRET_TOKEN_AUTH_AUTHSERVER_URL: "https://tunnistamo.test.kuva.hel.ninja/openid"
37+
K8S_SECRET_ILMOITIN_QUEUE_NOTIFICATIONS: 1
38+
K8S_SECRET_MAIL_MAILGUN_KEY: "$SECRET_MAILGUN_API_KEY"
39+
K8S_SECRET_MAIL_MAILGUN_DOMAIN: "mail.hel.ninja"
40+
K8S_SECRET_MAIL_MAILGUN_API: "https://api.eu.mailgun.net/v3"
41+
K8S_SECRET_MAILER_EMAIL_BACKEND: "anymail.backends.mailgun.EmailBackend"
42+
K8S_SECRET_DEFAULT_FROM_EMAIL: "no-reply@hel.ninja"
43+
K8S_SECRET_SENTRY_DSN: "$GL_SENTRY_DNS"
44+
K8S_SECRET_SENTRY_ENVIRONMENT: "test"

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/mirrors-isort
5+
rev: v4.3.21
6+
hooks:
7+
- id: isort
8+
- repo: https://github.com/psf/black
9+
rev: stable
10+
hooks:
11+
- id: black
12+
- repo: https://gitlab.com/pycqa/flake8
13+
rev: 3.7.9
14+
hooks:
15+
- id: flake8
16+
exclude: migrations|snapshots

.prod/on_deploy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
4+
./manage.py migrate --noinput

.prod/uwsgi.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[uwsgi]
2+
http-socket = :8000
3+
chdir = /app
4+
module = palvelutarjotin.wsgi
5+
static-map = /static=/var/static
6+
static-map = /media=/app/var/media
7+
uid = appuser
8+
gid = appuser
9+
master = 1
10+
processes = 2
11+
threads = 2
12+
cron = -1 -1 -1 -1 -1 /app/manage.py send_mail
13+
cron = -20 -1 -1 -1 -1 /app/manage.py retry_deferred
14+
cron = 0 0 -1 -1 -1 /app/manage.py purge_mail_log 7

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
branches: {only: [master, develop]}
2+
sudo: false
3+
language: python
4+
python: 3.7
5+
cache: pip
6+
7+
addons:
8+
postgresql: "10"
9+
apt:
10+
packages:
11+
- postgresql-10
12+
- postgresql-client-10
13+
14+
matrix:
15+
include:
16+
- name: Unit tests
17+
env: DATABASE_URL=postgres:///notification_service SECRET_KEY=topsecret123
18+
services: [postgresql]
19+
install: pip install -r requirements.txt -r requirements-dev.txt
20+
script: pytest -ra -vv --doctest-modules --cov=.
21+
after_success: pip install codecov && codecov
22+
23+
- name: Style
24+
install: pip install -r requirements.txt -r requirements-dev.txt
25+
script:
26+
- black --check .
27+
- flake8
28+
- isort -c

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ==============================
2+
FROM helsinkitest/python:3.7-slim as appbase
3+
# ==============================
4+
RUN mkdir /entrypoint
5+
6+
COPY --chown=appuser:appuser requirements.txt /app/requirements.txt
7+
COPY --chown=appuser:appuser requirements-prod.txt /app/requirements-prod.txt
8+
9+
RUN apt-install.sh \
10+
git \
11+
netcat \
12+
libpq-dev \
13+
build-essential \
14+
&& pip install -U pip \
15+
&& pip install --no-cache-dir -r /app/requirements.txt \
16+
&& pip install --no-cache-dir -r /app/requirements-prod.txt \
17+
&& apt-cleanup.sh build-essential
18+
19+
COPY --chown=appuser:appuser docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
20+
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
21+
22+
# ==============================
23+
FROM appbase as development
24+
# ==============================
25+
26+
COPY --chown=appuser:appuser requirements-dev.txt /app/requirements-dev.txt
27+
RUN apt-install.sh \
28+
build-essential \
29+
&& pip install --no-cache-dir -r /app/requirements-dev.txt \
30+
&& apt-cleanup.sh build-essential
31+
32+
ENV DEV_SERVER=1
33+
34+
COPY --chown=appuser:appuser . /app/
35+
36+
USER appuser
37+
EXPOSE 8081/tcp
38+
39+
# ==============================
40+
FROM appbase as production
41+
# ==============================
42+
43+
COPY --chown=appuser:appuser . /app/
44+
45+
RUN SECRET_KEY="only-used-for-collectstatic" python manage.py collectstatic
46+
47+
USER appuser
48+
EXPOSE 8000/tcp

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020, City of Helsinki
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Notification service API
2+
// TBA

0 commit comments

Comments
 (0)