Commit d7f3b583 authored by Stenio Araujo's avatar Stenio Araujo
Browse files

Add HTTPS

parent 15d79b66
......@@ -116,3 +116,8 @@ venv.bak/
# End of https://www.gitignore.io/api/python,visualstudiocode
# certificates
key.pem
cert.pem
*.swp
......@@ -11,8 +11,8 @@ RUN mkdir /app
WORKDIR /app
COPY app.py /app
COPY run.sh /app
EXPOSE 8080
CMD ["python", "app.py"]
ENTRYPOINT ["sh", "run.sh"]
......@@ -326,23 +326,13 @@ def _get(url):
return requests.get(url, headers=headers).json()
if __name__ == "__main__":
envs = {
"ALLOWED_CHANNELS_IDS": ALLOWED_CHANNELS_IDS,
"GITLAB_PERSONAL_TOKEN": GITLAB_PERSONAL_TOKEN,
"SECRET_ACCESS_KEY": SECRET_ACCESS_KEY,
"SLACK_SIGNING_SECRET": SLACK_SIGNING_SECRET
}
if not all(envs.values()):
msg = ("All the Environment Variables %s are needed, "
"define them before starting the app." % envs.keys())
raise Exception(msg)
listen_ip, listen_port = "0.0.0.0", "8080"
if len(sys.argv) > 1:
if ':' in sys.argv[1]:
listen_ip, listen_port = sys.argv[1].strip().split(':')
else:
listen_port = sys.argv[1]
app.run(debug=True, use_reloader=True, host=listen_ip, port=listen_port)
envs = {
"ALLOWED_CHANNELS_IDS": ALLOWED_CHANNELS_IDS,
"GITLAB_PERSONAL_TOKEN": GITLAB_PERSONAL_TOKEN,
"SECRET_ACCESS_KEY": SECRET_ACCESS_KEY,
"SLACK_SIGNING_SECRET": SLACK_SIGNING_SECRET
}
if not all(envs.values()):
msg = ("All the Environment Variables %s are needed, "
"define them before starting the app." % envs.keys())
raise Exception(msg)
......@@ -4,10 +4,10 @@ services:
container_name: "merges-issues-slash"
image: merges-issues-slash
environment:
- ALLOWED_CHANNELS_IDS=""
- GITLAB_PERSONAL_TOKEN=""
- SECRET_ACCESS_KEY=""
- SLACK_SIGNING_SECRET=""
- ALLOWED_CHANNELS_IDS
- GITLAB_PERSONAL_TOKEN
- SECRET_ACCESS_KEY
- SLACK_SIGNING_SECRET
ports:
- "8082:8080"
restart: always
#!/bin/sh
if [ -z "$HTTPS_CERT" ] || [ -z "$HTTPS_KEY" ]; then
export HTTPS_CERT=$(pwd)/cert.pem
export HTTPS_KEY=$(pwd)/key.pem
if [ -e $HTTPS_CERT ] || [ -e $HTTPS_KEY ]; then
echo "There is a key or cert in the directory already, please remove it before generating a new one"
echo "Skiping self signed certificate generation"
else
openssl req -x509 -newkey rsa:4096 -keyout $HTTPS_KEY -out $HTTPS_CERT -days 365 -subj "/C=BR/ST=Paraiba/L=Campina Grande/O=Stenio Araujo/OU=Stenio/CN=merge-issues-slash.duckdns.org" -nodes
fi
ls -l $HTTPS_CERT $HTTPS_KEY
fi
export FLASK_APP=$(pwd)/app.py
flask run --cert $HTTPS_CERT --key $HTTPS_KEY --host 0.0.0.0 --port 8080 --debugger
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