added uvicorn
This commit is contained in:
parent
3802158ad5
commit
cd3663038f
@ -34,7 +34,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
if (pythonWSGI?.toLowerCase() === 'gunicorn') {
|
if (pythonWSGI?.toLowerCase() === 'gunicorn') {
|
||||||
Dockerfile.push(`RUN pip install gunicorn`);
|
Dockerfile.push(`RUN pip install gunicorn`);
|
||||||
} else if (pythonWSGI?.toLowerCase() === 'uwsgi') {
|
} else if (pythonWSGI?.toLowerCase() === "uvicorn") {
|
||||||
|
Dockerfile.push(`RUN pip install uvicorn`);
|
||||||
|
}
|
||||||
|
else if (pythonWSGI?.toLowerCase() === 'uwsgi') {
|
||||||
Dockerfile.push(`RUN apk add --no-cache uwsgi-python3`);
|
Dockerfile.push(`RUN apk add --no-cache uwsgi-python3`);
|
||||||
// Dockerfile.push(`RUN pip install --no-cache-dir uwsgi`)
|
// Dockerfile.push(`RUN pip install --no-cache-dir uwsgi`)
|
||||||
}
|
}
|
||||||
@ -49,8 +52,12 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
Dockerfile.push(`EXPOSE ${port}`);
|
Dockerfile.push(`EXPOSE ${port}`);
|
||||||
if (pythonWSGI?.toLowerCase() === 'gunicorn') {
|
if (pythonWSGI?.toLowerCase() === 'gunicorn') {
|
||||||
Dockerfile.push(`CMD gunicorn -w=4 -b=0.0.0.0:8000 ${pythonModule}:${pythonVariable}`);
|
Dockerfile.push(`CMD gunicorn ${pythonModule}:${pythonVariable}`);
|
||||||
} else if (pythonWSGI?.toLowerCase() === 'uwsgi') {
|
} else if (pythonWSGI?.toLowerCase() === "uvicorn") {
|
||||||
|
Dockerfile.push(`CMD uvicorn ${pythonModule}:${pythonVariable} --reload --port ${port}`);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (pythonWSGI?.toLowerCase() === 'uwsgi') {
|
||||||
Dockerfile.push(
|
Dockerfile.push(
|
||||||
`CMD uwsgi --master -p 4 --http-socket 0.0.0.0:8000 --uid uwsgi --plugins python3 --protocol uwsgi --wsgi ${pythonModule}:${pythonVariable}`
|
`CMD uwsgi --master -p 4 --http-socket 0.0.0.0:8000 --uid uwsgi --plugins python3 --protocol uwsgi --wsgi ${pythonModule}:${pythonVariable}`
|
||||||
);
|
);
|
||||||
|
@ -45,9 +45,9 @@
|
|||||||
import Explainer from '$lib/components/Explainer.svelte';
|
import Explainer from '$lib/components/Explainer.svelte';
|
||||||
import Setting from '$lib/components/Setting.svelte';
|
import Setting from '$lib/components/Setting.svelte';
|
||||||
import type Prisma from '@prisma/client';
|
import type Prisma from '@prisma/client';
|
||||||
import { getDomain, notNodeDeployments, staticDeployments } from '$lib/components/common';
|
import { notNodeDeployments, staticDeployments } from '$lib/components/common';
|
||||||
import { toast } from '@zerodevx/svelte-toast';
|
import { toast } from '@zerodevx/svelte-toast';
|
||||||
import { get, post } from '$lib/api';
|
import { post } from '$lib/api';
|
||||||
import cuid from 'cuid';
|
import cuid from 'cuid';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/env';
|
||||||
import { disabledButton } from '$lib/store';
|
import { disabledButton } from '$lib/store';
|
||||||
@ -63,10 +63,6 @@
|
|||||||
let dualCerts = application.settings.dualCerts;
|
let dualCerts = application.settings.dualCerts;
|
||||||
let autodeploy = application.settings.autodeploy;
|
let autodeploy = application.settings.autodeploy;
|
||||||
|
|
||||||
let nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
|
|
||||||
let isNonWWWDomainOK = false;
|
|
||||||
let isWWWDomainOK = false;
|
|
||||||
|
|
||||||
let wsgis = [
|
let wsgis = [
|
||||||
{
|
{
|
||||||
value: 'None',
|
value: 'None',
|
||||||
@ -75,6 +71,10 @@
|
|||||||
{
|
{
|
||||||
value: 'Gunicorn',
|
value: 'Gunicorn',
|
||||||
label: 'Gunicorn'
|
label: 'Gunicorn'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Uvicorn',
|
||||||
|
label: 'Uvicorn'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
function containerClass() {
|
function containerClass() {
|
||||||
@ -131,31 +131,13 @@
|
|||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
|
await post(`/applications/${id}/check.json`, { fqdn: application.fqdn, forceSave });
|
||||||
await post(`/applications/${id}/check.json`, {
|
|
||||||
fqdn: application.fqdn,
|
|
||||||
forceSave,
|
|
||||||
dualCerts,
|
|
||||||
exposePort: application.exposePort
|
|
||||||
});
|
|
||||||
await post(`/applications/${id}.json`, { ...application });
|
await post(`/applications/${id}.json`, { ...application });
|
||||||
$disabledButton = false;
|
$disabledButton = false;
|
||||||
forceSave = false;
|
|
||||||
return toast.push('Configurations saved.');
|
return toast.push('Configurations saved.');
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
||||||
forceSave = true;
|
forceSave = true;
|
||||||
if (dualCerts) {
|
|
||||||
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
|
||||||
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
|
||||||
} else {
|
|
||||||
const isWWW = getDomain(application.fqdn).includes('www.');
|
|
||||||
if (isWWW) {
|
|
||||||
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
|
||||||
} else {
|
|
||||||
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -173,19 +155,6 @@
|
|||||||
application.baseBuildImage = event.detail.value;
|
application.baseBuildImage = event.detail.value;
|
||||||
await handleSubmit();
|
await handleSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isDNSValid(domain, isWWW) {
|
|
||||||
try {
|
|
||||||
await get(`/applications/${id}/check.json?domain=${domain}`);
|
|
||||||
toast.push('DNS configuration is valid.');
|
|
||||||
isWWW ? (isWWWDomainOK = true) : (isNonWWWDomainOK = true);
|
|
||||||
return true;
|
|
||||||
} catch ({ error }) {
|
|
||||||
errorNotification(error);
|
|
||||||
isWWW ? (isWWWDomainOK = false) : (isNonWWWDomainOK = false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex items-center space-x-2 p-5 px-6 font-bold">
|
<div class="flex items-center space-x-2 p-5 px-6 font-bold">
|
||||||
@ -358,26 +327,24 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if application.buildPack !== 'docker'}
|
<div class="grid grid-cols-2 items-center">
|
||||||
<div class="grid grid-cols-2 items-center">
|
<label for="baseImage" class="text-base font-bold text-stone-100"
|
||||||
<label for="baseImage" class="text-base font-bold text-stone-100"
|
>{$t('application.base_image')}</label
|
||||||
>{$t('application.base_image')}</label
|
>
|
||||||
>
|
<div class="custom-select-wrapper">
|
||||||
<div class="custom-select-wrapper">
|
<Select
|
||||||
<Select
|
isDisabled={!$session.isAdmin || isRunning}
|
||||||
isDisabled={!$session.isAdmin || isRunning}
|
containerClasses={containerClass()}
|
||||||
containerClasses={containerClass()}
|
id="baseImages"
|
||||||
id="baseImages"
|
showIndicator={!isRunning}
|
||||||
showIndicator={!isRunning}
|
items={application.baseImages}
|
||||||
items={application.baseImages}
|
on:select={selectBaseImage}
|
||||||
on:select={selectBaseImage}
|
value={application.baseImage}
|
||||||
value={application.baseImage}
|
isClearable={false}
|
||||||
isClearable={false}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Explainer text={$t('application.base_image_explainer')} />
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
<Explainer text={$t('application.base_image_explainer')} />
|
||||||
|
</div>
|
||||||
{#if application.buildCommand || application.buildPack === 'rust' || application.buildPack === 'laravel'}
|
{#if application.buildCommand || application.buildPack === 'rust' || application.buildPack === 'laravel'}
|
||||||
<div class="grid grid-cols-2 items-center pb-8">
|
<div class="grid grid-cols-2 items-center pb-8">
|
||||||
<label for="baseBuildImage" class="text-base font-bold text-stone-100"
|
<label for="baseBuildImage" class="text-base font-bold text-stone-100"
|
||||||
@ -420,52 +387,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<Explainer text={$t('application.https_explainer')} />
|
<Explainer text={$t('application.https_explainer')} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<input
|
||||||
<input
|
readonly={!$session.isAdmin || isRunning}
|
||||||
readonly={!$session.isAdmin || isRunning}
|
disabled={!$session.isAdmin || isRunning}
|
||||||
disabled={!$session.isAdmin || isRunning}
|
bind:this={domainEl}
|
||||||
bind:this={domainEl}
|
name="fqdn"
|
||||||
name="fqdn"
|
id="fqdn"
|
||||||
id="fqdn"
|
bind:value={application.fqdn}
|
||||||
bind:value={application.fqdn}
|
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
|
||||||
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
|
placeholder="eg: https://coollabs.io"
|
||||||
placeholder="eg: https://coollabs.io"
|
required
|
||||||
/>
|
/>
|
||||||
{#if forceSave}
|
|
||||||
<div class="flex-col space-y-2 pt-4 text-center">
|
|
||||||
{#if isNonWWWDomainOK}
|
|
||||||
<button
|
|
||||||
class="bg-green-600 hover:bg-green-500"
|
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
|
||||||
>DNS settings for {nonWWWDomain} is OK, click to recheck.</button
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
class="bg-red-600 hover:bg-red-500"
|
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
|
||||||
>DNS settings for {nonWWWDomain} is invalid, click to recheck.</button
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
{#if dualCerts}
|
|
||||||
{#if isWWWDomainOK}
|
|
||||||
<button
|
|
||||||
class="bg-green-600 hover:bg-green-500"
|
|
||||||
on:click|preventDefault={() =>
|
|
||||||
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
|
||||||
>DNS settings for www.{nonWWWDomain} is OK, click to recheck.</button
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
class="bg-red-600 hover:bg-red-500"
|
|
||||||
on:click|preventDefault={() =>
|
|
||||||
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
|
||||||
>DNS settings for www.{nonWWWDomain} is invalid, click to recheck.</button
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center pb-8">
|
<div class="grid grid-cols-2 items-center pb-8">
|
||||||
<Setting
|
<Setting
|
||||||
@ -480,7 +412,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if application.buildPack === 'python'}
|
{#if application.buildPack === 'python'}
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<label for="pythonModule" class="text-base font-bold text-stone-100">WSGI</label>
|
<label for="pythonModule" class="text-base font-bold text-stone-100">WSGI / ASGI</label>
|
||||||
<div class="custom-select-wrapper">
|
<div class="custom-select-wrapper">
|
||||||
<Select id="wsgi" items={wsgis} on:select={selectWSGI} value={application.pythonWSGI} />
|
<Select id="wsgi" items={wsgis} on:select={selectWSGI} value={application.pythonWSGI} />
|
||||||
</div>
|
</div>
|
||||||
@ -494,7 +426,7 @@
|
|||||||
id="pythonModule"
|
id="pythonModule"
|
||||||
required
|
required
|
||||||
bind:value={application.pythonModule}
|
bind:value={application.pythonModule}
|
||||||
placeholder={application.pythonWSGI?.toLowerCase() !== 'gunicorn' ? 'main.py' : 'main'}
|
placeholder={application.pythonWSGI?.toLowerCase() !== 'none' ? 'main' : 'main.py'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if application.pythonWSGI?.toLowerCase() === 'gunicorn'}
|
{#if application.pythonWSGI?.toLowerCase() === 'gunicorn'}
|
||||||
@ -510,6 +442,19 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if application.pythonWSGI?.toLowerCase() === 'uvicorn'}
|
||||||
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
<label for="pythonVariable" class="text-base font-bold text-stone-100">Variable</label>
|
||||||
|
<input
|
||||||
|
readonly={!$session.isAdmin}
|
||||||
|
name="pythonVariable"
|
||||||
|
id="pythonVariable"
|
||||||
|
required
|
||||||
|
bind:value={application.pythonVariable}
|
||||||
|
placeholder="default: app"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if !staticDeployments.includes(application.buildPack)}
|
{#if !staticDeployments.includes(application.buildPack)}
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
@ -523,24 +468,9 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if application.buildPack !== 'docker'}
|
|
||||||
<div class="grid grid-cols-2 items-center">
|
|
||||||
<label for="exposePort" class="text-base font-bold text-stone-100">Exposed Port</label>
|
|
||||||
<input
|
|
||||||
readonly={!$session.isAdmin && !isRunning}
|
|
||||||
disabled={!$session.isAdmin || isRunning}
|
|
||||||
name="exposePort"
|
|
||||||
id="exposePort"
|
|
||||||
bind:value={application.exposePort}
|
|
||||||
placeholder="12345"
|
|
||||||
/>
|
|
||||||
<Explainer
|
|
||||||
text={'You can expose your application to a port on the host system.<br><br>Useful if you would like to use your own reverse proxy or tunnel and also in development mode. Otherwise leave empty.'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{#if !notNodeDeployments.includes(application.buildPack)}
|
{#if !notNodeDeployments.includes(application.buildPack)}
|
||||||
<div class="grid grid-cols-2 items-center pt-4">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<label for="installCommand" class="text-base font-bold text-stone-100"
|
<label for="installCommand" class="text-base font-bold text-stone-100"
|
||||||
>{$t('application.install_command')}</label
|
>{$t('application.install_command')}</label
|
||||||
>
|
>
|
||||||
@ -578,7 +508,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if application.buildPack === 'docker'}
|
{#if application.buildPack === 'docker'}
|
||||||
<div class="grid grid-cols-2 items-center pt-4">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<label for="dockerFileLocation" class="text-base font-bold text-stone-100"
|
<label for="dockerFileLocation" class="text-base font-bold text-stone-100"
|
||||||
>Dockerfile Location</label
|
>Dockerfile Location</label
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user