Skip to content

Commit

Permalink
chore: run black code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakirG committed Mar 11, 2019
1 parent fa93051 commit 208693b
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 227 deletions.
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# To run: docker run -v /path/to/wsgi.py:/var/www/manifestservice/wsgi.py --name=manifestservice -p 81:80 manifestservice
# To check running container: docker exec -it manifestservice /bin/bash


FROM quay.io/cdis/python-nginx:master

RUN echo "7" && ls
ENV appname=manifestservice

# number of uwsgi worker processes
Expand All @@ -16,32 +14,30 @@ RUN apk update \
&& apk add postgresql-libs postgresql-dev libffi-dev libressl-dev \
&& apk add linux-headers musl-dev gcc \
&& apk add curl bash git vim
RUN echo "17" && ls

COPY . /$appname
COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini
COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py
COPY ./deployment/nginx/nginx.conf /etc/nginx/
COPY ./deployment/nginx/uwsgi.conf /etc/nginx/conf.d/nginx.conf
WORKDIR /$appname
RUN echo "24" && ls

RUN python -m pip install --upgrade pip && pip install pipenv && pipenv install

RUN echo "26" && ls
RUN mkdir -p /var/www/$appname \
&& mkdir -p /var/www/.cache/Python-Eggs/ \
&& mkdir /run/nginx/ \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& chown nginx -R /var/www/.cache/Python-Eggs/ \
&& chown nginx /var/www/$appname
RUN echo "34" && ls

EXPOSE 80
RUN echo "36"

RUN COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" >$appname/version_data.py \
&& VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >>$appname/version_data.py \
&& python setup.py install

WORKDIR /var/www/$appname
RUN echo "42" && ls

CMD /$appname/dockerrun.bash
19 changes: 0 additions & 19 deletions deployment/uwsgi/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,10 @@ vacuum = true
chdir = /manifestservice/
uid = nginx
gid = nginx
# pythonpath = /usr/local/lib/site-packages/
virtualenv = $(VENV)
pythonpath = /usr/local/lib/python3.6/site-packages/


# [uwsgi]
# protocol = uwsgi
# socket = /var/www/wts/uwsgi.sock
# buffer-size = 32768
# chmod-socket = 666
# master = true
# harakiri-verbose = 20
# disable-logging = true
# wsgi-file=/wts/wsgi.py
# plugins = python3
# vacuum = true
# chdir = /wts/
# uid = nginx
# gid = nginx
# virtualenv = $(VENV)
# pythonpath = /usr/local/lib/python3.6/site-packages/


# Use this to initialize application in worker processes, not master. This
# prevents the workers from all trying to open the same database
# connections at startup:
Expand Down
1 change: 1 addition & 0 deletions deployment/uwsgi/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from manifestservice.api import app

application = app
39 changes: 26 additions & 13 deletions manifestservice/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import json


def create_app():
app = flask.Flask(__name__)
app.register_blueprint(manifests_bp, url_prefix="")
Expand All @@ -19,30 +20,42 @@ def create_app():
config_dict = json.loads(config_str)
except Exception as e:
print(e)
raise ValueError("Unable to parse the provided config file at {}".format(config_path))

raise ValueError(
"Unable to parse the provided config file at {}".format(config_path)
)

for key in config_dict:
app.config[key] = config_dict[key]

app.config['OIDC_ISSUER'] = 'https://%s/user' % config_dict['hostname']
app.config['MANIFEST_BUCKET_NAME'] = config_dict['manifest_bucket_name']
app.config["OIDC_ISSUER"] = "https://%s/user" % config_dict["hostname"]
app.config["MANIFEST_BUCKET_NAME"] = config_dict["manifest_bucket_name"]

app.config['AWS_ACCESS_KEY_ID'] = config_dict['aws_access_key_id'].strip()
app.config['AWS_SECRET_ACCESS_KEY'] = config_dict['aws_secret_access_key'].strip()
app.config["AWS_ACCESS_KEY_ID"] = config_dict["aws_access_key_id"].strip()
app.config["AWS_SECRET_ACCESS_KEY"] = config_dict["aws_secret_access_key"].strip()

os.environ['AWS_ACCESS_KEY_ID'] = config_dict['aws_access_key_id'].strip()
os.environ['AWS_SECRET_ACCESS_KEY'] = config_dict['aws_secret_access_key'].strip()
os.environ["AWS_ACCESS_KEY_ID"] = config_dict["aws_access_key_id"].strip()
os.environ["AWS_SECRET_ACCESS_KEY"] = config_dict["aws_secret_access_key"].strip()

required_config_variables = ['AWS_SECRET_ACCESS_KEY', 'AWS_ACCESS_KEY_ID', 'OIDC_ISSUER', 'MANIFEST_BUCKET_NAME']
required_config_variables = [
"AWS_SECRET_ACCESS_KEY",
"AWS_ACCESS_KEY_ID",
"OIDC_ISSUER",
"MANIFEST_BUCKET_NAME",
]
if not set(required_config_variables).issubset(set(app.config.keys())):
raise ValueError("Not all required config variables were provided in {}. Missing: {}".format(config_path, str(
set(required_config_variables).difference(set(app.config.keys()))))
raise ValueError(
"Not all required config variables were provided in {}. Missing: {}".format(
config_path,
str(set(required_config_variables).difference(set(app.config.keys()))),
)
)

return app


app = create_app()


@app.route("/_status", methods=["GET"])
def health_check():
"""
Expand All @@ -61,5 +74,5 @@ def health_check():

def run_for_development(**kwargs):
app.logger.setLevel(logging.INFO)
app.run(**kwargs)

app.run(**kwargs)
3 changes: 0 additions & 3 deletions manifestservice/dev_settings.py

This file was deleted.

Loading

0 comments on commit 208693b

Please sign in to comment.