From e028e9af99f11669ed83d572f9898cb1ac3ce004 Mon Sep 17 00:00:00 2001 From: frikky Date: Wed, 8 Sep 2021 01:09:57 +0200 Subject: [PATCH] Made SDK have more included libraries, and made App Builder MUCH faster --- backend/app_gen/openapi/baseline/Dockerfile | 25 ++++++++++++--------- backend/app_sdk/Dockerfile | 4 +++- backend/app_sdk/app_base.py | 19 +++++++++++++--- backend/go-app/go.mod | 2 +- functions/onprem/worker/build.sh | 2 +- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/backend/app_gen/openapi/baseline/Dockerfile b/backend/app_gen/openapi/baseline/Dockerfile index 740fee62..8512e833 100644 --- a/backend/app_gen/openapi/baseline/Dockerfile +++ b/backend/app_gen/openapi/baseline/Dockerfile @@ -2,24 +2,27 @@ FROM frikky/shuffle:app_sdk as base # We're going to stage away all of the bloat from the build tools so lets create a builder stage -FROM base as builder +#FROM base as builder # Install all alpine build tools needed for our pip installs -RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-dev +#RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-dev # Install all of our pip packages in a single directory that we can copy to our base image later -RUN mkdir /install -WORKDIR /install -COPY requirements.txt /requirements.txt -RUN pip install --prefix="/install" -r /requirements.txt +#RUN mkdir /install +#WORKDIR /install +#COPY requirements.txt /requirements.txt +# +## Switch back to our base image and copy in all of our built packages and source code +#FROM base +#COPY --from=builder /install /usr/local -# Switch back to our base image and copy in all of our built packages and source code -FROM base -COPY --from=builder /install /usr/local -COPY src /app # Install any binary dependencies needed in our final image - this can be a lot of different stuff -RUN apk --no-cache add --update libmagic +#RUN apk --no-cache add --update libmagic +WORKDIR / +COPY requirements.txt /requirements.txt +RUN pip install --prefix="/usr/local" -r /requirements.txt +COPY src /app # Finally, lets run our app! WORKDIR /app diff --git a/backend/app_sdk/Dockerfile b/backend/app_sdk/Dockerfile index 84f4f950..b2febec6 100644 --- a/backend/app_sdk/Dockerfile +++ b/backend/app_sdk/Dockerfile @@ -8,7 +8,9 @@ WORKDIR /install FROM base -RUN apk update && apk add --no-cache tzdata +#--no-cache +RUN apk update && apk add --update tzdata libmagic alpine-sdk libffi libffi-dev musl-dev openssl-dev + COPY --from=builder /install /usr/local COPY requirements.txt /requirements.txt RUN pip3 install -r /requirements.txt diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 7b90b818..022e0e5c 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -2113,9 +2113,12 @@ class AppBase: print("Deleting %s because key = value" % key) deletekeys.append(key) continue - + for deletekey in deletekeys: - del newvalue[deletekey] + try: + del newvalue[deletekey] + except: + pass #print("Post delete: %s" % newvalue) for key, value in newvalue.items(): @@ -2128,8 +2131,16 @@ class AppBase: except json.decoder.JSONDecodeError as e: print("Inner overwrite issue: %s" % e) continue + except: + print("General error in newvalue items loop") + continue - action["parameters"][counter]["value"] = json.dumps(newvalue) + try: + action["parameters"][counter]["value"] = json.dumps(newvalue) + except json.decoder.JSONDecodeError as e: + print("[WARNING] JsonDecodeError: %s" % e) + action["parameters"][counter]["value"] = newvalue + except json.decoder.JSONDecodeError as e: print("Failed JSON replacement for OpenAPI keys (2) {e}") @@ -2137,6 +2148,7 @@ class AppBase: break #print(action["parameters"]) + print("Pre parameters") for parameter in newparams: action["parameters"].append(parameter) @@ -2150,6 +2162,7 @@ class AppBase: # Multi_parameter has the data for each. variable minlength = 0 + print("Pre-loading parameters") multi_parameters = json.loads(json.dumps(params)) multiexecution = False multi_execution_lists = [] diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index c0296204..630b5b0c 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -2,7 +2,7 @@ module shuffle go 1.13 -//replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared +replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi diff --git a/functions/onprem/worker/build.sh b/functions/onprem/worker/build.sh index 2dbd7f04..5119977c 100644 --- a/functions/onprem/worker/build.sh +++ b/functions/onprem/worker/build.sh @@ -1,5 +1,5 @@ NAME=shuffle-worker -VERSION=0.9.14 +VERSION=0.9.15 echo "Running docker build with $NAME:$VERSION" #CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o worker.bin .