Commit 437f544e authored by Leonard Marschke's avatar Leonard Marschke 👾
Browse files

merge from reference repo

parent aec1ff47
Loading
Loading
Loading
Loading
Loading
+57 −2
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -3,3 +3,5 @@ FROM lmmdock/flask-webserver
COPY ./ /app

RUN pip3 install -r requirements.txt

RUN chown uwsgi:uwsgi /app
+2 −0
Original line number Diff line number Diff line
@@ -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)
+8 −2
Original line number Diff line number Diff line
@@ -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
+5 −0
Original line number Diff line number Diff line
@@ -4,3 +4,8 @@ DATABASE = {
}

COOKIE_AES_KEY = 'CHANGEME'

SENTRY_CONFIG = {
    'dsn': 'https://8324787878372834872@sentry.marschke.me/6',
    'environment': 'development',
}
Loading