Skip to content

Commit ce50769

Browse files
authored
Merge pull request #44 from City-of-Helsinki/release/0.1.0
Release 0.1.0
2 parents bb3d7b7 + 8104567 commit ce50769

108 files changed

Lines changed: 5098 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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"

.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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[uwsgi]
2+
http-socket = :8000
3+
chdir = /app
4+
module = kukkuu.wsgi
5+
static-map = /static=/var/static
6+
uid = appuser
7+
gid = appuser
8+
master = 1
9+
processes = 2
10+
threads = 2

.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:///kukkuu 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) 2019, 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: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,84 @@
1-
# kukkuu
2-
Godchildren of culture API
1+
# Kukkuu
2+
3+
:baby: Godchildren of culture (kulttuurin kummilapset) API :violin:
4+
5+
## Development with Docker
6+
7+
1. Copy `docker-compose.env.yaml.example` to `docker-compose.env.yaml` and modify it if needed.
8+
9+
2. Run `docker-compose up`
10+
11+
The project is now running at [localhost:8081](http://localhost:8081)
12+
13+
## Development without Docker
14+
15+
Prerequisites:
16+
17+
* PostgreSQL 10
18+
* Python 3.7
19+
20+
### Installing Python requirements
21+
22+
* Run `pip install -r requirements.txt`
23+
* Run `pip install -r requirements-dev.txt` (development requirements)
24+
25+
### Database
26+
27+
To setup a database compatible with default database settings:
28+
29+
Create user and database
30+
31+
sudo -u postgres createuser -P -R -S kukkuu # use password `kukkuu`
32+
sudo -u postgres createdb -O kukkuu kukkuu
33+
34+
Allow user to create test database
35+
36+
sudo -u postgres psql -c "ALTER USER kukkuu CREATEDB;"
37+
38+
### Daily running
39+
40+
* Create `.env` file: `touch .env`
41+
* Set the `DEBUG` environment variable to `1`.
42+
* Run `python manage.py migrate`
43+
* Run `python manage.py runserver localhost:8081`
44+
45+
The project is now running at [localhost:8081](http://localhost:8081)
46+
47+
## Keeping Python requirements up to date
48+
49+
1. Install `pip-tools`:
50+
51+
* `pip install pip-tools`
52+
53+
2. Add new packages to `requirements.in` or `requirements-dev.in`
54+
55+
3. Update `.txt` file for the changed requirements file:
56+
57+
* `pip-compile requirements.in`
58+
* `pip-compile requirements-dev.in`
59+
60+
4. If you want to update dependencies to their newest versions, run:
61+
62+
* `pip-compile --upgrade requirements.in`
63+
64+
5. To install Python requirements run:
65+
66+
* `pip-sync requirements.txt`
67+
68+
## Code format
69+
70+
This project uses [`black`](https://github.com/ambv/black) for Python code formatting.
71+
We follow the basic config, without any modifications. Basic `black` commands:
72+
73+
* To let `black` do its magic: `black .`
74+
* To see which files `black` would change: `black --check .`
75+
76+
Or you can use [`pre-commit`](https://pre-commit.com/) to quickly format your code before committing.
77+
78+
79+
1. Install `pre-commit` (there are many ways to do but let's use pip as an example:
80+
* `pip install pre-commit`
81+
2. Set up git hooks from `.pre-commit-config.yaml`, run this command from project root:
82+
* `pre-commit install`
83+
84+
After that, formatting hooks will run against all changed files before committing

children/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config = "children.apps.ChildrenConfig"

0 commit comments

Comments
 (0)