Commit 437f544e authored by Leonard Marschke's avatar Leonard Marschke

merge from reference repo

parent aec1ff47
Pipeline #7052 failed with stages
in 1 minute and 30 seconds
......@@ -3,7 +3,12 @@ image: lmmdock/build-environment
stages:
- test
- build
- deploy
- deployStaging
- deployProduction
variables:
DOCKER_DRIVER: overlay2
GIT_SSH_COMMAND: "ssh -i .ssh/id_rsa -o UserKnownHostsFile=.ssh/known_hosts"
before_script:
- mkdir -p build
......@@ -43,13 +48,63 @@ build-api-definition:
expire_in: 1 week
pages:
stage: deploy
stage: deployProduction
script:
- mkdir -p public
- cp -av build/api public/api
only:
- master
dependencies:
- build-api-definition
artifacts:
paths:
- public
expire_in: 1 week
dockerImage-flask:
stage: build
services:
- docker:dind
variables:
DOCKER_ARTIFACT_TAG: "flask-training-api"
image: timnn/docker:latest
script:
- wget -O - https://bpdbsystel.pages.rechenknecht.net/ci-snippets/docker-scripts.tgz | tar xz
- ./docker-build.sh . "build/flask-training-api.gz"
dependencies: []
artifacts:
paths:
- build/flask-training-api.gz
expire_in: 1 day
deploy-flask:staging:
image: lmmdock/build-environment
stage: deployStaging
script:
- deploy/init_ssh.sh
- wget https://raw.githubusercontent.com/lmm-git/temply/master/temply.sh
- source ./temply.sh
- declare -A templyParams
- templyParams[FLAVOR]="staging"
- templyParams[PORT]="3091"
- scp -i .ssh/id_rsa -o UserKnownHostsFile=.ssh/known_hosts build/flask-training-api.gz deploy@10.20.231.134:/tmp/flask-training-api.gz
- temply deploy/flask.sh templyParams | ssh -i .ssh/id_rsa -o UserKnownHostsFile=.ssh/known_hosts deploy@10.20.231.134 'bash -s'
dependencies:
- dockerImage-flask
deploy-flask:production:
image: lmmdock/build-environment
stage: deployProduction
when: manual
script:
- deploy/init_ssh.sh
- wget https://raw.githubusercontent.com/lmm-git/temply/master/temply.sh
- source ./temply.sh
- declare -A templyParams
- templyParams[FLAVOR]="production"
- templyParams[PORT]="3081"
- scp -i .ssh/id_rsa -o UserKnownHostsFile=.ssh/known_hosts build/flask-training-api.gz deploy@10.20.231.134:/tmp/flask-training-api.gz
- temply deploy/flask.sh templyParams | ssh -i .ssh/id_rsa -o UserKnownHostsFile=.ssh/known_hosts deploy@10.20.231.134 'bash -s'
dependencies:
- dockerImage-flask
......@@ -3,3 +3,5 @@ FROM lmmdock/flask-webserver
COPY ./ /app
RUN pip3 install -r requirements.txt
RUN chown uwsgi:uwsgi /app
......@@ -2,6 +2,7 @@ from flask_common.flask import Flask
from flask_common.util import register_cors_headers
from peewee_common.Database import Holder
from util import sentry
flask = Flask(__name__)
flask.config.from_pyfile("../application.cfg")
......@@ -20,3 +21,4 @@ flask.register_blueprint(V1)
register_cors_headers(flask, allowOrigin=lambda _: True, allowCredentials=False,
allowedHeaders='Content-Type,cache-control,x-requested-with')
sentry.setup(flask)
......@@ -65,7 +65,7 @@ def get_tasks():
@V1.route('/answers', methods=['GET'])
def get_answers():
return json.dumps({
result = {
'Is a REST API bound to a single exchange format like JSON? How can multiple formats be used? (1 Point)':
'',
'Are all operations on this REST APIs idempotent? Explain why! (1 Point)':
......@@ -83,7 +83,13 @@ def get_answers():
'Please write down your matriculation number at top of this file.',
'Please add a comment at top of this file how much time you needed for this assignment (please be honest).',
]
})
}
for key in result:
if key != 'Hand in requirements (1 Point)':
result[key] = '[Solution hidden] Hey, what are you searching? A solution? Tzz. ;)'
return json.dumps(result), 200
# TODO implement missing routes
......
......@@ -4,3 +4,8 @@ DATABASE = {
}
COOKIE_AES_KEY = 'CHANGEME'
SENTRY_CONFIG = {
'dsn': 'https://8324787878372834872@sentry.marschke.me/6',
'environment': 'development',
}
......@@ -4,7 +4,7 @@ info:
version: "1.0.0"
title: "Flask Training API"
contact:
email: "leonard@marschke.me"
email: "www-coding@lists.myhpi.de"
servers:
- url: "https://someserver/v1"
......@@ -52,7 +52,7 @@ paths:
description: Number of images to skip
responses:
200:
description: Mail content
description: List of images
content:
application/json:
schema:
......@@ -78,7 +78,7 @@ paths:
- $ref: '#/components/parameters/ImageId'
responses:
200:
description: Mail metadata
description: Image metadata
content:
application/json:
schema:
......@@ -93,12 +93,12 @@ paths:
/images/{imageId}/bitmap:
get:
summary: Get bitmap of image
summary: Get bitmap of image (the API will need to load the image from the backend URL and pass it on to the client). Mime headers will be set accordingly when the image is sent to the client, so any browser should be able to display the image directly.
parameters:
- $ref: '#/components/parameters/ImageId'
responses:
200:
description: Bitmap
description: bitmap
content:
image:
schema:
......@@ -116,7 +116,7 @@ paths:
description: Should fetch images from https://image-annotations.marschke.me/NAACL/. Operation must be idempotent.
responses:
200:
description: Mail successfully saved
description: Images successfully saved
content:
application/json:
schema:
......
......@@ -3,3 +3,4 @@ module = main
callable = flask
need-app = True
wsgi-disable-file-wrapper = true
enable-threads = True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment