diff --git a/backend/Dockerfile b/backend/Dockerfile index 36e3c0f2..a7a0de05 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,6 +2,7 @@ from golang as builder # Add files RUN mkdir /app +RUN mkdir /app_sdk WORKDIR /app ADD ./go-app/main.go /app ADD ./go-app/walkoff.go /app @@ -14,13 +15,21 @@ RUN go get -v RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o webapp . -# Certificate build +# Certificate build - gets required certs FROM alpine:latest as certs RUN apk --update add ca-certificates from scratch -COPY --from=builder /app/ / +RUN mkdir /app +RUN mkdir /app_sdk + +# Required files for code generation +ADD ./app_sdk/app_sdk.py /app_sdk +ADD ./app_sdk/static_baseline.py /app_sdk + +COPY --from=builder /app/ /app COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +WORKDIR /app EXPOSE 5001 CMD ["./webapp"] diff --git a/backend/app_sdk/Dockerfile b/backend/app_sdk/Dockerfile new file mode 100644 index 00000000..44294a5b --- /dev/null +++ b/backend/app_sdk/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.7-alpine as base + +FROM base as builder +RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-dev + +RUN mkdir /install +WORKDIR /install + +COPY requirements.txt /requirements.txt +RUN pip install --prefix="/install" -r /requirements.txt + +FROM base + +COPY --from=builder /install /usr/local +COPY __init__.py /app/walkoff_app_sdk/__init__.py +COPY app_base.py /app/walkoff_app_sdk/app_base.py diff --git a/functions/onprem/app_sdk/LICENSE b/backend/app_sdk/LICENSE similarity index 100% rename from functions/onprem/app_sdk/LICENSE rename to backend/app_sdk/LICENSE diff --git a/backend/app_sdk/README.md b/backend/app_sdk/README.md new file mode 100644 index 00000000..754392ff --- /dev/null +++ b/backend/app_sdk/README.md @@ -0,0 +1,16 @@ +# app_sdk.py +This is the SDK used for apps to behave like they should. +To change it in the backend, upload it to Buckets/shuffler.appspot.com/generated_apps/baseline. + +# static_baseline.py +It's used for python code generation and should be under MIT. Has to be located here because it's used by the backend. + +## If you want to update apps.. PS: downloads from docker hub do overrides.. :) +1. Write your code & check if runtime works +2. Build app_base image +3. docker rm $(docker ps -aq) # Remove all stopped containers +4. Delete the specific app's Docker image (docker rmi frikky/shuffle:...) +5. Rebuild the Docker image (click load in GUI?) + +# LICENSE +Everything in here is MIT, not AGPLv3 as indicated by the license. diff --git a/backend/app_sdk/__init__.py b/backend/app_sdk/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functions/onprem/app_sdk/app_base.py b/backend/app_sdk/app_base.py similarity index 100% rename from functions/onprem/app_sdk/app_base.py rename to backend/app_sdk/app_base.py diff --git a/backend/app_sdk/build.sh b/backend/app_sdk/build.sh new file mode 100644 index 00000000..c93c83fc --- /dev/null +++ b/backend/app_sdk/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker rmi frikky/shuffle:app_sdk +docker build . -t frikky/shuffle:app_sdk --no-cache +docker push frikky/shuffle:app_sdk diff --git a/backend/app_sdk/readme b/backend/app_sdk/readme new file mode 100644 index 00000000..4a01094d --- /dev/null +++ b/backend/app_sdk/readme @@ -0,0 +1,8 @@ +# App_sdk +App_sdk development is continued here: https://github.com/frikky/Shuffle-apps/tree/master/app_sdk + +# Added static:baseline.py +It's used for python code generation and should be under MIT. + +# LICENSE +Everything in this folder is MIT, not AGPLv3 diff --git a/backend/app_sdk/requirements.txt b/backend/app_sdk/requirements.txt new file mode 100644 index 00000000..804abb1b --- /dev/null +++ b/backend/app_sdk/requirements.txt @@ -0,0 +1,2 @@ +requests +urllib3 diff --git a/functions/static_baseline.py b/backend/app_sdk/static_baseline.py similarity index 100% rename from functions/static_baseline.py rename to backend/app_sdk/static_baseline.py diff --git a/backend/go-app/codegen.go b/backend/go-app/codegen.go index 889c20e7..29c06917 100644 --- a/backend/go-app/codegen.go +++ b/backend/go-app/codegen.go @@ -122,8 +122,8 @@ func streamZipdata(ctx context.Context, identifier, pythoncode, requirements str func getAppbase() ([]byte, []byte, error) { // 1. Have baseline in bucket/generated_apps/baseline // 2. Copy the baseline to a new folder with identifier name - static := "../../functions/static_baseline.py" - appbase := "../../functions/onprem/app_sdk/app_base.py" + static := "../app_sdk/static_baseline.py" + appbase := "../app_sdk/app_base.py" staticData, err := ioutil.ReadFile(static) if err != nil { diff --git a/functions/README.md b/functions/README.md index 76682e26..b953b6c0 100644 --- a/functions/README.md +++ b/functions/README.md @@ -17,3 +17,6 @@ The point of this folder is to make GCP Cloud functions able to run default WALK * class AppBase * class * Runner + +## Update may 2020: +Moved static_baseline to ./onprem/app_sdk because of license. diff --git a/functions/onprem/app_sdk/readme b/functions/onprem/app_sdk/readme deleted file mode 100644 index 873d45d3..00000000 --- a/functions/onprem/app_sdk/readme +++ /dev/null @@ -1,4 +0,0 @@ -# App_sdk -App_sdk development is continued here: https://github.com/frikky/Shuffle-apps/tree/master/app_sdk - -It's under MIT license, NOT AGPLv3.