Skip to content

Commit c3017f5

Browse files
authored
Merge pull request #44 from geoadmin/feat-license-and-updates
Added license and some updates - #minor
2 parents 6ddeceb + 0b232f5 commit c3017f5

File tree

11 files changed

+280
-280
lines changed

11 files changed

+280
-280
lines changed

.isort.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[settings]
2-
known_third_party=pytest
3-
known_flask=flask
2+
known_third_party=pytest,celery,gatilegrid
3+
known_flask=flask,flask_sqlalchemy
4+
known_sqlalchemy=sqlalchemy
45
force_single_line=True
5-
sections=FUTURE,STDLIB,THIRDPARTY,FLASK,FIRSTPARTY,LOCALFOLDER
6+
sections=FUTURE,STDLIB,THIRDPARTY,SQLALCHEMY,FLASK,FIRSTPARTY,LOCALFOLDER

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ ignore-docstrings=yes
375375
ignore-imports=no
376376

377377
# Minimum lines number of a similarity.
378-
min-similarity-lines=4
378+
min-similarity-lines=20
379379

380380

381381
[VARIABLES]

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Buster slim python 3.7 base image.
2-
FROM python:3.7-slim-buster
1+
# Buster slim python 3.9 base image.
2+
FROM python:3.9-slim-buster
33
ENV HTTP_PORT 8080
44
RUN groupadd -r geoadmin && useradd -r -s /bin/false -g geoadmin geoadmin
55

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, swisstopo
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Pipfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
PyYAML = "~=5.4"
8-
gevent = "~=20.9.0"
9-
gunicorn = "~=19.9.0"
10-
Flask = "~=1.1.1"
11-
Pillow = "~=8.1.1"
12-
logging-utilities = "~=1.2.1"
13-
python-dotenv = "~=0.19.1"
7+
PyYAML = "*"
8+
gevent = "*"
9+
gunicorn = "*"
10+
Flask = "*"
11+
logging-utilities = "*"
12+
python-dotenv = "*"
1413

1514
[dev-packages]
1615
yapf = "*"
@@ -20,4 +19,4 @@ pylint-flask = "*"
2019
shellcheck-py = "*"
2120

2221
[requires]
23-
python_version = "3.7"
22+
python_version = "3.9"

Pipfile.lock

Lines changed: 216 additions & 248 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
- [Table of content](#table-of-content)
1111
- [Description](#description)
12-
- [Staging Environments](#staging-environments)
1312
- [Versioning](#versioning)
1413
- [Local Development](#local-development)
1514
- [Make Dependencies](#make-dependencies)
@@ -25,14 +24,6 @@
2524
A simple description of the service should go here
2625
A detailed descriptions of the endpoints can be found in the [OpenAPI Spec](openapi.yaml).
2726

28-
### Staging Environments
29-
30-
| Environments | URL |
31-
| ------------ | --------------------------------------------------------------------------------------------------------------------- |
32-
| DEV | [https://service-name.bgdi-dev.swisstopo.cloud/v4/name/](https://service-name.bgdi-dev.swisstopo.cloud/v4/name/) |
33-
| INT | [https://service-name.bgdi-int.swisstopo.cloud/v4/name/](https://service-name.bgdi-int.swisstopo.cloud/v4/name/) |
34-
| PROD | [https://service-name.bgdi-prod.swisstopo.cloud/v4/name/](https://service-name.bgdi-int.swisstopo.cloud/v4/name/) |
35-
3627
## Versioning
3728

3829
This service uses [SemVer](https://semver.org/) as versioning scheme. The versioning is automatically handled by `.github/workflows/main.yml` file.
@@ -43,7 +34,7 @@ See also [Git Flow - Versioning](https://github.com/geoadmin/doc-guidelines/blob
4334

4435
### Make Dependencies
4536

46-
The **Make** targets assume you have **python3.7**, **pipenv**, **bash**, **curl**, **tar**, **docker** and **docker-compose** installed.
37+
The **Make** targets assume you have **python3.9**, **pipenv**, **bash**, **curl**, **tar**, **docker** and **docker-compose** installed.
4738

4839
### Setting up to work
4940

@@ -137,9 +128,6 @@ docker ps --format="table {{.ID}}\t{{.Image}}\t{{.Labels}}"
137128

138129
## Deployment
139130

140-
This service is to be deployed to the Kubernetes cluster once it is merged.
141-
TO DO: give instructions to deploy to kubernetes.
142-
143131
### Deployment configuration
144132

145133
The service is configured by Environment Variable:
@@ -149,3 +137,6 @@ The service is configured by Environment Variable:
149137
| LOGGING_CFG | logging-cfg-local.yml | Logging configuration file |
150138
| FORWARED_ALLOW_IPS | `*` | Sets the gunicorn `forwarded_allow_ips` (see https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips). This is required in order to `secure_scheme_headers` to works. |
151139
| FORWARDED_PROTO_HEADER_NAME | `X-Forwarded-Proto` | Sets gunicorn `secure_scheme_headers` parameter to `{FORWARDED_PROTO_HEADER_NAME: 'https'}`, see https://docs.gunicorn.org/en/stable/settings.html#secure-scheme-headers. |
140+
| SCRIPT_NAME | `''` | If the service is behind a reverse proxy and not served at the root, the route prefix must be set in `SCRIPT_NAME`. |
141+
| WSGI_WORKERS | `2` | WSGI service number of workers. 0 or negative value means that the number of worker are computed from the number of cpu. |
142+
| WSGI_TIMEOUT | `30`| WSGI timeout. |

app/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@
2828
# Proxy settings
2929
FORWARED_ALLOW_IPS = os.getenv('FORWARED_ALLOW_IPS', '*')
3030
FORWARDED_PROTO_HEADER_NAME = os.getenv('FORWARDED_PROTO_HEADER_NAME', 'X-Forwarded-Proto')
31+
WSGI_WORKERS = int(os.getenv('WSGI_WORKERS', '2'))
32+
if WSGI_WORKERS <= 0:
33+
from multiprocessing import cpu_count
34+
WSGI_WORKERS = (cpu_count() * 2) + 1
35+
WSGI_TIMEOUT = int(os.getenv('WSGI_TIMEOUT', '3'))

buildspec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
phases:
1313
install:
1414
runtime-versions:
15-
python: 3.7
15+
python: 3.9
1616
commands:
1717
- aws --version
1818
- echo "Login to AWS ECR docker registry"
@@ -29,7 +29,7 @@ phases:
2929
export GITHUB_BRANCH=${GITHUB_BRANCH#remotes/origin/};
3030
fi
3131
- export GITHUB_COMMIT=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
32-
- export GITHUB_TAG="$(git describe --tags 2>/dev/null)"
32+
- export GITHUB_TAG="$(git describe --tags || echo 'no-version-info')"
3333
- echo "GITHUB_BRANCH=${GITHUB_BRANCH} GITHUB_COMMIT=${GITHUB_COMMIT} GITHUB_TAG=${GITHUB_TAG} DOCKER_IMG_TAG=${DOCKER_IMG_TAG}"
3434
- echo "Creating a clean environment"
3535
- make ci

service_launcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'''Service launcher to use Flask without wsgi.py
22
'''
3-
from app import app # pylint: disable=unused-import
43
from app.helpers.utils import init_logging
54

65
# Initialize Logging using JSON format for all loggers and using the Stream Handler.
76
init_logging()
7+
8+
# pylint: disable=unused-import,wrong-import-position
9+
from app import app # pylint: disable=unused-import

0 commit comments

Comments
 (0)