Skip to content

Commit

Permalink
Merge pull request #88 from fescobar/beta
Browse files Browse the repository at this point in the history
 #87 - Deployment Improvements
  • Loading branch information
fescobar authored Jun 15, 2020
2 parents 270ab86 + 69fe5aa commit b7611ed
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 37 deletions.
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Table of contents
* [Updating seconds to check Allure Results](#updating-seconds-to-check-allure-results)
* [Keep History and Trends](#keep-history-and-trends)
* [Override User Container](#override-user-container)
* [Start in DEV Mode](#start-in-dev-mode)
* [Export Native Full Report](#export-native-full-report)
* [Customize Emailable Report](#customize-emailable-report)
* [Override CSS](#override-css)
Expand Down Expand Up @@ -240,14 +241,14 @@ With this option you could generate multiple reports for multiple projects, you

##### Multiple Project - Docker on Unix/Mac
```sh
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY="TRUE" \
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=NONE -e KEEP_HISTORY="TRUE" \
-v ${PWD}/projects:/app/projects \
frankescobar/allure-docker-service
```

##### Multiple Project - Docker on Windows (Git Bash)
```sh
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY="TRUE" \
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=NONE -e KEEP_HISTORY="TRUE" \
-v "/$(pwd)/projects:/app/projects" \
frankescobar/allure-docker-service
```
Expand All @@ -261,7 +262,7 @@ services:
allure:
image: "frankescobar/allure-docker-service"
environment:
CHECK_RESULTS_EVERY_SECONDS: 1
CHECK_RESULTS_EVERY_SECONDS: NONE
KEEP_HISTORY: "TRUE"
KEEP_HISTORY_LATEST: 25
ports:
Expand Down Expand Up @@ -398,26 +399,21 @@ allure_1 | Overriding configuration
allure_1 | Checking Allure Results every 1 second/s
allure_1 | Creating executor.json for PROJECT_ID: default
allure_1 | Generating report for PROJECT_ID: default
allure_1 | * Serving Flask app "app" (lazy loading)
allure_1 | * Environment: production
allure_1 | WARNING: This is a development server. Do not use it in a production deployment.
allure_1 | Use a production WSGI server instead.
allure_1 | * Debug mode: off
allure_1 | * Running on http://0.0.0.0:5050/ (Press CTRL+C to quit)
allure_1 | Detecting results changes for PROJECT_ID: default ...
allure_1 | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1 | Detecting results changes for PROJECT_ID: default
allure_1 | Automatic Execution in Progress for PROJECT_ID: default...
allure_1 | Creating history on results directory for PROJECT_ID: default ...
allure_1 | Copying history from previous results...
allure_1 | Status: 200
allure_1 | Creating executor.json for PROJECT_ID: default
allure_1 | Generating report for PROJECT_ID: default
allure_1 | Report successfully generated to allure-report
allure_1 | 127.0.0.1 - - [22/May/2020 17:30:16] "GET /emailable-report/render?project_id=default HTTP/1.1" 400 -
allure_1 | Retrying call http://localhost:5050/emailable-report/render?project_id=default in 2 seconds
allure_1 | 127.0.0.1 - - [22/May/2020 17:30:19] "GET /emailable-report/render?project_id=default HTTP/1.1" 400 -
allure_1 | Retrying call http://localhost:5050/emailable-report/render?project_id=default in 2 seconds
allure_1 | 127.0.0.1 - - [22/May/2020 17:30:21] "GET /emailable-report/render?project_id=default HTTP/1.1" 400 -
allure_1 | Retrying call http://localhost:5050/emailable-report/render?project_id=default in 2 seconds
allure_1 | Report successfully generated to allure-report
allure_1 | 127.0.0.1 - - [22/May/2020 17:30:21] "GET /emailable-report/render?project_id=default HTTP/1.1" 200 -
allure_1 | Starting web server...
allure_1 | 2020-06-15 10:20:06.000:INFO::main: Logging initialized @1518ms to org.eclipse.jetty.util.log.StdErrLog
allure_1 | Can not open browser because this capability is not supported on your platform. You can use the link below to open the report manually.
allure_1 | Server started at <http://192.168.208.2:4040/>. Press <Ctrl+C> to exit
allure_1 | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1 | Storing report history for PROJECT_ID: default
allure_1 | BUILD_ORDER:1
allure_1 | Status: 200
```

Expand Down Expand Up @@ -724,6 +720,19 @@ Note: It's not a good practice to use `root` user to manipulate containers.
Reference:
- https://snyk.io/blog/10-docker-image-security-best-practices/

#### Start in DEV Mode
`Available from Allure Docker Service version 2.13.3`

Enable dev mode, if you want to see the logs about api requests using the `DEV_MODE` environment variable.

Docker Compose example:
```sh
environment:
DEV_MODE: 1
```
NOTE:
- Don't use this mode for live/prod environments.
#### Export Native Full Report
`Available from Allure Docker Service version 2.13.1`
Expand Down
28 changes: 21 additions & 7 deletions allure-docker-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from flask_swagger_ui import get_swaggerui_blueprint
from subprocess import call
from werkzeug.utils import secure_filename
import os, uuid, glob, json, base64, zipfile, io, re, shutil, tempfile, subprocess
import waitress, os, uuid, glob, json, base64, zipfile, io, re, shutil, tempfile, subprocess

app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
Expand All @@ -21,7 +21,7 @@
DEFAULT_TEMPLATE = 'default.html'
CSS = "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cosmo/bootstrap.css"
TITLE = "Emailable Report"
API_RESPONSE_LESS_VERBOSE = ''
API_RESPONSE_LESS_VERBOSE = 0

if "EMAILABLE_REPORT_CSS_CDN" in os.environ:
app.logger.info('Overriding CSS')
Expand All @@ -32,7 +32,10 @@
TITLE = os.environ['EMAILABLE_REPORT_TITLE']

if "API_RESPONSE_LESS_VERBOSE" in os.environ:
API_RESPONSE_LESS_VERBOSE = os.environ['API_RESPONSE_LESS_VERBOSE']
try:
API_RESPONSE_LESS_VERBOSE = int(os.environ['API_RESPONSE_LESS_VERBOSE'])
except Exception as ex:
app.logger.error('Wrong env var value. Setting API_RESPONSE_LESS_VERBOSE by default')

### swagger specific ###
SWAGGER_URL = '/swagger'
Expand Down Expand Up @@ -218,7 +221,7 @@ def send_results():
if failedFilesCount > 0:
raise Exception('Problems with files: {}'.format(failedFiles))

if API_RESPONSE_LESS_VERBOSE != "1":
if API_RESPONSE_LESS_VERBOSE != 1:
files = os.listdir(results_project)
currentFilesCount = len(files)
sentFilesCount = len(validatedResults)
Expand All @@ -233,7 +236,7 @@ def send_results():
resp = jsonify(body)
resp.status_code = 400
else:
if API_RESPONSE_LESS_VERBOSE != "1":
if API_RESPONSE_LESS_VERBOSE != 1:
body = {
'data': {
'current_files': files,
Expand Down Expand Up @@ -278,7 +281,7 @@ def generate_report():
project_path=get_project_path(project_id)
results_project='{}/results'.format(project_path)

if API_RESPONSE_LESS_VERBOSE != "1":
if API_RESPONSE_LESS_VERBOSE != 1:
files = os.listdir(results_project)

execution_name = request.args.get('execution_name')
Expand Down Expand Up @@ -784,5 +787,16 @@ def check_process(process_file, project_id):
if proccount > 0:
raise Exception("Processing files for project_id '{}'. Try later!".format(project_id))

dev_mode = 0
if "DEV_MODE" in os.environ:
try:
dev_mode = int(os.environ['DEV_MODE'])
except Exception as ex:
app.logger.error('Wrong env var value. Setting DEV_MODE by default')

if __name__ == '__main__':
app.run(host='0.0.0.0', port=os.environ['PORT_API'])
if dev_mode == 1:
app.logger.info('Stating in DEV_MODE')
app.run(host='0.0.0.0', port=os.environ['PORT_API'])
else:
waitress.serve(app, threads=6, host='0.0.0.0', port=os.environ['PORT_API'], url_scheme='http')
15 changes: 8 additions & 7 deletions allure-docker-scripts/generateAllureReport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ EXECUTION_NAME=$4
EXECUTION_FROM=$5
EXECUTION_TYPE=$6

echo "Creating $EXECUTOR_FILENAME for PROJECT_ID: $PROJECT_ID"

PROJECT_LATEST_REPORT=$STATIC_CONTENT_PROJECTS/$PROJECT_ID/reports/latest
if [ -e $PROJECT_LATEST_REPORT ]; then
LAST_REPORT_PATH_DIRECTORY=$(ls -td $STATIC_CONTENT_PROJECTS/$PROJECT_ID/reports/* | grep -v latest | grep -v $EMAILABLE_REPORT_FILE_NAME | head -1)
else
LAST_REPORT_PATH_DIRECTORY=$(ls -td $STATIC_CONTENT_PROJECTS/$PROJECT_ID/reports/* | grep -v $EMAILABLE_REPORT_FILE_NAME | head -1)
PROJECT_REPORTS=$STATIC_CONTENT_PROJECTS/$PROJECT_ID/reports
if [ "$(ls $PROJECT_REPORTS | wc -l)" != "0" ]; then
if [ -e "$PROJECT_REPORTS/latest" ]; then
LAST_REPORT_PATH_DIRECTORY=$(ls -td $PROJECT_REPORTS/* | grep -v latest | grep -v $EMAILABLE_REPORT_FILE_NAME | head -1)
else
LAST_REPORT_PATH_DIRECTORY=$(ls -td $PROJECT_REPORTS/* | grep -v $EMAILABLE_REPORT_FILE_NAME | head -1)
fi
fi

LAST_REPORT_DIRECTORY=$(basename -- "$LAST_REPORT_PATH_DIRECTORY")
Expand All @@ -29,6 +29,7 @@ fi

EXECUTOR_PATH=$RESULTS_DIRECTORY/$EXECUTOR_FILENAME

echo "Creating $EXECUTOR_FILENAME for PROJECT_ID: $PROJECT_ID"
if [[ "$LAST_REPORT_DIRECTORY" != "latest" ]]; then
BUILD_ORDER=$(($LAST_REPORT_DIRECTORY + 1))

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
args:
RELEASE: "2.13.3"
environment:
DEV_MODE: 1
CHECK_RESULTS_EVERY_SECONDS: 5
KEEP_HISTORY: "TRUE"
KEEP_HISTORY_LATEST: 5
Expand Down
2 changes: 1 addition & 1 deletion docker-custom/Dockerfile.bionic-custom
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN apt-get update && \
unzip && \
ln -s `which python3` /usr/bin/python && \
pip3 install --upgrade pip && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 flask-swagger-ui==3.25.0 requests==2.23.0 && \
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
unzip -q /tmp/allure-commandline.zip -d / && \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN apt-get update && \
unzip && \
ln -s `which python3` /usr/bin/python && \
pip3 install --upgrade pip && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 flask-swagger-ui==3.25.0 requests==2.23.0 && \
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
unzip -q /tmp/allure-commandline.zip -d / && \
Expand Down
4 changes: 2 additions & 2 deletions docker/archive/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jdk-slim
FROM adoptopenjdk:11-jre-openj9-bionic
LABEL maintainer="fescobar.systems@gmail.com"

ARG RELEASE=NONE
Expand All @@ -18,7 +18,7 @@ RUN apt-get install python3-pip -y
RUN apt-get install unzip -y
RUN ln -s `which python3` /usr/bin/python
RUN pip3 install --upgrade pip
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4
RUN pip install -Iv Flask==1.1.2 flask-swagger-ui==3.25.0 requests==2.23.0
RUN apt-get install --reinstall procps -y
RUN apt-get install wget -y
Expand Down

0 comments on commit b7611ed

Please sign in to comment.