Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multiple upgrades #245

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
DOCKER_IMAGE: frankescobar/allure-docker-service
ALLURE_RELEASE: 2.21.0
ALLURE_RELEASE: 2.27.0
QEMU_VERSION: v4.0.0
DOCKER_CLI_EXPERIMENTAL: enabled

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ The following table shows the provided Manifest Lists.

| **Tag** | **allure-docker-service Base Image** |
|----------------------------------------|---------------------------------------------------|
| latest, 2.21.0 | frankescobar/allure-docker-service:2.21.0-amd64 |
| | frankescobar/allure-docker-service:2.21.0-arm32v7 |
| | frankescobar/allure-docker-service:2.21.0-arm64v8 |
| latest, 2.27.0 | frankescobar/allure-docker-service:2.27.0-amd64 |
| | frankescobar/allure-docker-service:2.27.0-arm32v7 |
| | frankescobar/allure-docker-service:2.27.0-arm64v8 |

## USAGE
### Generate Allure Results
Expand Down Expand Up @@ -722,7 +722,7 @@ You can switch the version container using `frankescobar/allure-docker-service:$
Docker Compose example:
```sh
allure:
image: "frankescobar/allure-docker-service:2.21.0"
image: "frankescobar/allure-docker-service:2.27.0"
```
or using latest version:

Expand Down Expand Up @@ -1395,7 +1395,7 @@ docker-compose -f docker-compose-dev.yml up --build
```
### Build image
```sh
docker build -t allure-release -f docker-custom/Dockerfile.bionic-custom --build-arg ALLURE_RELEASE=2.21.0 .
docker build -t allure-release -f docker-custom/Dockerfile.bionic-custom --build-arg ALLURE_RELEASE=2.27.0 .
```
### Run container
```sh
Expand Down Expand Up @@ -1446,5 +1446,5 @@ docker run -d -p 5050:5050 frankescobar/allure-docker-service
```
### Download specific tagged image registered (Example)
```sh
docker run -d -p 5050:5050 frankescobar/allure-docker-service:2.21.0
docker run -d -p 5050:5050 frankescobar/allure-docker-service:2.27.0
```
43 changes: 22 additions & 21 deletions allure-docker-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from flask_swagger_ui import get_swaggerui_blueprint
from flask_jwt_extended import (
JWTManager, jwt_required, create_access_token, create_refresh_token, current_user,
get_jwt_identity, verify_jwt_in_request, jwt_refresh_token_required, get_raw_jwt,
set_access_cookies, set_refresh_cookies, unset_jwt_cookies, verify_jwt_refresh_token_in_request
get_jwt_identity, verify_jwt_in_request, get_jwt,
set_access_cookies, set_refresh_cookies, unset_jwt_cookies
)

dictConfig({
Expand Down Expand Up @@ -151,7 +151,7 @@ def __str__(self):
REPORT_INDEX_FILE = 'index.html'
DEFAULT_TEMPLATE = 'default.html'
LANGUAGE_TEMPLATE = 'select_language.html'
LANGUAGES = ["en", "ru", "zh", "de", "nl", "he", "br", "pl", "ja", "es", "kr", "fr"]
LANGUAGES = ["en", "ru", "zh", "de", "nl", "he", "br", "pl", "ja", "es", "kr", "fr", "az"]
GLOBAL_CSS = "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cosmo/bootstrap.css"
EMAILABLE_REPORT_CSS = GLOBAL_CSS
EMAILABLE_REPORT_TITLE = "Emailable Report"
Expand Down Expand Up @@ -440,10 +440,10 @@ def generate_security_swagger_spec():
'app_name': "Allure Docker Service"
}
)
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix="/")
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=NATIVE_PREFIX)
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_ENDPOINT)
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_ENDPOINT_PATH)
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="main", url_prefix="/")
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="native", url_prefix=NATIVE_PREFIX)
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="swagger", url_prefix=SWAGGER_ENDPOINT)
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="swagger_path", url_prefix=SWAGGER_ENDPOINT_PATH)
if URL_PREFIX:
app.register_blueprint(SWAGGERUI_BLUEPRINT,
url_prefix='{}{}'.format(NATIVE_PREFIX, SWAGGER_ENDPOINT))
Expand All @@ -456,9 +456,9 @@ def generate_security_swagger_spec():
blacklist = set() #pylint: disable=invalid-name
jwt = JWTManager(app) #pylint: disable=invalid-name

@jwt.token_in_blacklist_loader
def check_if_token_in_blacklist(decrypted_token):
jti = decrypted_token['jti']
@jwt.token_in_blocklist_loader
def check_if_token_in_blacklist(jwt_header, jwt_data):
jti = jwt_data['jti']
return jti in blacklist

@jwt.invalid_token_loader
Expand All @@ -478,8 +478,8 @@ def unauthorized_loader(msg):
}), 401

@jwt.expired_token_loader
def my_expired_token_callback(expired_token):
token_type = expired_token['type']
def my_expired_token_callback(jwt_headers, jwt_payload):
token_type = jwt_payload['type']
return jsonify({
'meta_data': {
'message': 'The {} token has expired'.format(token_type),
Expand All @@ -488,7 +488,7 @@ def my_expired_token_callback(expired_token):
}), 401

@jwt.revoked_token_loader
def revoked_token_loader():
def revoked_token_loader(jwt_header, jwt_payload):
return jsonify({
'meta_data': {
'message': 'Revoked Token'
Expand All @@ -500,7 +500,7 @@ def jwt_required(fn): #pylint: disable=invalid-name, function-redefined
def wrapper(*args, **kwargs):
if ENABLE_SECURITY_LOGIN:
if is_endpoint_protected(request.endpoint):
verify_jwt_in_request()
verify_jwt_in_request(refresh=False)
return fn(*args, **kwargs)
return wrapper

Expand All @@ -509,12 +509,13 @@ def jwt_refresh_token_required(fn): #pylint: disable=invalid-name, function-rede
def wrapper(*args, **kwargs):
if ENABLE_SECURITY_LOGIN:
if is_endpoint_protected(request.endpoint):
verify_jwt_refresh_token_in_request()
verify_jwt_in_request(refresh=True)
return fn(*args, **kwargs)
return wrapper

@jwt.user_loader_callback_loader
def user_loader_callback(identity):
@jwt.user_lookup_loader
def user_loader_callback(jwt_header, jwt_data):
identity = jwt_data['sub']
if identity not in USERS_INFO:
return None
return UserAccess(
Expand Down Expand Up @@ -619,7 +620,7 @@ def logout_endpoint():
resp = jsonify(body)
return resp, 404
try:
jti = get_raw_jwt()['jti']
jti = get_jwt()['jti']
blacklist.add(jti)
return jsonify({'meta_data': {'message' : 'Successfully logged out'}}), 200
except Exception as ex:
Expand All @@ -644,7 +645,7 @@ def logout_refresh_token_endpoint():
resp = jsonify(body)
return resp, 404
try:
jti = get_raw_jwt()['jti']
jti = get_jwt()['jti']
blacklist.add(jti)
resp = jsonify({'meta_data': {'message' : 'Successfully logged out'}})
unset_jwt_cookies(resp)
Expand Down Expand Up @@ -835,7 +836,7 @@ def latest_report_endpoint():
resp.status_code = 404
return resp

project_report_latest_path = '/latest/{}'.format(REPORT_INDEX_FILE)
project_report_latest_path = 'latest/{}'.format(REPORT_INDEX_FILE)
url = url_for('get_reports_endpoint', project_id=project_id,
path=project_report_latest_path, redirect='false', _external=True)
return redirect(url)
Expand Down Expand Up @@ -1257,7 +1258,7 @@ def report_export_endpoint():
data,
mimetype='application/zip',
as_attachment=True,
attachment_filename='allure-docker-service-report.zip'
download_name='allure-docker-service-report.zip'
)
except Exception as ex:
body = {
Expand Down
2 changes: 1 addition & 1 deletion allure-docker-scripts/cleanAllureHistory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ "$(ls -A $PROJECT_LATEST_REPORT | wc -l)" != "0" ]; then
fi

if [ "$(ls -A $PROJECT_REPORTS_DIRECTORY | wc -l)" != "0" ]; then
ls -d $PROJECT_REPORTS_DIRECTORY/* | grep -v latest | grep -wv 0 | xargs rm 2 -rf> /dev/null
ls -d $PROJECT_REPORTS_DIRECTORY/* | grep -wv $PROJECT_REPORTS_DIRECTORY/latest | grep -wv 0 | xargs rm 2 -rf> /dev/null
fi

if [ -e $PROJECT_RESULTS_HISTORY ]; then
Expand Down
2 changes: 1 addition & 1 deletion allure-docker-scripts/generateAllureReport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ EXECUTION_TYPE=$6
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)
LAST_REPORT_PATH_DIRECTORY=$(ls -td $PROJECT_REPORTS/* | grep -wv $PROJECT_REPORTS/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
Expand Down
4 changes: 2 additions & 2 deletions allure-docker-scripts/keepAllureLatestHistory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if [ "$KEEP_HISTORY" == "TRUE" ] || [ "$KEEP_HISTORY" == "true" ] || [ "$KEEP_HI
if echo $KEEP_HISTORY_LATEST | egrep -q '^[0-9]+$'; then
KEEP_LATEST=$KEEP_HISTORY_LATEST
fi
CURRENT_SIZE=$(ls -Ad $PROJECT_REPORTS_DIRECTORY/* | grep -v latest | grep -wv 0 | grep -v $EMAILABLE_REPORT_FILE_NAME | wc -l)
CURRENT_SIZE=$(ls -Ad $PROJECT_REPORTS_DIRECTORY/* | grep -wv $PROJECT_REPORTS_DIRECTORY/latest | grep -wv 0 | grep -v $EMAILABLE_REPORT_FILE_NAME | wc -l)

if [ "$CURRENT_SIZE" -gt "$KEEP_LATEST" ]; then
SIZE_TO_REMOVE="$(($CURRENT_SIZE-$KEEP_LATEST))"
echo "Keeping latest $KEEP_LATEST history reports for PROJECT_ID: $PROJECT_ID"
ls -tAd $PROJECT_REPORTS_DIRECTORY/* | grep -v latest | grep -wv 0 | grep -v $EMAILABLE_REPORT_FILE_NAME | tail -$SIZE_TO_REMOVE | xargs rm 2 -rf> /dev/null
ls -tAd $PROJECT_REPORTS_DIRECTORY/* | grep -wv $PROJECT_REPORTS_DIRECTORY/latest | grep -wv 0 | grep -v $EMAILABLE_REPORT_FILE_NAME | tail -$SIZE_TO_REMOVE | xargs rm 2 -rf> /dev/null
fi
fi
2 changes: 1 addition & 1 deletion allure-docker-scripts/runAllureApp.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
python $ROOT/allure-docker-api/app.py
python${PYTHON_VERSION} $ROOT/allure-docker-api/app.py
2 changes: 1 addition & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
context: ../allure-docker-service
dockerfile: docker-custom/Dockerfile.bionic-custom
args:
ALLURE_RELEASE: "2.21.0"
ALLURE_RELEASE: "2.27.0"
environment:
DEV_MODE: 0
CHECK_RESULTS_EVERY_SECONDS: NONE
Expand Down
23 changes: 14 additions & 9 deletions docker-custom/Dockerfile.bionic-custom
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
ARG ARCH=amd64
ARG JDK=adoptopenjdk:11-jre-openj9-bionic
ARG BUILD_DATE
ARG BUILD_VERSION=2.21.0-custom
ARG BUILD_VERSION=2.27.0-custom
ARG BUILD_REF=na
ARG ALLURE_RELEASE=2.21.0
ARG ALLURE_RELEASE=2.27.0
ARG ALLURE_REPO=https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
ARG UID=1000
ARG GID=1000
ARG PYTHON_VERSION=3.8

######

FROM python:3.6-alpine AS dev_stage
FROM python:${PYTHON_VERSION}-alpine AS dev_stage
RUN apk update
RUN apk add build-base
RUN pip install -U pylint
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.24.1 flask-swagger-ui==3.36.0 requests==2.23.0
RUN pip install --upgrade pip setuptools wheel waitress && \
pip install -Iv Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0

ENV ROOT_DIR=/code
RUN mkdir -p $ROOT_DIR
Expand All @@ -34,6 +35,7 @@ ARG ALLURE_RELEASE
ARG ALLURE_REPO
ARG UID
ARG GID
ARG PYTHON_VERSION=3.8

LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.docker.dockerfile="docker-custom/Dockerfile.bionic-custom" \
Expand All @@ -47,18 +49,20 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.vcs-url="https://github.com/fescobar/allure-docker-service" \
org.label-schema.arch=${ARCH} \
authors="Frank Escobar <[email protected]>, Raymond Mouthaan <[email protected]>"

RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends \
tzdata \
nano \
python3 \
python${PYTHON_VERSION} \
python3-pip \
unzip && \
ln -s `which python3` /usr/bin/python && \
pip3 install --upgrade pip && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.25.0 flask-swagger-ui==3.36.0 requests==2.23.0 && \
python${PYTHON_VERSION} -m pip install --upgrade pip setuptools wheel waitress && \
python${PYTHON_VERSION} -m pip install -v Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0 && \
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
unzip -q /tmp/allure-commandline.zip -d / && \
apt-get remove -y unzip && \
Expand All @@ -70,6 +74,7 @@ RUN apt-get update && \
RUN groupadd --gid ${GID} allure \
&& useradd --uid ${UID} --gid allure --shell /bin/bash --create-home allure

ENV PYTHON_VERSION=${PYTHON_VERSION}
ENV ROOT=/app
ENV ALLURE_HOME=/allure-$ALLURE_RELEASE
ENV ALLURE_HOME_SL=/allure
Expand Down
18 changes: 12 additions & 6 deletions docker/Dockerfile.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ ARG ALLURE_REPO=https://repo.maven.apache.org/maven2/io/qameta/allure/allure-com
ARG QEMU_ARCH
ARG UID=1000
ARG GID=1000
ARG PYTHON_VERSION=3.8

######

FROM python:3.6-alpine AS dev_stage
FROM python:${PYTHON_VERSION}-alpine AS dev_stage
RUN apk update
RUN apk add build-base
RUN pip install -U pylint
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.24.1 flask-swagger-ui==3.36.0 requests==2.23.0
RUN pip install --upgrade pip setuptools wheel waitress && \
pip install -Iv Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0

ENV ROOT_DIR=/code
RUN mkdir -p $ROOT_DIR
Expand All @@ -36,6 +37,7 @@ ARG ALLURE_REPO
ARG QEMU_ARCH
ARG UID
ARG GID
ARG PYTHON_VERSION=3.8

LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.docker.dockerfile="docker/Dockerfile.bionic" \
Expand All @@ -54,17 +56,20 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \
COPY tmp/qemu-$QEMU_ARCH-static /usr/bin/qemu-$QEMU_ARCH-static

RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends \
tzdata \
nano \
python3 \
python${PYTHON_VERSION} \
python3-pip \
python3-dev \
unzip && \
ln -s `which python3` /usr/bin/python && \
pip3 install --upgrade pip && \
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.25.0 flask-swagger-ui==3.36.0 requests==2.23.0 && \
python${PYTHON_VERSION} -m pip install --upgrade pip setuptools wheel waitress && \
python${PYTHON_VERSION} -m pip install -v Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0 && \
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
unzip -q /tmp/allure-commandline.zip -d / && \
apt-get remove -y unzip && \
Expand All @@ -76,6 +81,7 @@ RUN apt-get update && \
RUN groupadd --gid ${GID} allure \
&& useradd --uid ${UID} --gid allure --shell /bin/bash --create-home allure

ENV PYTHON_VERSION=${PYTHON_VERSION}
ENV ROOT=/app
ENV ALLURE_HOME=/allure-$ALLURE_RELEASE
ENV ALLURE_HOME_SL=/allure
Expand Down
Loading