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

#46 as a user i can deploy applications via deploy this application style listings #47

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
36 changes: 36 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"CONTAINER_HOSTING_SSH_SETUP_HANDLER_API_KEY"
)
DOKKU_WRAPPER_FULL_PATH = os.getenv("DOKKU_WRAPPER_FULL_PATH")
# Default port to 5000
# See https://dokku.com/docs~v0.15.5/networking/port-management/#:~:text=Applications%20not%20using-,EXPOSE,-Any%20application%20that

# See https://github.com/dokku/dokku-letsencrypt/pull/211

Expand Down Expand Up @@ -117,6 +119,7 @@ async def homepage(request):
state_django = f"{secrets.token_urlsafe(30)}---django"
state_flask = f"{secrets.token_urlsafe(30)}---flask"
state_expressFramework = f"{secrets.token_urlsafe(30)}---expressFramework"
state_flowise = f"{secrets.token_urlsafe(30)}---flowise"
# UNTRUSTED_REPO_INFO gets replaced by the users given git host, org name and repo name
state_existing_repo = f"{secrets.token_urlsafe(30)}---existing_repo-UNTRUSTED_GIT_HOST|UNTRUSTED_GIT_ORG_NAME|UNTRUSTED_GIT_REPO_NAME"

Expand All @@ -127,6 +130,8 @@ async def homepage(request):
github_authorize_url_django = f"{github_oauth_auth_url}client_id={client_id}&state={state_django}&scope=workflow%20repo%20user:email" # noqa: E501
github_authorize_url_flask = f"{github_oauth_auth_url}client_id={client_id}&state={state_flask}&scope=workflow%20repo%20user:email" # noqa: E501
github_authorize_url_expressFramework = f"{github_oauth_auth_url}client_id={client_id}&state={state_expressFramework}&scope=workflow%20repo%20user:email" # noqa: E501
github_authorize_url_flowise = f"{github_oauth_auth_url}client_id={client_id}&state={state_flowise}&scope=workflow%20repo%20user:email" # noqa: E501

github_authorize_url_existing_repo = f"{github_oauth_auth_url}client_id={client_id}&state={state_existing_repo}&scope=workflow%20repo%20user:email" # noqa: E501

return templates.TemplateResponse(
Expand All @@ -137,6 +142,7 @@ async def homepage(request):
"github_authorize_url_django": github_authorize_url_django,
"github_authorize_url_flask": github_authorize_url_flask,
"github_authorize_url_expressFramework": github_authorize_url_expressFramework,
"github_authorize_url_flowise": github_authorize_url_flowise,
"github_authorize_url_existing_repo": github_authorize_url_existing_repo,
"request": request,
},
Expand Down Expand Up @@ -595,6 +601,18 @@ def add_expressFramework_quickstart():
index.add([f"{BASE_PATH}tmp-cloned-repos/{APP_NAME}/src/Dockerfile"])
index.commit("Added express framework quickstart")

def add_flowise_quickstart():
# add framework quickstart files
shutil.copytree(
f"{BASE_PATH}/repo-template-files/quickstarts/applications/flowise-quickstart/src",
f"./tmp-cloned-repos/{APP_NAME}/src",
dirs_exist_ok=True,
)
# add/commit framework files to repo
index = repo.index
index.add([f"{BASE_PATH}tmp-cloned-repos/{APP_NAME}/src/Dockerfile"])
index.commit("Added flowise application quickstart")

if "rails" in state:
# add framework quickstart files
shutil.copytree(
Expand Down Expand Up @@ -631,6 +649,24 @@ def add_expressFramework_quickstart():
if "expressFramework" in state:
add_expressFramework_quickstart()

if "flowise" in state:
DEFAULT_CONTAINER_INTERNAL_LISTEN_PORT = 3000
# POST DEFAULT_CONTAINER_INTERNAL_LISTEN_PORT to DOKKU_HOST_SSH_ENDPOINT
data = {
"CONTAINER_HOSTING_SSH_SETUP_HANDLER_API_KEY": CONTAINER_HOSTING_SSH_SETUP_HANDLER_API_KEY,
"APP_NAME": APP_NAME,
"KEY": f"{APP_NAME}:DEFAULT_CONTAINER_INTERNAL_LISTEN_PORT",
"VALUE": DEFAULT_CONTAINER_INTERNAL_LISTEN_PORT,
}
try:
print("Posting to DOKKU_HOST_SSH_ENDPOINT")
req = requests.post(
DOKKU_HOST_SSH_ENDPOINT + "/STORE-KEY-VALUE", json=data, timeout=10
)
except requests.exceptions.ConnectTimeout as e:
print(f"Ignoring ConnectTimeout because we fire and forget: {e}")
add_flowise_quickstart()

if "---existing_repo-" in state:
# In this case don't create a new repo, only
# add to the existing repo provided in ---existing_repo-.. metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM flowiseai/flowise:1.6.2
# See https://github.com/FlowiseAI/Flowise/issues/2064
CMD /usr/local/bin/npx flowise start

EXPOSE 3000
12 changes: 11 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h2 class="subheading">Container hosting service with a database &amp; CI/CD inc
<hr />
<h2>Quickstart</h2>
<ol>
<li>Choose your framework</li>
<li>Choose your framework (or <a href="#application">application)</a></li>
<li>Connect your GitHub account</li>
<li>Automatic project setup (database, CI/CD &amp; tagged releases)</li>
</ol>
Expand Down Expand Up @@ -134,6 +134,16 @@ <h3>FAQ</h3>
</ul>


<h2 id="application">Application Hosting</h2>
<p>Quickly host popular container applications. Click the application you want to host, and we'll
spin up a repo for you to store the application so you can contribute to it/host it.</p>

<ul>
<li><a class="debounce" href="{{ github_authorize_url_flowise }}">Flowise</a></li>
</ul>



<script>
debounceLinks = document.getElementsByClassName("debounce");
for (i=0;i<debounceLinks.length;i++){
Expand Down
Loading