Compare commits

...

24 Commits

Author SHA1 Message Date
Andras Bacsai
a8e9668c2b Haha 2021-06-22 12:19:12 +02:00
Andras Bacsai
425feba0e2 It's working! 2021-06-22 12:12:11 +02:00
Andras Bacsai
c09b8d888f Hmm, it should work now, right? (Please... work..) 2021-06-22 12:07:51 +02:00
Andras Bacsai
748e691a58 Hmm, ok 2021-06-22 12:02:06 +02:00
Andras Bacsai
f8c81ff95f Nooo 2021-06-22 11:54:19 +02:00
Andras Bacsai
d11c4a3cd7 Fix the fix of fix 2021-06-22 11:45:46 +02:00
Andras Bacsai
3f3ea151ef Fixes are not fixing 2021-06-22 11:40:02 +02:00
Andras Bacsai
7e2f68870c Hm, soemthing is not working 2021-06-22 11:20:21 +02:00
Andras Bacsai
df41cf14da Fix login again 2021-06-22 11:12:30 +02:00
Andras Bacsai
111370c025 Fix email login 2021-06-22 10:56:38 +02:00
Andras Bacsai
bcb2ba0b1b Fix Get Started button 2021-06-22 10:44:08 +02:00
Andras Bacsai
807d526ffa v1.0.21 (#66) 2021-06-22 10:19:20 +02:00
Andras Bacsai
2ff9c5fed5 v1.0.20 (#65) 2021-06-18 21:16:05 +02:00
Andras Bacsai
d43cd663d2 v1.0.19 (#64) 2021-06-17 20:47:09 +02:00
Andras Bacsai
dae91267e8 Corrected package.json dependencies 2021-06-16 11:14:10 +02:00
Andras Bacsai
b2d6317a23 SvelteKit package updates 2021-06-16 10:56:53 +02:00
Andras Bacsai
c49b412e69 Fix sveltekit/adapter-node version 2021-06-11 11:20:12 +02:00
Andras Bacsai
05e5d73556 v1.0.18 (#60)
* Removed nocodb image

* Quick fix for no installations
2021-06-10 11:55:02 +02:00
Andras Bacsai
53620f4b1a Update README.md 2021-06-07 23:57:31 +02:00
Andras Bacsai
9d14b03eb1 v1.0.17 (#59) 2021-06-07 23:44:36 +02:00
Andras Bacsai
04a5b1bd4f Fix for PR 2021-06-07 21:49:52 +02:00
Andras Bacsai
31b3f58b2c v1.0.16 (#51) 2021-06-07 21:33:11 +02:00
Andras Bacsai
9c173d1de0 bump version 2021-05-22 15:33:13 +02:00
Andras Bacsai
e11b6d74ed v1.0.15 (#49)
Webhook quickfix.
2021-05-22 15:28:22 +02:00
71 changed files with 4068 additions and 2708 deletions

View File

@@ -16,7 +16,8 @@ Installation is automated with the following command:
## Features
You can deploy any of the following applications, databases and services easily.
- Deploy Pull Request automatically, so you can review them quickly!
- You can deploy any of the following applications, databases and services easily.
(constantly growing lists)
@@ -47,14 +48,19 @@ With Github integration
### Services
- [WordPress](https://wordpress.org)
- [Plausible Analytics](https://plausible.io)
- [NocoDB](https://nocodb.com)
- [VSCode Server](https://github.com/cdr/code-server)
- [MinIO](https://min.io)
## Support
- Twitter: [@andrasbacsai](https://twitter.com/andrasbacsai)
- Telegram: [@andrasbacsai](https://t.me/andrasbacsai)
- Email: [andras@coollabs.io](mailto:andras@coollabs.io)
- Discord: [Invitation](https://discord.com/invite/bvS3WhR)
- Discord: [Invitation](https://discord.gg/xhBCC7eGKw)
## Roadmap

View File

@@ -1,12 +1,12 @@
{
"name": "coolify",
"description": "An open-source, hassle-free, self-hostable Heroku & Netlify alternative.",
"version": "1.0.14",
"version": "1.0.21",
"license": "AGPL-3.0",
"scripts": {
"dev:docker:start": "docker-compose -f docker-compose-dev.yml up -d",
"dev:docker:stop": "docker-compose -f docker-compose-dev.yml down",
"dev": "NODE_ENV=development svelte-kit dev --host 0.0.0.0",
"dev": "TAILWIND_MODE=watch NODE_ENV=development svelte-kit dev --host 0.0.0.0",
"build": "NODE_ENV=production svelte-kit build",
"preview": "svelte-kit preview",
"start": "node build",
@@ -14,45 +14,47 @@
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^1.0.0-next.20",
"@sveltejs/kit": "1.0.0-next.107",
"@sveltejs/adapter-node": "1.0.0-next.26",
"@sveltejs/kit": "1.0.0-next.115",
"@types/dockerode": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"autoprefixer": "^10.2.5",
"cssnano": "^5.0.2",
"dotenv-extended": "^2.9.0",
"eslint": "^7.26.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"autoprefixer": "^10.2.6",
"cssnano": "^5.0.5",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.0",
"postcss": "^8.2.15",
"postcss": "^8.3.0",
"postcss-load-config": "^3.0.1",
"prettier": "~2.3.0",
"prettier": "~2.3.1",
"prettier-plugin-svelte": "^2.3.0",
"svelte": "^3.38.2",
"svelte-preprocess": "^4.7.3",
"tailwindcss": "2.2.0-canary.8",
"tailwindcss": "2.2.0",
"tslib": "^2.2.0",
"typescript": "^4.2.4",
"vite": "^2.3.2"
"typescript": "^4.3.2",
"vite": "^2.3.6"
},
"type": "module",
"dependencies": {
"@iarna/toml": "^2.2.5",
"@zerodevx/svelte-toast": "^0.3.0",
"bcrypt": "^5.0.1",
"commander": "^7.2.0",
"compare-versions": "^3.6.0",
"cookie": "^0.4.1",
"cuid": "^2.1.8",
"dayjs": "^1.10.4",
"dayjs": "^1.10.5",
"dockerode": "^3.3.0",
"dotenv-extended": "^2.9.0",
"generate-password": "^1.6.0",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.9",
"mongoose": "^5.12.13",
"shelljs": "^0.8.4",
"svelte-kit-cookie-session": "^0.4.3",
"svelte-kit-cookie-session": "^1.0.6",
"svelte-select": "^3.17.0",
"systeminformation": "^5.7.7",
"unique-names-generator": "^4.5.0"
}
}

3343
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -92,7 +92,9 @@ body {
input {
@apply text-sm rounded py-2 px-6 font-bold bg-warmGray-800 text-white transition duration-150 outline-none border border-transparent !important;
}
input:hover {
input:hover,
input:focus-visible,
input:focus {
@apply bg-warmGray-700 !important;
}
textarea {
@@ -107,6 +109,7 @@ select {
select:hover {
@apply bg-warmGray-700 !important;
}
label {
@apply text-left text-base font-bold text-warmGray-400 !important;
}
@@ -116,6 +119,11 @@ button {
.button {
@apply rounded text-sm font-bold transition-all duration-100 !important;
}
.button:focus-visible,
.button:focus {
@apply bg-warmGray-700 !important;
}
.h-271 {
min-height: 271px !important;
}

View File

@@ -1,8 +1,17 @@
<script>
import { application } from '$store';
import { VITE_GITHUB_APP_NAME } from '$lib/consts';
import { application, isPullRequestPermissionsGranted } from '$store';
import { onMount } from 'svelte';
import TooltipInfo from '$components/TooltipInfo.svelte';
import { request } from '$lib/request';
import { page, session } from '$app/stores';
import { browser } from '$app/env';
let domainInput;
let loading = {
previewDeployment: false
};
let howToActivate = false;
const buildpacks = {
static: {
port: {
@@ -110,6 +119,45 @@
custom: true
}
};
async function setPreviewDeployment() {
if ($application.general.isPreviewDeploymentEnabled) {
const result = window.confirm(
"Are you sure? It will delete all PR deployments - it's NOT reversible!"
);
if (result) {
loading.previewDeployment = true;
$application.general.isPreviewDeploymentEnabled =
!$application.general.isPreviewDeploymentEnabled;
if ($page.path !== '/application/new') {
const config = await request(`/api/v1/application/config/previewDeployment`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch,
isPreviewDeploymentEnabled: $application.general.isPreviewDeploymentEnabled
}
});
}
loading.previewDeployment = false;
}
} else {
loading.previewDeployment = true;
$application.general.isPreviewDeploymentEnabled =
!$application.general.isPreviewDeploymentEnabled;
$application.general.pullRequest = 0;
if ($page.path !== '/application/new') {
const config = await request(`/api/v1/application/config/previewDeployment`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch,
isPreviewDeploymentEnabled: $application.general.isPreviewDeploymentEnabled
}
});
}
loading.previewDeployment = false;
}
}
function selectBuildPack(event) {
if (event.target.innerText === 'React/Preact') {
$application.build.pack = 'react';
@@ -117,6 +165,34 @@
$application.build.pack = event.target.innerText.replace(/\./g, '').toLowerCase();
}
}
async function openGithub() {
if (browser) {
const config = await request(`https://api.github.com/apps/${VITE_GITHUB_APP_NAME}`, $session);
let url = `https://github.com/settings/apps/${VITE_GITHUB_APP_NAME}/permissions`;
if (config.owner.type === 'Organization') {
url = `https://github.com/organizations/${config.owner.login}/settings/apps/${VITE_GITHUB_APP_NAME}/permissions`;
}
const left = screen.width / 2 - 1020 / 2;
const top = screen.height / 2 - 618 / 2;
const newWindow = open(
url,
'Permission Update',
'resizable=1, scrollbars=1, fullscreen=1, height=1000, width=1220,top=' +
top +
', left=' +
left +
', toolbar=0, menubar=0, status=0'
);
const timer = setInterval(async () => {
if (newWindow?.closed) {
clearInterval(timer);
location.reload();
}
}, 100);
}
}
onMount(() => {
if (!$application.publish.domain) domainInput.focus();
});
@@ -235,6 +311,127 @@
</div>
<div class="text-2xl font-bold border-gradient w-52">General settings</div>
<div class="grid grid-cols-1 max-w-2xl md:mx-auto mx-6 justify-center items-center pt-10">
<div>
<ul class="divide-y divide-warmGray-800">
<li class="pb-6 flex items-center justify-between">
<div class="flex flex-col">
<p class="text-base font-bold text-warmGray-100">Preview deployments</p>
<p class="text-sm font-medium text-warmGray-400">
PR's will be deployed so you could review them easily
</p>
</div>
{#if $isPullRequestPermissionsGranted}
<div
class="relative"
class:animate-wiggle={loading.previewDeployment}
class:opacity-25={loading.previewDeployment}
>
<button
type="button"
disabled={loading.previewDeployment}
on:click={setPreviewDeployment}
aria-pressed="false"
class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200"
class:bg-green-600={$application.general.isPreviewDeploymentEnabled}
class:bg-warmGray-700={!$application.general.isPreviewDeploymentEnabled}
class:cursor-not-allowed={loading.previewDeployment}
>
<span class="sr-only">Use setting</span>
<span
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transition ease-in-out duration-200 transform"
class:translate-x-5={$application.general.isPreviewDeploymentEnabled}
class:translate-x-0={!$application.general.isPreviewDeploymentEnabled}
>
<span
class=" ease-in duration-200 absolute inset-0 h-full w-full flex items-center justify-center transition-opacity"
class:opacity-0={$application.general.isPreviewDeploymentEnabled}
class:opacity-100={!$application.general.isPreviewDeploymentEnabled}
aria-hidden="true"
>
<svg class="bg-white h-3 w-3 text-red-600" fill="none" viewBox="0 0 12 12">
<path
d="M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</span>
<span
class="ease-out duration-100 absolute inset-0 h-full w-full flex items-center justify-center transition-opacity"
aria-hidden="true"
class:opacity-100={$application.general.isPreviewDeploymentEnabled}
class:opacity-0={!$application.general.isPreviewDeploymentEnabled}
>
<svg
class="bg-white h-3 w-3 text-green-600"
fill="currentColor"
viewBox="0 0 12 12"
>
<path
d="M3.707 5.293a1 1 0 00-1.414 1.414l1.414-1.414zM5 8l-.707.707a1 1 0 001.414 0L5 8zm4.707-3.293a1 1 0 00-1.414-1.414l1.414 1.414zm-7.414 2l2 2 1.414-1.414-2-2-1.414 1.414zm3.414 2l4-4-1.414-1.414-4 4 1.414 1.414z"
/>
</svg>
</span>
</span>
</button>
{#if loading.previewDeployment}
<div class="absolute left-0 bottom-0 -mb-4 -ml-2 text-xs font-bold">{$application.general.isPreviewDeploymentEnabled ? 'Enabling...' : 'Disabling...' }</div>
{/if}
</div>
{:else}
<div class="relative">
{#if !howToActivate}
<button
class="button py-2 px-2 bg-warmGray-800 hover:bg-warmGray-700 text-white"
on:click={() => (howToActivate = !howToActivate)}>How to active this?</button
>
{:else}
<button
class="button py-2 px-2 bg-green-600 hover:bg-green-500 text-white"
on:click={openGithub}>Open Github</button
>
{/if}
{#if howToActivate}
<div class="absolute right-0 w-64 z-10">
<div class="bg-warmGray-800 p-4 my-2 rounded text-white">
<div
class="absolute right-0 top-0 p-2 my-3 mx-1 text-xs font-bold cursor-pointer hover:bg-warmGray-700"
on:click={() => (howToActivate = false)}
>
X
</div>
<p class="text-sm font-medium text-warmGray-400">
You need to add <span class="text-white">two new permissions</span> to your GitHub
App:
</p>
<br />
<p class="text-sm font-medium text-warmGray-400">
1. In <span class="text-white">Repository permissions</span>, add
<span class="text-white">Read-only</span>
access to <span class="text-white">Pull requests</span>.
</p>
<br />
<p class="text-sm font-medium text-warmGray-400">
2. In <span class="text-white">Subscribe to events</span> section,
<span class="text-white"> check Pull request</span> field.
</p>
<br />
<p class="text-sm font-medium text-warmGray-400">
3. You <span class="text-white">receive an email</span> where you need to
<span class="text-white">accept the new permissions</span>.
</p>
</div>
</div>
{/if}
</div>
{/if}
</li>
</ul>
</div>
<div class="grid grid-flow-col gap-2 items-center pb-6">
<div class="grid grid-flow-row">
<label for="Domain" class="">Domain</label>
@@ -298,11 +495,7 @@
</div>
</div>
</div>
<div
class="text-2xl font-bold w-40 border-gradient"
>
Commands
</div>
<div class="text-2xl font-bold w-40 border-gradient">Commands</div>
<div class=" max-w-2xl md:mx-auto mx-6 justify-center items-center pt-10 pb-32">
<div class="grid grid-flow-col gap-2 items-center">
<div class="grid grid-flow-row">
@@ -320,17 +513,17 @@
placeholder="main"
/>
<label for="ApplicationInstance"
>Application Instance<TooltipInfo
label="The instance name (the main function name. See gunicorn.org for more details)"
/>
</label>
>Application Instance<TooltipInfo
label="The instance name (the main function name. See gunicorn.org for more details)"
/>
</label>
<input
class="mb-6"
id="ApplicationInstance"
bind:value={$application.build.command.python.instance}
placeholder="app"
/>
<input
class="mb-6"
id="ApplicationInstance"
bind:value={$application.build.command.python.instance}
placeholder="app"
/>
{:else}
<label
for="installCommand"
@@ -395,7 +588,7 @@
<style lang="postcss">
.buildpack {
@apply px-6 py-2 mx-2 my-2 bg-warmGray-800 w-48 ease-in-out transform hover:scale-105 text-center rounded border-2 border-transparent border-dashed cursor-pointer transition duration-100;
@apply px-6 py-2 mx-2 my-2 bg-warmGray-800 w-48 ease-in-out hover:scale-105 text-center rounded border-2 border-transparent border-dashed cursor-pointer transition duration-100;
}
</style>

View File

@@ -0,0 +1,110 @@
<script>
import { browser } from '$app/env';
import { goto } from '$app/navigation';
import { onDestroy, onMount } from 'svelte';
import { session } from '$app/stores';
import { request } from '$lib/request';
import { toast } from '@zerodevx/svelte-toast';
import { application, prApplication } from '$store';
let loadPRDeployments = null;
onMount(async () => {
await getPRDeployments();
loadPRDeployments = setInterval(async () => {
await getPRDeployments();
}, 1000);
});
onDestroy(() => {
clearInterval(loadPRDeployments);
});
async function getPRDeployments() {
const { configuration } = await request(`/api/v1/application/config`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch
}
});
$prApplication = configuration.filter((c) => c.general.pullRequest !== 0);
}
async function removePR(prConfiguration) {
const result = window.confirm("Are you sure? It's NOT reversible!");
if (result) {
await request(`/api/v1/application/remove`, $session, {
body: {
organization: prConfiguration.repository.organization,
name: prConfiguration.repository.name,
branch: prConfiguration.repository.branch,
domain: prConfiguration.publish.domain
}
});
browser && toast.push('PR deployment removed.');
const { configuration } = await request(`/api/v1/application/config`, $session, {
body: {
name: prConfiguration.repository.name,
organization: prConfiguration.repository.organization,
branch: prConfiguration.repository.branch
}
});
$prApplication = configuration.filter((c) => c.general.pullRequest !== 0);
}
}
</script>
<div class="text-2xl font-bold border-gradient w-48">Pull Requests</div>
<div class="text-center pt-4">
{#if $prApplication.length > 0}
<div class="py-4 ">
{#each $prApplication as pr}
<div class="flex space-x-4 justify-center items-center">
<div class="text-left font-bold tracking-tight ">
{pr.publish.domain}
</div>
<a
target="_blank"
class="icon mx-2 "
href={'https://' + pr.publish.domain + pr.publish.path}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg></a
>
<!-- <div class="flex-1" /> -->
<button
class="icon hover:text-red-500 hover:bg-warmGray-800"
on:click={() => removePR(pr)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
/>
</svg>
</button>
</div>
{/each}
</div>
{:else}
<div class="font-bold text-center">No PR deployments found</div>
{/if}
</div>

View File

@@ -2,7 +2,14 @@
import { goto } from '$app/navigation';
import { request } from '$lib/request';
import { session } from '$app/stores';
import { githubRepositories, application, githubInstallations } from '$store';
import {
githubRepositories,
application,
githubInstallations,
prApplication,
initConf,
isPullRequestPermissionsGranted
} from '$store';
import { fade } from 'svelte/transition';
import Loading from '$components/Loading.svelte';
@@ -18,6 +25,7 @@
};
let branches = [];
let relogin = false;
let permissions = {};
function dashify(str: string, options?: any) {
if (typeof str !== 'string') return str;
return str
@@ -60,7 +68,7 @@
return false;
}
if (installations.length === 0) {
relogin = true;
loading.github = false;
return false;
}
$application.github.installation.id = installations[0].id;
@@ -110,8 +118,17 @@
$session
);
loading.branches = false;
await loadPermissions();
}
async function loadPermissions() {
const config = await request(
`https://api.github.com/apps/${dashify(import.meta.env.VITE_GITHUB_APP_NAME)}`,
$session
);
if (config.permissions['pull_requests'] && config.events.includes('pull_request')) {
$isPullRequestPermissionsGranted = true;
}
}
async function modifyGithubAppConfig() {
if (browser) {
const left = screen.width / 2 - 1020 / 2;
@@ -128,20 +145,23 @@
', toolbar=0, menubar=0, status=0'
);
const timer = setInterval(async () => {
if (newWindow.closed) {
if (newWindow?.closed) {
clearInterval(timer);
loading.github = true;
if ($application.repository.name) {
try {
const config = await request(`/api/v1/application/config`, $session, {
const { configuration } = await request(`/api/v1/application/config`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch
}
});
$application = { ...config };
$prApplication = configuration.filter((c) => c.general.pullRequest !== 0);
$application = configuration.find((c) => c.general.pullRequest === 0);
$initConf = JSON.parse(JSON.stringify($application));
} catch (error) {
browser && goto('/dashboard/applications', { replaceState: true });
}

View File

@@ -14,7 +14,7 @@
', toolbar=0, menubar=0, status=0'
);
const timer = setInterval(() => {
if (newWindow.closed) {
if (newWindow?.closed) {
clearInterval(timer);
location.reload()
}
@@ -24,7 +24,7 @@
<div class="text-center text-white">
<div class="text-2xl font-bold text-center pb-4">Choose your Git provider</div>
<button on:click={login} class="hover:scale-110 transform duration-100 transition">
<button on:click={login} class="hover:scale-110 duration-100 transition">
<svg
class="w-16"
xmlns="http://www.w3.org/2000/svg"

View File

@@ -8,17 +8,23 @@
import { goto } from '$app/navigation';
import { browser } from '$app/env';
async function removeApplication() {
await request(`/api/v1/application/remove`, $session, {
body: {
organization: $application.repository.organization,
name: $application.repository.name,
branch: $application.repository.branch
}
});
const result = window.confirm(
"Are you sure? It will delete all deployments, including PR's - it's NOT reversible!"
);
if (result) {
await request(`/api/v1/application/remove`, $session, {
body: {
organization: $application.repository.organization,
name: $application.repository.name,
branch: $application.repository.branch,
domain: $application.publish.domain
}
});
browser && toast.push('Application removed.');
$application = JSON.parse(JSON.stringify(initialApplication));
browser && goto(`/dashboard/applications`, { replaceState: true });
browser && toast.push('Application removed.');
$application = JSON.parse(JSON.stringify(initialApplication));
browser && goto(`/dashboard/applications`, { replaceState: true });
}
}
onDestroy(() => {
@@ -46,10 +52,10 @@
);
}
} catch (error) {
// console.log(error);
// toast.push(error.error || error || 'Ooops something went wrong.');
browser && toast.push(error.error || error || 'Ooops something went wrong.');
}
}
</script>
<nav class="flex text-white justify-end items-center m-4 fixed right-0 top-0 space-x-4 z-50">

View File

@@ -1,7 +1,7 @@
<script>
import { toast } from '@zerodevx/svelte-toast';
import templates from '$lib/api/applications/packs/templates';
import { application, dashboard } from '$store';
import { application, dashboard, initConf, prApplication } from '$store';
import General from '$components/Application/ActiveTab/General.svelte';
import Secrets from '$components/Application/ActiveTab/Secrets.svelte';
import Loading from '$components/Loading.svelte';
@@ -9,17 +9,18 @@
import { page, session } from '$app/stores';
import { request } from '$lib/request';
import { browser } from '$app/env';
import PullRequests from './ActiveTab/PullRequests.svelte';
let activeTab = {
general: true,
buildStep: false,
secrets: false
secrets: false,
pullRequests: false
};
function activateTab(tab) {
if (activeTab.hasOwnProperty(tab)) {
activeTab = {
general: false,
buildStep: false,
pullRequests: false,
secrets: false
};
activeTab[tab] = true;
@@ -48,16 +49,7 @@
}
return;
}
if ($page.path !== '/application/new') {
const config = await request(`/api/v1/application/config`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch
}
});
$application = { ...config };
} else {
if ($page.path === '/application/new') {
try {
const dir = await request(
`https://api.github.com/repos/${$application.repository.organization}/${$application.repository.name}/contents/?ref=${$application.repository.branch}`,
@@ -103,17 +95,18 @@
$application.build.pack = 'rust';
browser && toast.push(`Rust language detected. Default values set.`);
} else if (requirementsTXT) {
$application.build.pack = 'python'
$application.build.pack = 'python';
browser && toast.push('Python language detected. Default values set.');
} else if (Dockerfile) {
$application.build.pack = 'docker';
browser && toast.push('Custom Dockerfile found. Build pack set to docker.');
}
}
} catch (error) {
// Nothing detected
}
}
}
</script>
{#await load()}
@@ -135,6 +128,15 @@
>
Secrets
</div>
{#if $application.general.isPreviewDeploymentEnabled}
<div
on:click={() => activateTab('pullRequests')}
class:text-green-500={activeTab.pullRequests}
class="px-3 py-2 cursor-pointer hover:bg-warmGray-700 rounded-lg transition duration-100"
>
Pull Requests
</div>
{/if}
</nav>
</div>
<div class="max-w-4xl mx-auto">
@@ -143,6 +145,8 @@
<General />
{:else if activeTab.secrets}
<Secrets />
{:else if activeTab.pullRequests && $page.path !== '/application/new'}
<PullRequests />
{/if}
</div>
</div>

View File

@@ -45,7 +45,7 @@
{#if $page.path === '/database/new'}
<div class="flex justify-center space-x-4 font-bold pb-6">
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-green-600 p-2 rounded bg-warmGray-800 w-32"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-green-600 p-2 rounded bg-warmGray-800 w-32"
class:border-green-600={type === 'mongodb'}
on:click={() => (type = 'mongodb')}
>
@@ -55,7 +55,7 @@
<div class="text-white">MongoDB</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-red-600 p-2 rounded bg-warmGray-800 w-32"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-red-600 p-2 rounded bg-warmGray-800 w-32"
class:border-red-600={type === 'couchdb'}
on:click={() => (type = 'couchdb')}
>
@@ -65,7 +65,7 @@
<div class="text-white">Couchdb</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-600 p-2 rounded bg-warmGray-800 w-32"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-600 p-2 rounded bg-warmGray-800 w-32"
class:border-blue-600={type === 'postgresql'}
on:click={() => (type = 'postgresql')}
>
@@ -75,7 +75,7 @@
<div class="text-white">PostgreSQL</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-orange-600 p-2 rounded bg-warmGray-800 w-32"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-orange-600 p-2 rounded bg-warmGray-800 w-32"
class:border-orange-600={type === 'mysql'}
on:click={() => (type = 'mysql')}
>
@@ -85,7 +85,7 @@
<div class="text-white">MySQL</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-red-600 p-2 rounded bg-warmGray-800 w-32"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-red-600 p-2 rounded bg-warmGray-800 w-32"
class:border-red-600={type === 'redis'}
on:click={() => (type = 'redis')}
>

View File

@@ -1,80 +1,83 @@
<script>
export let github = false;
export let githubLoadingText = 'Loading GitHub...';
export let fullscreen = true;
</script>
{#if fullscreen}
{#if github}
<div class="fixed left-0 top-0 flex flex-wrap content-center h-full w-full">
<div class="main flex justify-center items-center">
<div class="w-64">
<svg
class=" w-28 animate-bounce mx-auto"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><path
d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
/></svg
>
<div class="text-xl font-bold text-center">
{githubLoadingText}
</div>
</div>
</div>
</div>
{:else}
<div class="main fixed left-0 top-0 flex flex-wrap content-center h-full">
<span class="loader" />
</div>
{/if}
{:else}
<div class="main h-64 py-24 left-0 top-0 flex flex-wrap content-center mx-auto">
<span class="loader" />
</div>
{/if}
<style lang="postcss">
.loader {
width: 8px;
height: 40px;
border-radius: 4px;
display: block;
margin: 20px auto;
position: relative;
background: currentColor;
color: #fff;
box-sizing: border-box;
animation: animloader 0.3s 0.3s linear infinite alternate;
}
.loader::after,
.loader::before {
content: "";
width: 8px;
height: 40px;
border-radius: 4px;
background: currentColor;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 20px;
box-sizing: border-box;
animation: animloader 0.3s 0.45s linear infinite alternate;
}
.loader::before {
left: -20px;
animation-delay: 0s;
}
@keyframes animloader {
0% {
height: 48px;
}
100% {
height: 4px;
}
}
</style>
<script>
export let github = false;
export let githubLoadingText = "Loading GitHub...";
export let fullscreen = true;
</script>
{#if fullscreen}
{#if github}
<div class="fixed left-0 top-0 flex flex-wrap content-center h-full w-full">
<div class="main flex justify-center items-center">
<div class="w-64">
<svg
class=" w-28 animate-bounce mx-auto"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><path
d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
></path></svg
>
<div class="text-xl font-bold text-center">
{githubLoadingText}
</div>
</div>
</div>
</div>
{:else}
<div class="main fixed left-0 top-0 flex flex-wrap content-center h-full">
<span class=" loader"></span>
</div>
{/if}
{/if}
.loader {
width: 8px;
height: 40px;
border-radius: 4px;
display: block;
margin: 20px auto;
position: relative;
background: currentColor;
color: #fff;
box-sizing: border-box;
animation: animloader 0.3s 0.3s linear infinite alternate;
}
.loader::after,
.loader::before {
content: '';
width: 8px;
height: 40px;
border-radius: 4px;
background: currentColor;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 20px;
box-sizing: border-box;
animation: animloader 0.3s 0.45s linear infinite alternate;
}
.loader::before {
left: -20px;
animation-delay: 0s;
}
@keyframes animloader {
0% {
height: 48px;
}
100% {
height: 4px;
}
}
</style>

View File

@@ -1,54 +1,56 @@
<script>
export let value;
let showPassword = false;
export let value;
let showPassword = false;
export let isEditable = false;
</script>
<div class="relative w-full">
<input
type="{showPassword ? 'text' : 'password'}"
class="w-full "
{value}
disabled
/>
<div
class="absolute top-0 my-2 mx-2 right-0 cursor-pointer text-warmGray-600 hover:text-white"
on:click="{() => showPassword = !showPassword}"
>
{#if showPassword}
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
></path>
</svg>
{:else}
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
></path>
</svg>
{/if}
</div>
{#if showPassword}
<input type="text" class="w-full" bind:value disabled={!isEditable} />
{:else}
<input type="password" class="w-full" bind:value disabled={!isEditable} />
{/if}
<div
class="absolute top-0 my-2 mx-2 right-0 cursor-pointer text-warmGray-600 hover:text-white"
on:click={() => (showPassword = !showPassword)}
>
{#if showPassword}
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
/>
</svg>
{:else}
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
/>
</svg>
{/if}
</div>
</div>

View File

@@ -0,0 +1,35 @@
<script>
import { fade } from 'svelte/transition';
import { toast } from '@zerodevx/svelte-toast';
import Loading from '../Loading.svelte';
import Tooltip from '$components/Tooltip.svelte';
import { request } from '$lib/request';
import { page, session } from '$app/stores';
import PasswordField from '$components/PasswordField.svelte';
import { browser } from '$app/env';
export let service;
async function getPassword() {
try {
const { password } = await request(`/api/v1/services/deploy/${$page.params.name}/password`, $session);
service.config.password = password
} catch (error) {
console.log(error);
browser && toast.push(`Ooops, there was an error activating users for VSCode Server?!`);
}
}
</script>
{#await getPassword()}
<Loading />
{:then}
<div class="text-left max-w-5xl mx-auto px-6" in:fade={{ duration: 100 }}>
<div class="pb-2 pt-5 space-y-4">
<div class="flex items-center">
<div class="font-bold w-64 text-warmGray-400">Password</div>
<PasswordField value={service.config.password} />
</div>
</div>
</div>
{/await}

View File

@@ -0,0 +1,26 @@
<script>
import { fade } from 'svelte/transition';
import { toast } from '@zerodevx/svelte-toast';
import Loading from '../Loading.svelte';
import Tooltip from '$components/Tooltip.svelte';
import { request } from '$lib/request';
import { page, session } from '$app/stores';
import PasswordField from '$components/PasswordField.svelte';
import { browser } from '$app/env';
export let service;
</script>
<div class="text-left max-w-5xl mx-auto px-6" in:fade={{ duration: 100 }}>
<div class="pb-2 pt-5 space-y-4">
<div class="flex items-center pt-4">
<div class="font-bold w-64 text-warmGray-400">Root User</div>
<input class="w-full" value={service.config.generateEnvsMinIO.MINIO_ROOT_USER} disabled />
</div>
<div class="flex items-center">
<div class="font-bold w-64 text-warmGray-400">Root Password</div>
<PasswordField value={service.config.generateEnvsMinIO.MINIO_ROOT_PASSWORD} />
</div>
</div>
</div>

View File

@@ -6,7 +6,7 @@
import { request } from '$lib/request';
import { page, session } from '$app/stores';
import PasswordField from '$components/PasswordField.svelte';
import { browser } from '$app/env';
import { browser } from '$app/env';
export let service;
let loading = false;
async function activate() {
@@ -24,6 +24,7 @@ import { browser } from '$app/env';
loading = false;
}
}
</script>
{#if loading}

5
src/global.d.ts vendored
View File

@@ -36,6 +36,8 @@ export type Application = {
deployId: string;
nickname: string;
workdir: string;
isPreviewDeploymentEnabled: boolean;
pullRequest: number;
};
build: {
pack: string;
@@ -47,8 +49,7 @@ export type Application = {
python: {
module?: string;
instance?: string;
}
};
};
container: {
name: string;

View File

@@ -31,11 +31,9 @@ async function connectMongoDB() {
);
}
console.log('Connected to mongodb.');
} catch (error) {
console.log(error);
}
}
(async () => {
@@ -48,7 +46,7 @@ async function connectMongoDB() {
try {
await cleanupStuckedDeploymentsInDB();
} catch (error) {
console.log(error)
console.log(error);
}
try {
const dockerServices = await docker.engine.listServices();
@@ -76,26 +74,43 @@ async function connectMongoDB() {
).values()
];
for (const application of applications) {
await Configuration.findOneAndUpdate({
'repository.name': application.configuration.repository.name,
'repository.organization': application.configuration.repository.organization,
'repository.branch': application.configuration.repository.branch,
}, {
...application.configuration
}, { upsert: true })
await Configuration.findOneAndUpdate(
{
'repository.name': application.configuration.repository.name,
'repository.organization': application.configuration.repository.organization,
'repository.branch': application.configuration.repository.branch,
'publish.domain': application.configuration.publish.domain
},
{
...application.configuration
},
{ upsert: true, new: true }
);
}
} catch (error) {
console.log(error)
console.log(error);
}
})()
})();
export async function handle({ request, render }) {
export async function handle({ request, resolve }) {
const { SECRETS_ENCRYPTION_KEY } = process.env;
const session = initializeSession(request.headers, {
secret: SECRETS_ENCRYPTION_KEY,
cookie: { path: '/' }
});
let session;
try {
session = initializeSession(request.headers, {
secret: SECRETS_ENCRYPTION_KEY,
cookie: { path: '/', secure: true }
});
} catch (error) {
console.log(error)
return {
status: 302,
headers: {
'set-cookie': 'kit.session=deleted;path=/;expires=Wed, 21 Oct 2015 07:28:00 GMT',
location: '/'
}
};
}
request.locals.session = session;
if (session?.data?.coolToken) {
try {
@@ -105,7 +120,7 @@ export async function handle({ request, render }) {
request.locals.session.destroy = true;
}
}
const response = await render(request);
const response = await resolve(request);
if (!session['set-cookie']) {
if (!session?.data?.coolToken && !publicPages.includes(request.path)) {
return {
@@ -131,6 +146,6 @@ export function getSession(request) {
isLoggedIn: data && Object.keys(data).length !== 0 ? true : false,
expires: data.expires,
coolToken: data.coolToken,
ghToken: data.ghToken
ghToken: data.ghToken || null
};
}

View File

@@ -11,7 +11,8 @@ export async function deleteSameDeployments(configuration) {
const running = JSON.parse(s.Spec.Labels.configuration);
if (
running.repository.id === configuration.repository.id &&
running.repository.branch === configuration.repository.branch
running.repository.branch === configuration.repository.branch &&
running.publish.domain === configuration.publish.domain
) {
await execShellAsync(`docker stack rm ${s.Spec.Labels['com.docker.stack.namespace']}`);
}
@@ -54,7 +55,6 @@ export async function purgeImagesContainers(configuration, deleteAll = false) {
.split('\n');
if (IDsToDelete.length > 1) await execShellAsync(`docker rmi -f ${IDsToDelete.join(' ')}`);
}
} catch (error) {
console.log(error);
}

View File

@@ -4,7 +4,7 @@ import { execShellAsync } from '../common';
export default async function (configuration) {
try {
const { GITHUB_APP_PRIVATE_KEY } = process.env;
const { workdir } = configuration.general;
const { workdir, isPreviewDeploymentEnabled, pullRequest } = configuration.general;
const { organization, name, branch } = configuration.repository;
const github = configuration.github;
if (!github.installation.id || !github.app.id) {
@@ -37,8 +37,14 @@ export default async function (configuration) {
await execShellAsync(
`mkdir -p ${workdir} && git clone -q -b ${branch} https://x-access-token:${token}@github.com/${organization}/${name}.git ${workdir}/`
);
if (isPreviewDeploymentEnabled && pullRequest && pullRequest !== 0) {
await execShellAsync(
`cd ${workdir} && git fetch origin pull/${pullRequest}/head:pull_${pullRequest} && git checkout pull_${pullRequest}`
);
}
configuration.build.container.tag = (
await execShellAsync(`cd ${configuration.general.workdir}/ && git rev-parse HEAD`)
await execShellAsync(`cd ${workdir}/ && git rev-parse HEAD`)
)
.replace('\n', '')
.slice(0, 7);

View File

@@ -10,9 +10,8 @@ function getUniq() {
}
export function setDefaultConfiguration(configuration) {
const nickname = getUniq();
const nickname = configuration.general.nickname || getUniq();
const deployId = cuid();
const shaBase = JSON.stringify({ repository: configuration.repository });
const sha256 = crypto.createHash('sha256').update(shaBase).digest('hex');
@@ -21,12 +20,17 @@ export function setDefaultConfiguration(configuration) {
configuration.general.nickname = nickname;
configuration.general.deployId = deployId;
configuration.general.workdir = `/tmp/${deployId}`;
if (configuration.general.isPreviewDeploymentEnabled && configuration.general.pullRequest !== 0) {
configuration.build.container.name = `pr${configuration.general.pullRequest}-${sha256.slice(
0,
8
)}`;
configuration.publish.domain = `pr${configuration.general.pullRequest}.${configuration.publish.domain}`;
}
if (!configuration.publish.path) configuration.publish.path = '/';
if (!configuration.publish.port) {
if (
configuration.build.pack === 'nodejs' ||
configuration.build.pack === 'vuejs' ||
configuration.build.pack === 'nuxtjs' ||
configuration.build.pack === 'rust' ||
configuration.build.pack === 'nextjs' ||
@@ -58,11 +62,13 @@ export function setDefaultConfiguration(configuration) {
configuration.build.pack === 'nextjs' ||
configuration.build.pack === 'nestjs'
) {
if (!configuration.build.command.start) configuration.build.command.start = 'yarn start'
if (!configuration.build.command.start) configuration.build.command.start = 'yarn start';
}
if (configuration.build.pack === 'python') {
if (!configuration.build.command.python.module) configuration.build.command.python.module = 'main'
if (!configuration.build.command.python.instance) configuration.build.command.python.instance = 'app'
if (!configuration.build.command.python.module)
configuration.build.command.python.module = 'main';
if (!configuration.build.command.python.instance)
configuration.build.command.python.instance = 'app';
}
configuration.build.container.baseSHA = crypto
@@ -74,13 +80,17 @@ export function setDefaultConfiguration(configuration) {
return configuration;
}
export async function precheckDeployment({ services, configuration }) {
export async function precheckDeployment(configuration) {
const services = (await docker.engine.listServices()).filter(
(r) =>
r.Spec.Labels.managedBy === 'coolify' &&
r.Spec.Labels.type === 'application' &&
JSON.parse(r.Spec.Labels.configuration).publish.domain === configuration.publish.domain
);
let foundService = false;
let configChanged = false;
let imageChanged = false;
let forceUpdate = false;
for (const service of services) {
const running = JSON.parse(service.Spec.Labels.configuration);
if (running) {
@@ -88,6 +98,7 @@ export async function precheckDeployment({ services, configuration }) {
running.repository.id === configuration.repository.id &&
running.repository.branch === configuration.repository.branch
) {
foundService = true;
// Base service configuration changed
if (
!running.build.container.baseSHA ||
@@ -107,8 +118,32 @@ export async function precheckDeployment({ services, configuration }) {
(n) =>
n.DesiredState !== 'Running' && n.Image.split(':')[1] === running.build.container.tag
);
if (isError.length > 0) forceUpdate = true;
foundService = true;
if (isError.length > 0) {
forceUpdate = true;
}
const compareObjects = (a, b) => {
if (a === b) return true;
if (typeof a != 'object' || typeof b != 'object' || a == null || b == null) return false;
const keysA = Object.keys(a),
keysB = Object.keys(b);
if (keysA.length != keysB.length) return false;
for (const key of keysA) {
if (!keysB.includes(key)) return false;
if (typeof a[key] === 'function' || typeof b[key] === 'function') {
if (a[key].toString() != b[key].toString()) return false;
} else {
if (!compareObjects(a[key], b[key])) return false;
}
}
return true;
};
const runningWithoutContainer = JSON.parse(JSON.stringify(running));
delete runningWithoutContainer.build.container;
@@ -118,16 +153,23 @@ export async function precheckDeployment({ services, configuration }) {
// If only the configuration changed
if (
JSON.stringify(runningWithoutContainer.build) !==
JSON.stringify(configurationWithoutContainer.build) ||
JSON.stringify(runningWithoutContainer.publish) !==
JSON.stringify(configurationWithoutContainer.publish)
)
!compareObjects(runningWithoutContainer.build, configurationWithoutContainer.build) ||
!compareObjects(runningWithoutContainer.publish, configurationWithoutContainer.publish) ||
runningWithoutContainer.general.isPreviewDeploymentEnabled !==
configurationWithoutContainer.general.isPreviewDeploymentEnabled
) {
configChanged = true;
}
// If only the image changed
if (running.build.container.tag !== configuration.build.container.tag) imageChanged = true;
// If build pack changed, forceUpdate the service
if (running.build.pack !== configuration.build.pack) forceUpdate = true;
if (
configuration.general.isPreviewDeploymentEnabled &&
configuration.general.pullRequest !== 0
)
forceUpdate = true;
}
}
}
@@ -144,28 +186,9 @@ export async function precheckDeployment({ services, configuration }) {
}
export async function updateServiceLabels(configuration) {
// In case of any failure during deployment, still update the current configuration.
const services = (await docker.engine.listServices()).filter(
(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application'
return await execShellAsync(
`docker service update --label-add configuration='${JSON.stringify(configuration)}' ${
configuration.build.container.name
}_${configuration.build.container.name}`
);
const found = services.find((s) => {
const config = JSON.parse(s.Spec.Labels.configuration);
if (
config.repository.id === configuration.repository.id &&
config.repository.branch === configuration.repository.branch
) {
return config;
}
return null;
});
if (found) {
const { ID } = found;
const Labels = { ...JSON.parse(found.Spec.Labels.configuration), ...configuration };
await execShellAsync(
`docker service update --label-add configuration='${JSON.stringify(
Labels
)}' --label-add com.docker.stack.image='${configuration.build.container.name}:${configuration.build.container.tag
}' ${ID}`
);
}
}

View File

@@ -1,9 +1,9 @@
import { docker } from '$lib/api/docker';
import { saveAppLog } from './logging';
import { promises as fs } from 'fs';
import { deleteSameDeployments } from './cleanup';
import { deleteSameDeployments, purgeImagesContainers } from './cleanup';
import yaml from 'js-yaml';
import { execShellAsync } from '../common';
import { delay, execShellAsync } from '../common';
export default async function (configuration, imageChanged) {
const generateEnvs = {};
@@ -11,6 +11,7 @@ export default async function (configuration, imageChanged) {
generateEnvs[secret.name] = secret.value;
}
const containerName = configuration.build.container.name;
const containerTag = configuration.build.container.tag;
// Only save SHA256 of it in the configuration label
const baseServiceConfiguration = configuration.baseServiceConfiguration;
@@ -20,7 +21,7 @@ export default async function (configuration, imageChanged) {
version: '3.8',
services: {
[containerName]: {
image: `${configuration.build.container.name}:${configuration.build.container.tag}`,
image: `${containerName}:${containerTag}`,
networks: [`${docker.network}`],
environment: generateEnvs,
deploy: {
@@ -31,22 +32,18 @@ export default async function (configuration, imageChanged) {
'configuration=' + JSON.stringify(configuration),
'traefik.enable=true',
'traefik.http.services.' +
configuration.build.container.name +
containerName +
`.loadbalancer.server.port=${configuration.publish.port}`,
'traefik.http.routers.' + configuration.build.container.name + '.entrypoints=websecure',
'traefik.http.routers.' + containerName + '.entrypoints=websecure',
'traefik.http.routers.' +
configuration.build.container.name +
containerName +
'.rule=Host(`' +
configuration.publish.domain +
'`) && PathPrefix(`' +
configuration.publish.path +
'`)',
'traefik.http.routers.' +
configuration.build.container.name +
'.tls.certresolver=letsencrypt',
'traefik.http.routers.' +
configuration.build.container.name +
'.middlewares=global-compress'
'traefik.http.routers.' + containerName + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + containerName + '.middlewares=global-compress'
]
}
}
@@ -62,7 +59,7 @@ export default async function (configuration, imageChanged) {
if (imageChanged) {
// console.log('image changed')
await execShellAsync(
`docker service update --image ${configuration.build.container.name}:${configuration.build.container.tag} ${configuration.build.container.name}_${configuration.build.container.name}`
`docker service update --image ${containerName}:${containerTag} ${containerName}_${containerName}`
);
} else {
// console.log('new deployment or force deployment or config changed')
@@ -71,6 +68,11 @@ export default async function (configuration, imageChanged) {
`cat ${configuration.general.workdir}/stack.yml | docker stack deploy --prune -c - ${containerName}`
);
}
async function purgeImagesAsync(found) {
await delay(10000);
await purgeImagesContainers(found, true);
}
purgeImagesAsync(configuration);
await saveAppLog('### Published done!', configuration);
}

View File

@@ -4,7 +4,6 @@ import ApplicationLog from '$models/ApplicationLog';
import dayjs from 'dayjs';
import { version } from '../../../../package.json';
function generateTimestamp() {
return `${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} `;
}

View File

@@ -15,10 +15,7 @@ const publishPython = (configuration) => {
};
export default async function (configuration) {
await fs.writeFile(
`${configuration.general.workdir}/Dockerfile`,
publishPython(configuration)
);
await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishPython(configuration));
const stream = await docker.engine.buildImage(
{ src: ['.'], context: configuration.general.workdir },
{ t: `${configuration.build.container.name}:${configuration.build.container.tag}` }

View File

@@ -46,6 +46,7 @@ const templates = {
pack: 'vuejs',
...defaultBuildAndDeploy,
directory: 'dist',
port: 80,
name: 'Vue'
},
gatsby: {

View File

@@ -1,4 +1,3 @@
import Deployment from '$models/Deployment';
import dayjs from 'dayjs';
import buildContainer from './buildContainer';
@@ -10,7 +9,7 @@ import { saveAppLog } from './logging';
export default async function (configuration, imageChanged) {
const { id, organization, name, branch } = configuration.repository;
const { domain } = configuration.publish;
const { deployId} = configuration.general;
const { deployId } = configuration.general;
try {
await saveAppLog(`${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} Queued.`, configuration);
await copyFiles(configuration);
@@ -20,6 +19,7 @@ export default async function (configuration, imageChanged) {
{ repoId: id, branch, deployId, organization, name, domain },
{ repoId: id, branch, deployId, organization, name, domain, progress: 'done' }
);
await updateServiceLabels(configuration);
} catch (error) {
await Deployment.findOneAndUpdate(

View File

@@ -9,7 +9,7 @@ export function execShellAsync(cmd, opts = {}) {
shell.config.silent = true;
shell.exec(cmd, opts, async function (code, stdout, stderr) {
if (code !== 0) {
await saveServerLog({ message: JSON.stringify({ cmd, opts, code, stdout, stderr }) })
await saveServerLog({ message: JSON.stringify({ cmd, opts, code, stdout, stderr }) });
return reject(new Error(stderr));
}
return resolve(stdout);

View File

@@ -1 +1,2 @@
export const publicPages = ['/', '/api/v1/login/github/app', '/api/v1/webhooks/deploy', '/success'];
export const publicPages = ['/', '/api/v1/login/github/app', '/api/v1/webhooks/deploy', '/success', '/api/v1/login/email']
export const VITE_GITHUB_APP_NAME = import.meta.env.VITE_GITHUB_APP_NAME

View File

@@ -63,7 +63,6 @@ export async function request(
} else {
if (response.headers.get('content-disposition')) {
const blob = await response.blob();
console.log(blob);
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = response.headers.get('content-disposition').split('=')[1] || 'backup.gz';

View File

@@ -8,4 +8,5 @@ const ApplicationLogsSchema = new Schema({
ApplicationLogsSchema.set('timestamps', true);
export default mongoose.models['logs-application'] || mongoose.model('logs-application', ApplicationLogsSchema);
export default mongoose.models['logs-application'] ||
mongoose.model('logs-application', ApplicationLogsSchema);

View File

@@ -13,12 +13,14 @@ const ConfigurationSchema = new Schema({
id: { type: Number, required: true },
organization: { type: String, required: true },
name: { type: String, required: true },
branch: { type: String, required: true },
branch: { type: String, required: true }
},
general: {
deployId: { type: String, required: true },
nickname: { type: String, required: true },
workdir: { type: String, required: true },
isPreviewDeploymentEnabled: { type: Boolean, required: true, default: false },
pullRequest: { type: Number, required: true, default: 0 }
},
build: {
pack: { type: String, required: true },
@@ -29,25 +31,25 @@ const ConfigurationSchema = new Schema({
start: { type: String },
python: {
module: { type: String },
instance: { type: String },
instance: { type: String }
}
},
container: {
name: { type: String, required: true },
tag: { type: String, required: true },
baseSHA: { type: String, required: true },
},
baseSHA: { type: String, required: true }
}
},
publish: {
directory: { type: String },
domain: { type: String, required: true },
path: { type: String },
port: { type: Number },
secrets: { type: Array },
secrets: { type: Array }
}
});
ConfigurationSchema.set('timestamps', true);
export default mongoose.models['configuration'] || mongoose.model('configuration', ConfigurationSchema);
export default mongoose.models['configuration'] ||
mongoose.model('configuration', ConfigurationSchema);

View File

@@ -1,5 +1,5 @@
import mongoose from 'mongoose';
import { version } from '../../package.json'
import { version } from '../../package.json';
const { Schema, Document } = mongoose;
// export interface ILogsServer extends Document {

View File

@@ -4,12 +4,16 @@ export interface IUser extends Document {
email: string;
avatar?: string;
uid: string;
type: string;
password: string;
}
const UserSchema = new Schema({
email: { type: String, required: true, unique: true },
avatar: { type: String },
uid: { type: String, required: true }
uid: { type: String, required: true },
type: { type: String, required: true, default: 'github' },
password: { type: String }
});
UserSchema.set('timestamps', true);

View File

@@ -23,7 +23,6 @@
}
return {};
}
</script>
<script lang="ts">
@@ -37,8 +36,9 @@
import Tooltip from '$components/Tooltip.svelte';
import compareVersions from 'compare-versions';
import packageJson from '../../package.json';
import { dashboard } from '$store';
import { dashboard, settings } from '$store';
import { browser } from '$app/env';
$settings.clientId = import.meta.env.VITE_GITHUB_APP_CLIENTID !== 'null' ? import.meta.env.VITE_GITHUB_APP_CLIENTID : null
$dashboard = initDashboard;
const branch =
process.env.NODE_ENV === 'production' &&
@@ -53,12 +53,13 @@
let upgradeDisabled = false;
let upgradeDone = false;
let showAck = false;
let globalFeatureFlag = browser && localStorage.getItem('globalFeatureFlag');
const options = {
duration: 2000
};
onMount(async () => {
upgradeAvailable = await checkUpgrade();
browser && localStorage.removeItem('token')
browser && localStorage.removeItem('token');
if (!localStorage.getItem('automaticErrorReportsAck')) {
showAck = true;
if (latest?.coolify[branch]?.settings?.sendErrors) {
@@ -103,7 +104,6 @@
localStorage.setItem('automaticErrorReportsAck', 'true');
showAck = false;
}
</script>
<SvelteToast {options} />
@@ -135,69 +135,136 @@
class:border-purple-500={$page.path === '/dashboard/databases'}
>
<div class="w-10 pt-4 pb-4"><img src="/favicon.png" alt="coolLabs logo" /></div>
<Tooltip position="right" label="Applications">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-green-500 mt-4 transition-all duration-100 cursor-pointer"
on:click={() => goto('/dashboard/applications')}
class:text-green-500={$page.path === '/dashboard/applications' ||
$page.path.startsWith('/application')}
class:bg-warmGray-700={$page.path === '/dashboard/applications' ||
$page.path.startsWith('/application')}
>
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><rect x="4" y="4" width="16" height="16" rx="2" ry="2" /><rect
x="9"
y="9"
width="6"
height="6"
/><line x1="9" y1="1" x2="9" y2="4" /><line x1="15" y1="1" x2="15" y2="4" /><line
x1="9"
y1="20"
x2="9"
y2="23"
/><line x1="15" y1="20" x2="15" y2="23" /><line x1="20" y1="9" x2="23" y2="9" /><line
x1="20"
y1="14"
x2="23"
y2="14"
/><line x1="1" y1="9" x2="4" y2="9" /><line x1="1" y1="14" x2="4" y2="14" /></svg
{#if $settings.clientId}
<Tooltip position="right" label="Applications">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-green-500 mt-4 transition-all duration-100 cursor-pointer"
on:click={() => goto('/dashboard/applications')}
class:text-green-500={$page.path === '/dashboard/applications' ||
$page.path.startsWith('/application')}
class:bg-warmGray-700={$page.path === '/dashboard/applications' ||
$page.path.startsWith('/application')}
>
</div>
</Tooltip>
<Tooltip position="right" label="Databases">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-purple-500 my-4 transition-all duration-100 cursor-pointer"
on:click={() => goto('/dashboard/databases')}
class:text-purple-500={$page.path === '/dashboard/databases' ||
$page.path.startsWith('/database')}
class:bg-warmGray-700={$page.path === '/dashboard/databases' ||
$page.path.startsWith('/database')}
>
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><rect x="4" y="4" width="16" height="16" rx="2" ry="2" /><rect
x="9"
y="9"
width="6"
height="6"
/><line x1="9" y1="1" x2="9" y2="4" /><line x1="15" y1="1" x2="15" y2="4" /><line
x1="9"
y1="20"
x2="9"
y2="23"
/><line x1="15" y1="20" x2="15" y2="23" /><line
x1="20"
y1="9"
x2="23"
y2="9"
/><line x1="20" y1="14" x2="23" y2="14" /><line x1="1" y1="9" x2="4" y2="9" /><line
x1="1"
y1="14"
x2="4"
y2="14"
/></svg
>
</div>
</Tooltip>
<Tooltip position="right" label="Databases">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-purple-500 my-4 transition-all duration-100 cursor-pointer"
on:click={() => goto('/dashboard/databases')}
class:text-purple-500={$page.path === '/dashboard/databases' ||
$page.path.startsWith('/database')}
class:bg-warmGray-700={$page.path === '/dashboard/databases' ||
$page.path.startsWith('/database')}
>
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"
/>
</svg>
</div>
</Tooltip>
{:else}
<Tooltip
position="right"
label="Applications disabled, no GitHub Integration detected"
size="large"
>
<div class="p-2 text-warmGray-700 mt-4 transition-all duration-100 cursor-pointer">
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"
/>
</svg>
</div>
</Tooltip>
stroke-linecap="round"
stroke-linejoin="round"
><rect x="4" y="4" width="16" height="16" rx="2" ry="2" /><rect
x="9"
y="9"
width="6"
height="6"
/><line x1="9" y1="1" x2="9" y2="4" /><line x1="15" y1="1" x2="15" y2="4" /><line
x1="9"
y1="20"
x2="9"
y2="23"
/><line x1="15" y1="20" x2="15" y2="23" /><line
x1="20"
y1="9"
x2="23"
y2="9"
/><line x1="20" y1="14" x2="23" y2="14" /><line x1="1" y1="9" x2="4" y2="9" /><line
x1="1"
y1="14"
x2="4"
y2="14"
/></svg
>
</div>
</Tooltip>
<Tooltip position="right" label="Databases disabled, no GitHub Integration detected" size="large">
<div
class="p-2 text-warmGray-700 my-4 transition-all duration-100 cursor-pointer"
>
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"
/>
</svg>
</div>
</Tooltip>
{/if}
<Tooltip position="right" label="Services">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-blue-500 transition-all duration-100 cursor-pointer"
@@ -224,6 +291,31 @@
</div>
</Tooltip>
<div class="flex-1" />
{#if globalFeatureFlag}
<Tooltip position="right" label="Servers">
<div
class="p-2 hover:bg-warmGray-700 rounded hover:text-red-500 mb-4 transition-all duration-100 cursor-pointer"
on:click={() => goto('/servers')}
class:text-red-500={$page.path === '/servers' || $page.path.startsWith('/servers')}
class:bg-warmGray-700={$page.path === '/servers' || $page.path.startsWith('/servers')}
>
<svg
class="w-8"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"
/>
</svg>
</div>
</Tooltip>
{/if}
<Tooltip position="right" label="Settings">
<button
class="p-2 hover:bg-warmGray-700 rounded hover:text-yellow-500 transition-all duration-100 cursor-pointer"
@@ -287,7 +379,7 @@
</main>
{#if upgradeAvailable && $page.path !== '/success' && $page.path !== '/'}
<footer
class="fixed bottom-0 right-0 p-4 px-6 w-auto rounded-tl text-white hover:scale-110 transform transition duration-100"
class="fixed bottom-0 right-0 p-4 px-6 w-auto rounded-tl text-white hover:scale-110 transition duration-100"
>
<div class="flex items-center">
<div />
@@ -306,7 +398,7 @@
>
{:else}
<button
class="opacity-50 tracking-tight font-bold text-xs rounded px-2 cursor-not-allowed"
class="opacity-50 tracking-tight font-bold text-xs rounded px-2 cursor-not-allowed"
disabled={upgradeDisabled}>Upgrading. It could take a while, please wait...</button
>
{/if}

View File

@@ -1,32 +1,18 @@
import { setDefaultConfiguration } from '$lib/api/applications/configuration';
import { saveServerLog } from '$lib/api/applications/logging';
import { docker } from '$lib/api/docker';
import Configuration from '$models/Configuration';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
try {
const { DOMAIN } = process.env;
const configuration = setDefaultConfiguration(request.body);
const services = (await docker.engine.listServices()).filter(
(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application'
);
let foundDomain = false;
for (const service of services) {
const running = JSON.parse(service.Spec.Labels.configuration);
if (running) {
if (
running.publish.domain === configuration.publish.domain &&
running.repository.id !== configuration.repository.id &&
running.publish.path === configuration.publish.path
) {
foundDomain = true;
}
}
}
if (DOMAIN === configuration.publish.domain) foundDomain = true;
if (foundDomain) {
const configurationFound = await Configuration.find({
'repository.id': { $ne: configuration.repository.id },
'publish.domain': configuration.publish.domain
}).select('-_id -__v -createdAt -updatedAt');
if (configurationFound.length > 0 || configuration.publish.domain === DOMAIN) {
return {
status: 200,
body: {

View File

@@ -5,17 +5,17 @@ import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
const { name, organization, branch }: any = request.body || {};
if (name && organization && branch) {
const configurationFound = await Configuration.findOne({
const configurationFound = await Configuration.find({
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch,
}).lean()
'repository.branch': branch
}).select('-_id -__v -createdAt -updatedAt');
if (configurationFound) {
return {
status: 200,
body: {
success: true,
...configurationFound
configuration: [...configurationFound]
}
};
}
@@ -46,6 +46,7 @@ export async function post(request: Request) {
}
return null;
});
if (found) {
return {
status: 200,

View File

@@ -0,0 +1,75 @@
import { updateServiceLabels } from '$lib/api/applications/configuration';
import { execShellAsync } from '$lib/api/common';
import { docker } from '$lib/api/docker';
import ApplicationLog from '$models/ApplicationLog';
import Configuration from '$models/Configuration';
import Deployment from '$models/Deployment';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
const { name, organization, branch, isPreviewDeploymentEnabled }: any = request.body || {};
if (name && organization && branch) {
const configuration = await Configuration.findOneAndUpdate(
{
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch
},
{
$set: {
'general.isPreviewDeploymentEnabled': isPreviewDeploymentEnabled,
'general.pullRequest': 0
}
},
{ new: true }
).select('-_id -__v -createdAt -updatedAt');
if (!isPreviewDeploymentEnabled) {
const found = await Configuration.find({
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch,
'general.pullRequest': { $ne: 0 }
});
for (const prDeployment of found) {
await Configuration.findOneAndRemove({
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch,
'publish.domain': prDeployment.publish.domain
});
const deploys = await Deployment.find({
organization,
branch,
name,
domain: prDeployment.publish.domain
});
for (const deploy of deploys) {
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
await Deployment.deleteMany({ deployId: deploy.deployId });
}
await execShellAsync(`docker stack rm ${prDeployment.build.container.name}`);
}
return {
status: 200,
body: {
organization,
name,
branch
}
};
}
updateServiceLabels(configuration);
return {
status: 200,
body: {
success: true
}
};
}
return {
status: 500,
body: {
error: 'Cannot save.'
}
};
}

View File

@@ -1,32 +1,26 @@
import type { Request } from '@sveltejs/kit';
import Deployment from '$models/Deployment';
import { docker } from '$lib/api/docker';
import { precheckDeployment, setDefaultConfiguration } from '$lib/api/applications/configuration';
import cloneRepository from '$lib/api/applications/cloneRepository';
import { cleanupTmp } from '$lib/api/common';
import queueAndBuild from '$lib/api/applications/queueAndBuild';
import Configuration from '$models/Configuration';
export async function post(request: Request) {
let configuration;
try {
const services = (await docker.engine.listServices()).filter(
(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application'
);
configuration = setDefaultConfiguration(request.body);
if (!configuration) {
return {
status: 500,
body: {
error: 'Whaaat?'
}
};
}
export async function post(request: Request) {
const configuration = setDefaultConfiguration(request.body);
if (!configuration) {
return {
status: 500,
body: {
error: 'Whaaat?'
}
};
}
try {
await cloneRepository(configuration);
const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment({
services,
const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment(
configuration
});
);
if (foundService && !forceUpdate && !imageChanged && !configChanged) {
cleanupTmp(configuration.general.workdir);
return {
@@ -56,7 +50,8 @@ export async function post(request: Request) {
}
const { id, organization, name, branch } = configuration.repository;
const { domain } = configuration.publish;
const { deployId, nickname } = configuration.general;
const { deployId, nickname, pullRequest } = configuration.general;
await new Deployment({
repoId: id,
branch,
@@ -66,18 +61,22 @@ export async function post(request: Request) {
name,
nickname
}).save();
await Configuration.findOneAndUpdate({
'repository.id': id,
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
},
await Configuration.findOneAndUpdate(
{
'repository.id': id,
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
'general.pullRequest': { $in: [null, 0] }
},
{ ...configuration },
{ upsert: true, new: true })
{ upsert: true, new: true }
);
queueAndBuild(configuration, imageChanged);
return {
status: 200,
status: 201,
body: {
message: 'Deployment queued.',
nickname: configuration.general.nickname,
@@ -86,6 +85,7 @@ export async function post(request: Request) {
}
};
} catch (error) {
console.log(error);
await Deployment.findOneAndUpdate(
{
repoId: configuration.repository.id,

View File

@@ -10,10 +10,7 @@ export async function get(request: Request) {
.select('-_id -__v')
.sort({ createdAt: 'asc' });
const deploy: any = await Deployment.findOne({ deployId })
.select('-_id -__v')
.sort({ createdAt: 'desc' });
const deploy: any = await Deployment.findOne({ deployId }).select('-_id -__v');
const finalLogs: any = {};
finalLogs.progress = deploy.progress;
finalLogs.events = logs.map((log) => log.event);

View File

@@ -16,12 +16,12 @@ export async function get(request: Request) {
.select('-_id -__v -repoId')
.sort({ createdAt: 'desc' })
.limit(show);
const finalLogs = deploy.map((d) => {
const finalLogs = { ...d._doc };
const updatedAt = dayjs(d.updatedAt).utc();
finalLogs.took = updatedAt.diff(dayjs(d.createdAt)) / 1000;
finalLogs.since = updatedAt.fromNow();
finalLogs.isPr = d.domain.startsWith('pr');
return finalLogs;
});
return {

View File

@@ -16,7 +16,7 @@ export async function get(request: Request) {
body: { success: true, logs }
};
} catch (error) {
console.log(error)
console.log(error);
await saveServerLog(error);
return {
status: 500,

View File

@@ -1,61 +1,69 @@
import { purgeImagesContainers } from '$lib/api/applications/cleanup';
import { docker } from '$lib/api/docker';
import Deployment from '$models/Deployment';
import ApplicationLog from '$models/ApplicationLog';
import { delay, execShellAsync } from '$lib/api/common';
import Configuration from '$models/Configuration';
async function call(found) {
async function purgeImagesAsync(found) {
await delay(10000);
await purgeImagesContainers(found, true);
}
export async function post(request: Request) {
const { organization, name, branch } = request.body;
let found = false;
const { organization, name, branch, domain } = request.body;
try {
(await docker.engine.listServices())
.filter((r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
.map((s) => {
const running = JSON.parse(s.Spec.Labels.configuration);
if (
running.repository.organization === organization &&
running.repository.name === name &&
running.repository.branch === branch
) {
found = running;
const configurationFound = await Configuration.findOne({
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
'publish.domain': domain
});
if (configurationFound) {
const id = configurationFound._id;
if (configurationFound?.general?.pullRequest === 0) {
// Main deployment deletion request; deleting main + PRs
const allConfiguration = await Configuration.find({
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch
});
for (const config of allConfiguration) {
await Configuration.findOneAndRemove({
'repository.name': config.repository.name,
'repository.organization': config.repository.organization,
'repository.branch': config.repository.branch
});
await execShellAsync(`docker stack rm ${config.build.container.name}`);
}
return null;
});
if (found) {
await Configuration.findOneAndRemove({
'repository.name': name,
'repository.organization': organization,
'repository.branch': branch,
})
const deploys = await Deployment.find({ organization, branch, name });
for (const deploy of deploys) {
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
await Deployment.deleteMany({ deployId: deploy.deployId });
const deploys = await Deployment.find({ organization, branch, name });
for (const deploy of deploys) {
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
await Deployment.deleteMany({ deployId: deploy.deployId });
}
purgeImagesAsync(configurationFound);
} else {
// Delete only PRs
await Configuration.findByIdAndRemove(id);
await execShellAsync(`docker stack rm ${configurationFound.build.container.name}`);
const deploys = await Deployment.find({ organization, branch, name, domain });
for (const deploy of deploys) {
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
await Deployment.deleteMany({ deployId: deploy.deployId });
}
purgeImagesAsync(configurationFound);
}
await execShellAsync(`docker stack rm ${found.build.container.name}`);
call(found);
return {
status: 200,
body: {
organization,
name,
branch
}
};
} else {
return {
status: 500,
error: {
message: 'Nothing to do.'
}
};
}
return {
status: 200,
body: {
organization,
name,
branch
}
};
} catch (error) {
console.log(error);
return {
status: 500,
error: {

View File

@@ -1,14 +1,9 @@
import { docker } from '$lib/api/docker';
import type { Request } from '@sveltejs/kit';
import Configuration from '$models/Configuration';
export async function get(request: Request) {
// Should update this to get data from mongodb and update db with the currently running services on start!
const dockerServices = await docker.engine.listServices();
let applications: any = dockerServices.filter(
(r) =>
r.Spec.Labels.managedBy === 'coolify' &&
r.Spec.Labels.type === 'application' &&
r.Spec.Labels.configuration
);
let databases: any = dockerServices.filter(
(r) =>
r.Spec.Labels.managedBy === 'coolify' &&
@@ -21,15 +16,6 @@ export async function get(request: Request) {
r.Spec.Labels.type === 'service' &&
r.Spec.Labels.configuration
);
applications = applications.map((r) => {
if (JSON.parse(r.Spec.Labels.configuration)) {
return {
configuration: JSON.parse(r.Spec.Labels.configuration),
UpdatedAt: r.UpdatedAt
};
}
return {};
});
databases = databases.map((r) => {
if (JSON.parse(r.Spec.Labels.configuration)) {
return {
@@ -47,14 +33,23 @@ export async function get(request: Request) {
}
return {};
});
applications = [
...new Map(
applications.map((item) => [
item.configuration.publish.domain + item.configuration.publish.path,
item
])
).values()
];
const configurations = await Configuration.find({
'general.pullRequest': { $in: [null, 0] }
}).select('-_id -__v -createdAt');
const applications = [];
for (const configuration of configurations) {
const foundPRDeployments = await Configuration.find({
'repository.id': configuration.repository.id,
'repository.branch': configuration.repository.branch,
'general.pullRequest': { $ne: 0 }
}).select('-_id -__v -createdAt');
const payload = {
configuration,
UpdatedAt: configuration.updatedAt,
prBuilds: foundPRDeployments.length > 0 ? true : false
};
applications.push(payload);
}
return {
status: 200,
body: {

View File

@@ -0,0 +1,105 @@
import mongoose from 'mongoose';
import Settings from '$models/Settings';
import User from '$models/User';
import bcrypt from 'bcrypt';
import cuid from 'cuid';
import jsonwebtoken from 'jsonwebtoken';
import type { Request } from '@sveltejs/kit';
const saltRounds = 15;
export async function post(request: Request) {
const { email, password } = request.body
const { JWT_SIGN_KEY } = process.env;
const settings = await Settings.findOne({ applicationName: 'coolify' });
const registeredUsers = await User.find().countDocuments();
const foundUser = await User.findOne({ email });
try {
let uid = cuid();
if (foundUser) {
if (foundUser.type === 'github') {
return {
status: 500,
body: {
error: 'Wrong password or email address.'
}
};
}
uid = foundUser.uid;
if (!await bcrypt.compare(password, foundUser.password)) {
return {
status: 500,
body: {
error: 'Wrong password or email address.'
}
};
}
} else {
if (registeredUsers === 0) {
const newUser = new User({
_id: new mongoose.Types.ObjectId(),
email,
uid,
type: 'email',
password: await bcrypt.hash(password, saltRounds)
});
const defaultSettings = new Settings({
_id: new mongoose.Types.ObjectId()
});
try {
await newUser.save();
await defaultSettings.save();
} catch (error) {
return {
status: 500,
error: error.message || error
};
}
} else {
if (!settings?.allowRegistration) {
return {
status: 500,
body: {
error: 'Registration disabled, enable it in settings.'
}
};
} else {
const newUser = new User({
_id: new mongoose.Types.ObjectId(),
email,
uid,
type: 'email',
password: await bcrypt.hash(password, saltRounds)
});
try {
await newUser.save();
} catch (error) {
return {
status: 500,
error: error.message || error
};
}
}
}
}
const coolToken = jsonwebtoken.sign({}, JWT_SIGN_KEY, {
expiresIn: 15778800,
algorithm: 'HS256',
audience: 'coolLabs',
issuer: 'coolLabs',
jwtid: uid,
subject: `User:${uid}`,
notBefore: -1000
});
request.locals.session.data = { coolToken, ghToken: null };
return {
status: 200,
body: {
message: "Successfully logged in."
}
};
} catch (error) {
return { status: 500, body: { error: error.message || error } };
}
}

View File

@@ -33,7 +33,8 @@ export async function get(request: Request) {
_id: new mongoose.Types.ObjectId(),
email,
avatar: avatar_url,
uid
uid,
type: 'github'
});
const defaultSettings = new Settings({
_id: new mongoose.Types.ObjectId()
@@ -68,7 +69,8 @@ export async function get(request: Request) {
_id: new mongoose.Types.ObjectId(),
email,
avatar: avatar_url,
uid
uid,
type: 'github'
});
try {
await newUser.save();

View File

@@ -0,0 +1,25 @@
import { saveServerLog } from '$lib/api/applications/logging';
import { execShellAsync } from '$lib/api/common';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
try {
const output = await execShellAsync('docker builder prune -af')
return {
status: 200,
body: {
message: 'OK',
output: output.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split('\n').pop()
}
}
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}

View File

@@ -0,0 +1,25 @@
import { saveServerLog } from '$lib/api/applications/logging';
import { execShellAsync } from '$lib/api/common';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
try {
const output = await execShellAsync('docker container prune -f')
return {
status: 200,
body: {
message: 'OK',
output: output.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split('\n').pop()
}
}
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}

View File

@@ -0,0 +1,25 @@
import { saveServerLog } from '$lib/api/applications/logging';
import { execShellAsync } from '$lib/api/common';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
try {
const output = await execShellAsync('docker image prune -af')
return {
status: 200,
body: {
message: 'OK',
output: output.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split('\n').pop()
}
}
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}

View File

@@ -0,0 +1,25 @@
import { saveServerLog } from '$lib/api/applications/logging';
import { execShellAsync } from '$lib/api/common';
import type { Request } from '@sveltejs/kit';
export async function post(request: Request) {
try {
const output = await execShellAsync('docker volume prune -f')
return {
status: 200,
body: {
message: 'OK',
output: output.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split('\n').pop()
}
}
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}

View File

@@ -0,0 +1,34 @@
import { saveServerLog } from '$lib/api/applications/logging';
import { execShellAsync } from '$lib/api/common';
import { docker } from '$lib/api/docker';
import type { Request } from '@sveltejs/kit';
import systeminformation from 'systeminformation'
export async function get(request: Request) {
try {
const df = await execShellAsync(
`docker system df --format '{{ json . }}'`
);
const dockerReclaimable = df
.split('\n')
.filter((n) => n)
.map((s) => JSON.parse(s))
return {
status: 200,
body: {
hostname: await (await systeminformation.osInfo()).hostname,
filesystems: await (await systeminformation.fsSize()).filter(fs => !fs.fs.match('/dev/loop') || !fs.fs.match('/var/lib/docker/')),
dockerReclaimable
}
}
} catch (error) {
await saveServerLog(error);
return {
status: 500,
body: {
error: error.message || error
}
};
}
}

View File

@@ -4,6 +4,7 @@ import type { Request } from '@sveltejs/kit';
export async function get(request: Request) {
const { serviceName } = request.params;
try {
const service = (await docker.engine.listServices()).find(
(r) =>

View File

@@ -0,0 +1,74 @@
import type { Request } from '@sveltejs/kit';
import yaml from 'js-yaml';
import { promises as fs } from 'fs';
import { docker } from '$lib/api/docker';
import { baseServiceConfiguration } from '$lib/api/applications/common';
import { cleanupTmp, execShellAsync } from '$lib/api/common';
export async function post(request: Request) {
let { baseURL } = request.body;
const traefikURL = baseURL;
baseURL = `https://${baseURL}`;
const workdir = '/tmp/code-server';
const deployId = 'code-server';
// const environment = [
// { name: 'DOCKER_USER', value: 'root' }
// ];
// const generateEnvsCodeServer = {};
// for (const env of environment) generateEnvsCodeServer[env.name] = env.value;
const stack = {
version: '3.8',
services: {
[deployId]: {
image: 'codercom/code-server',
command: 'code-server --disable-telemetry',
networks: [`${docker.network}`],
volumes: [`${deployId}-code-server-data:/home/coder`],
// environment: generateEnvsCodeServer,
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=code-server',
'configuration=' +
JSON.stringify({
baseURL
}),
'traefik.enable=true',
'traefik.http.services.' + deployId + '.loadbalancer.server.port=8080',
'traefik.http.routers.' + deployId + '.entrypoints=websecure',
'traefik.http.routers.' +
deployId +
'.rule=Host(`' +
traefikURL +
'`) && PathPrefix(`/`)',
'traefik.http.routers.' + deployId + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + deployId + '.middlewares=global-compress'
]
}
}
},
networks: {
[`${docker.network}`]: {
external: true
}
},
volumes: {
[`${deployId}-code-server-data`]: {
external: true
},
},
};
await execShellAsync(`mkdir -p ${workdir}`);
await fs.writeFile(`${workdir}/stack.yml`, yaml.dump(stack));
await execShellAsync('docker stack rm code-server');
await execShellAsync(`cat ${workdir}/stack.yml | docker stack deploy --prune -c - ${deployId}`);
cleanupTmp(workdir);
return {
status: 200,
body: { message: 'OK' }
};
}

View File

@@ -0,0 +1,25 @@
import { execShellAsync } from '$lib/api/common';
import type { Request } from '@sveltejs/kit';
import yaml from "js-yaml"
export async function get(request: Request) {
// const { POSTGRESQL_USERNAME, POSTGRESQL_PASSWORD, POSTGRESQL_DATABASE } = JSON.parse(
// JSON.parse(
// await execShellAsync(
// "docker service inspect code-server_code-server --format='{{json .Spec.Labels.configuration}}'"
// )
// )
// ).generateEnvsPostgres;
const containers = (await execShellAsync("docker ps -a --format='{{json .Names}}'"))
.replace(/"/g, '')
.trim()
.split('\n');
const codeServer = containers.find((container) => container.startsWith('code-server'));
const configYaml = yaml.load(await execShellAsync(
`docker exec ${codeServer} cat /home/coder/.config/code-server/config.yaml`
))
return {
status: 200,
body: { message: 'OK', password: configYaml.password }
};
}

View File

@@ -0,0 +1,77 @@
import type { Request } from '@sveltejs/kit';
import yaml from 'js-yaml';
import generator from 'generate-password';
import { promises as fs } from 'fs';
import { docker } from '$lib/api/docker';
import { baseServiceConfiguration } from '$lib/api/applications/common';
import { cleanupTmp, execShellAsync } from '$lib/api/common';
export async function post(request: Request) {
let { baseURL } = request.body;
const traefikURL = baseURL;
baseURL = `https://${baseURL}`;
const workdir = '/tmp/minio';
const deployId = 'minio';
const secrets = [
{ name: 'MINIO_ROOT_USER', value: generator.generate({ length: 12, numbers: true, strict: true }) },
{ name: 'MINIO_ROOT_PASSWORD', value: generator.generate({ length: 24, numbers: true, strict: true }) }
];
const generateEnvsMinIO = {};
for (const secret of secrets) generateEnvsMinIO[secret.name] = secret.value;
const stack = {
version: '3.8',
services: {
[deployId]: {
image: 'minio/minio',
command: 'server /data',
networks: [`${docker.network}`],
environment: generateEnvsMinIO,
volumes: [`${deployId}-minio-data:/data`],
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=minio',
'configuration=' +
JSON.stringify({
baseURL,
generateEnvsMinIO
}),
'traefik.enable=true',
'traefik.http.services.' + deployId + '.loadbalancer.server.port=9000',
'traefik.http.routers.' + deployId + '.entrypoints=websecure',
'traefik.http.routers.' +
deployId +
'.rule=Host(`' +
traefikURL +
'`) && PathPrefix(`/`)',
'traefik.http.routers.' + deployId + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + deployId + '.middlewares=global-compress'
]
}
}
},
networks: {
[`${docker.network}`]: {
external: true
}
},
volumes: {
[`${deployId}-minio-data`]: {
external: true
},
},
};
await execShellAsync(`mkdir -p ${workdir}`);
await fs.writeFile(`${workdir}/stack.yml`, yaml.dump(stack));
await execShellAsync('docker stack rm minio');
await execShellAsync(`cat ${workdir}/stack.yml | docker stack deploy --prune -c - ${deployId}`);
cleanupTmp(workdir);
return {
status: 200,
body: { message: 'OK' }
};
}

View File

@@ -0,0 +1,59 @@
import type { Request } from '@sveltejs/kit';
import yaml from 'js-yaml';
import { promises as fs } from 'fs';
import { docker } from '$lib/api/docker';
import { baseServiceConfiguration } from '$lib/api/applications/common';
import { cleanupTmp, execShellAsync } from '$lib/api/common';
export async function post(request: Request) {
let { baseURL } = request.body;
const traefikURL = baseURL;
baseURL = `https://${baseURL}`;
const workdir = '/tmp/nocodb';
const deployId = 'nocodb';
const stack = {
version: '3.8',
services: {
[deployId]: {
image: 'nocodb/nocodb',
networks: [`${docker.network}`],
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=nocodb',
'configuration=' +
JSON.stringify({
baseURL
}),
'traefik.enable=true',
'traefik.http.services.' + deployId + '.loadbalancer.server.port=8080',
'traefik.http.routers.' + deployId + '.entrypoints=websecure',
'traefik.http.routers.' +
deployId +
'.rule=Host(`' +
traefikURL +
'`) && PathPrefix(`/`)',
'traefik.http.routers.' + deployId + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + deployId + '.middlewares=global-compress'
]
}
}
},
networks: {
[`${docker.network}`]: {
external: true
}
}
};
await execShellAsync(`mkdir -p ${workdir}`);
await fs.writeFile(`${workdir}/stack.yml`, yaml.dump(stack));
await execShellAsync('docker stack rm nocodb');
await execShellAsync(`cat ${workdir}/stack.yml | docker stack deploy --prune -c - ${deployId}`);
cleanupTmp(workdir);
return {
status: 200,
body: { message: 'OK' }
};
}

View File

@@ -0,0 +1,172 @@
import type { Request } from '@sveltejs/kit';
import yaml from 'js-yaml';
import generator from 'generate-password';
import { promises as fs } from 'fs';
import { docker } from '$lib/api/docker';
import { baseServiceConfiguration } from '$lib/api/applications/common';
import { cleanupTmp, execShellAsync } from '$lib/api/common';
export async function post(request: Request) {
let { baseURL, remoteDB, database, wordpressExtraConfiguration } = request.body;
const traefikURL = baseURL;
baseURL = `https://${baseURL}`;
console.log({ baseURL, remoteDB, database, wordpressExtraConfiguration })
const workdir = '/tmp/wordpress';
const deployId = `wp-${generator.generate({ length: 5, numbers: true, strict: true })}`
const defaultDatabaseName = generator.generate({ length: 12, numbers: true, strict: true })
const defaultDatabaseHost = `${deployId}-mysql`
const defaultDatabaseUser = generator.generate({ length: 12, numbers: true, strict: true })
const defaultDatabasePassword = generator.generate({ length: 24, numbers: true, strict: true })
const defaultDatabaseRootPassword = generator.generate({ length: 24, numbers: true, strict: true })
const defaultDatabaseRootUser = generator.generate({ length: 12, numbers: true, strict: true })
let secrets = [
{ name: 'WORDPRESS_DB_HOST', value: defaultDatabaseHost },
{ name: 'WORDPRESS_DB_USER', value: defaultDatabaseUser },
{ name: 'WORDPRESS_DB_PASSWORD', value: defaultDatabasePassword },
{ name: 'WORDPRESS_DB_NAME', value: defaultDatabaseName },
{ name: 'WORDPRESS_CONFIG_EXTRA', value: wordpressExtraConfiguration }
];
const generateEnvsMySQL = {
MYSQL_ROOT_PASSWORD: defaultDatabaseRootPassword,
MYSQL_ROOT_USER: defaultDatabaseRootUser,
MYSQL_USER: defaultDatabaseUser,
MYSQL_PASSWORD: defaultDatabasePassword,
MYSQL_DATABASE: defaultDatabaseName
};
const image = 'bitnami/mysql:8.0';
const volume = `${deployId}-mysql-data:/bitnami/mysql/data`;
if (remoteDB) {
secrets = [
{ name: 'WORDPRESS_DB_HOST', value: database.host },
{ name: 'WORDPRESS_DB_USER', value: database.user },
{ name: 'WORDPRESS_DB_PASSWORD', value: database.password },
{ name: 'WORDPRESS_DB_NAME', value: database.name },
{ name: 'WORDPRESS_TABLE_PREFIX', value: database.tablePrefix },
{ name: 'WORDPRESS_CONFIG_EXTRA', value: wordpressExtraConfiguration }
]
}
const generateEnvsWordpress = {};
for (const secret of secrets) generateEnvsWordpress[secret.name] = secret.value;
let stack = {
version: '3.8',
services: {
[deployId]: {
image: 'wordpress',
networks: [`${docker.network}`],
environment: generateEnvsWordpress,
volumes: [`${deployId}-wordpress-data:/var/www/html`],
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=' + deployId,
'configuration=' +
JSON.stringify({
deployId,
baseURL,
generateEnvsWordpress
}),
'traefik.enable=true',
'traefik.http.services.' + deployId + '.loadbalancer.server.port=80',
'traefik.http.routers.' + deployId + '.entrypoints=websecure',
'traefik.http.routers.' +
deployId +
'.rule=Host(`' +
traefikURL +
'`) && PathPrefix(`/`)',
'traefik.http.routers.' + deployId + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + deployId + '.middlewares=global-compress'
]
}
},
[`${deployId}-mysql`]: {
image,
networks: [`${docker.network}`],
environment: generateEnvsMySQL,
volumes: [volume],
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=' + deployId,
]
}
}
},
networks: {
[`${docker.network}`]: {
external: true
}
},
volumes: {
[`${deployId}-wordpress-data`]: {
external: true
},
[`${deployId}-mysql-data`]: {
external: true
}
},
};
if (remoteDB) {
stack = {
version: '3.8',
services: {
[deployId]: {
image: 'wordpress',
networks: [`${docker.network}`],
environment: generateEnvsWordpress,
volumes: [`${deployId}-wordpress-data:/var/www/html`],
deploy: {
...baseServiceConfiguration,
labels: [
'managedBy=coolify',
'type=service',
'serviceName=' + deployId,
'configuration=' +
JSON.stringify({
deployId,
baseURL,
generateEnvsWordpress
}),
'traefik.enable=true',
'traefik.http.services.' + deployId + '.loadbalancer.server.port=80',
'traefik.http.routers.' + deployId + '.entrypoints=websecure',
'traefik.http.routers.' +
deployId +
'.rule=Host(`' +
traefikURL +
'`) && PathPrefix(`/`)',
'traefik.http.routers.' + deployId + '.tls.certresolver=letsencrypt',
'traefik.http.routers.' + deployId + '.middlewares=global-compress'
]
}
}
},
networks: {
[`${docker.network}`]: {
external: true
}
},
volumes: {
[`${deployId}-wordpress-data`]: {
external: true
}
},
};
}
await execShellAsync(`mkdir -p ${workdir}`);
await fs.writeFile(`${workdir}/stack.yml`, yaml.dump(stack));
await execShellAsync(`docker stack rm ${deployId}`);
await execShellAsync(`cat ${workdir}/stack.yml | docker stack deploy --prune -c - ${deployId}`);
cleanupTmp(workdir);
return {
status: 200,
body: { message: 'OK' }
};
}

View File

@@ -4,10 +4,16 @@ import Deployment from '$models/Deployment';
import { docker } from '$lib/api/docker';
import { precheckDeployment, setDefaultConfiguration } from '$lib/api/applications/configuration';
import cloneRepository from '$lib/api/applications/cloneRepository';
import { cleanupTmp } from '$lib/api/common';
import { cleanupTmp, execShellAsync } from '$lib/api/common';
import queueAndBuild from '$lib/api/applications/queueAndBuild';
import Configuration from '$models/Configuration';
import ApplicationLog from '$models/ApplicationLog';
import { cleanupStuckedDeploymentsInDB } from '$lib/api/applications/cleanup';
export async function post(request: Request) {
let configuration;
const allowedGithubEvents = ['push', 'pull_request'];
const allowedPRActions = ['opened', 'reopened', 'synchronize', 'closed'];
const githubEvent = request.headers['x-github-event'];
const { GITHUP_APP_WEBHOOK_SECRET } = process.env;
const hmac = crypto.createHmac('sha256', GITHUP_APP_WEBHOOK_SECRET);
const digest = Buffer.from(
@@ -19,52 +25,96 @@ export async function post(request: Request) {
return {
status: 500,
body: {
error: 'Invalid request'
error: 'Invalid request.'
}
};
}
if (request.headers['x-github-event'] !== 'push') {
if (!allowedGithubEvents.includes(githubEvent)) {
return {
status: 500,
body: {
error: 'Not a push event.'
error: 'Event not allowed.'
}
};
}
try {
const services = (await docker.engine.listServices()).filter(
(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application'
);
configuration = services.find((r) => {
if (request.body.ref.startsWith('refs')) {
const branch = request.body.ref.split('/')[2];
if (
JSON.parse(r.Spec.Labels.configuration).repository.id === request.body.repository.id &&
JSON.parse(r.Spec.Labels.configuration).repository.branch === branch
) {
return r;
const applications = await Configuration.find({
'repository.id': request.body.repository.id
}).select('-_id -__v -createdAt -updatedAt');
if (githubEvent === 'push') {
configuration = applications.find((r) => {
if (request.body.ref.startsWith('refs')) {
if (r.repository.branch === request.body.ref.split('/')[2]) {
return r;
}
}
return null;
});
} else if (githubEvent === 'pull_request') {
if (!allowedPRActions.includes(request.body.action)) {
return {
status: 500,
body: {
error: 'PR action is not allowed.'
}
};
}
return null;
});
configuration = setDefaultConfiguration(JSON.parse(configuration.Spec.Labels.configuration));
configuration = applications.find(
(r) => r.repository.branch === request.body['pull_request'].base.ref
);
if (configuration) {
if (!configuration.general.isPreviewDeploymentEnabled) {
return {
status: 500,
body: {
error: 'PR deployments are not enabled.'
}
};
}
configuration.general.pullRequest = request.body.number;
}
}
if (!configuration) {
return {
status: 500,
body: {
error: 'Whaaat?'
error: 'No configuration found.'
}
};
}
configuration = setDefaultConfiguration(configuration);
const { id, organization, name, branch } = configuration.repository;
const { domain } = configuration.publish;
const { deployId, nickname, pullRequest } = configuration.general;
if (request.body.action === 'closed') {
const deploys = await Deployment.find({ organization, branch, name, domain });
for (const deploy of deploys) {
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
await Deployment.deleteMany({ deployId: deploy.deployId });
}
await Configuration.findOneAndRemove({
'repository.id': id,
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
'general.pullRequest': pullRequest
});
await execShellAsync(`docker stack rm ${configuration.build.container.name}`);
return {
status: 200,
body: {
success: true,
message: 'Removed'
}
};
}
await cloneRepository(configuration);
const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment({
services,
const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment(
configuration
});
);
if (foundService && !forceUpdate && !imageChanged && !configChanged) {
cleanupTmp(configuration.general.workdir);
return {
@@ -76,11 +126,11 @@ export async function post(request: Request) {
};
}
const alreadyQueued = await Deployment.find({
repoId: configuration.repository.id,
branch: configuration.repository.branch,
organization: configuration.repository.organization,
name: configuration.repository.name,
domain: configuration.publish.domain,
repoId: id,
branch: branch,
organization: organization,
name: name,
domain: domain,
progress: { $in: ['queued', 'inprogress'] }
});
if (alreadyQueued.length > 0) {
@@ -92,6 +142,43 @@ export async function post(request: Request) {
}
};
}
await new Deployment({
repoId: id,
branch,
deployId,
domain,
organization,
name,
nickname
}).save();
if (githubEvent === 'pull_request') {
await Configuration.findOneAndUpdate(
{
'repository.id': id,
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
'general.pullRequest': pullRequest
},
{ ...configuration },
{ upsert: true, new: true }
);
} else {
await Configuration.findOneAndUpdate(
{
'repository.id': id,
'repository.organization': organization,
'repository.name': name,
'repository.branch': branch,
'general.pullRequest': { $in: [null, 0] }
},
{ ...configuration },
{ upsert: true, new: true }
);
}
queueAndBuild(configuration, imageChanged);
return {
status: 201,
@@ -103,11 +190,40 @@ export async function post(request: Request) {
}
};
} catch (error) {
console.log(error);
// console.log(configuration)
if (configuration) {
cleanupTmp(configuration.general.workdir);
await Deployment.findOneAndUpdate(
{
repoId: configuration.repository.id,
branch: configuration.repository.branch,
organization: configuration.repository.organization,
name: configuration.repository.name,
domain: configuration.publish.domain
},
{
repoId: configuration.repository.id,
branch: configuration.repository.branch,
organization: configuration.repository.organization,
name: configuration.repository.name,
domain: configuration.publish.domain,
progress: 'failed'
}
);
}
return {
status: 500,
body: {
error: error.message || error
}
};
} finally {
try {
await cleanupStuckedDeploymentsInDB();
} catch (error) {
console.log(error);
}
}
}

View File

@@ -84,13 +84,15 @@
deployment.progress !== 'failed'}
class:bg-warmGray-800={deployment.progress !== 'done' &&
deployment.progress !== 'failed'}
class:hover:bg-red-200={deployment.progress === 'failed'}
class:hover:border-red-500={deployment.progress === 'failed'}
on:click={() => goto(`./logs/${deployment.deployId}`)}
>
<div class="font-bold text-sm px-3 flex justify-center items-center">
{deployment.branch}
<div class="flex space-x-2 px-2">
<div class="font-bold text-sm flex justify-center items-center">
{deployment.branch}
</div>
<div class="font-bold text-xs flex justify-center items-center text-warmGray-500">{deployment.isPr ? 'PR' : ''}</div>
</div>
<div class="flex-1" />
<div class="px-3 w-48">
<div

View File

@@ -1,5 +1,20 @@
<script context="module" lang="ts">
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load(session) {
if (!browser && !process.env.VITE_GITHUB_APP_CLIENTID) {
return {
status: 301,
redirect: '/dashboard/services'
};
}
return {};
}
</script>
<script>
import { application, initialApplication, initConf, dashboard } from '$store';
import { application, initialApplication, initConf, dashboard, prApplication } from '$store';
import { onDestroy } from 'svelte';
import Loading from '$components/Loading.svelte';
import Navbar from '$components/Application/Navbar.svelte';
@@ -14,15 +29,16 @@
async function setConfiguration() {
try {
const config = await request(`/api/v1/application/config`, $session, {
const { configuration } = await request(`/api/v1/application/config`, $session, {
body: {
name: $application.repository.name,
organization: $application.repository.organization,
branch: $application.repository.branch
}
});
$application = { ...config };
$initConf = JSON.parse(JSON.stringify($application));
$prApplication = configuration.filter((c) => c.general.pullRequest !== 0);
$application = configuration.find((c) => c.general.pullRequest === 0);
if (!$application) browser && goto('/dashboard/applications');
} catch (error) {
browser && goto('/dashboard/applications');
}
@@ -57,7 +73,6 @@
onDestroy(() => {
$application = JSON.parse(JSON.stringify(initialApplication));
});
</script>
{#await loadConfiguration()}

View File

@@ -1,8 +1,28 @@
<script context="module" lang="ts">
import { request } from '$lib/request';
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load(session) {
if (!browser && !process.env.VITE_GITHUB_APP_CLIENTID) {
return {
status: 301,
redirect: '/dashboard/services'
};
}
return {
props: {
initDashboard: await request('/api/v1/dashboard', session)
}
};
}
</script>
<script lang="ts">
import { goto } from '$app/navigation';
import { dashboard, dateOptions } from '$store';
import { dashboard, dateOptions, settings } from '$store';
import { fade } from 'svelte/transition';
import { browser } from '$app/env';
</script>
<div
@@ -37,7 +57,7 @@
{#each $dashboard.applications.deployed as application}
<div class="px-4 pb-4">
<div
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-green-500 text-white shadow-md cursor-pointer ease-in-out transform hover:scale-105 duration-100 group"
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-green-500 text-white shadow-md cursor-pointer ease-in-out hover:scale-105 duration-100 group"
on:click={() => {
goto(
`/application/${application.configuration.repository.organization}/${application.configuration.repository.name}/${application.configuration.repository.branch}/configuration`

View File

@@ -1,3 +1,18 @@
<script context="module" lang="ts">
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load(session) {
if (!browser && !process.env.VITE_GITHUB_APP_CLIENTID) {
return {
status: 301,
redirect: '/dashboard/services'
};
}
return {};
}
</script>
<script>
import { goto } from '$app/navigation';
import MongoDb from '$components/Database/SVGs/MongoDb.svelte';
@@ -8,7 +23,7 @@
import { dashboard } from '$store';
import { fade } from 'svelte/transition';
import Redis from '$components/Database/SVGs/Redis.svelte';
import { browser } from '$app/env';
</script>
<div class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center">
@@ -45,7 +60,7 @@
goto(`/database/${database.configuration.general.deployId}/configuration`)}
>
<div
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-purple-500 text-white shadow-md cursor-pointer ease-in-out transform hover:scale-105 duration-100 group"
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-purple-500 text-white shadow-md cursor-pointer ease-in-out hover:scale-105 duration-100 group"
>
<div class="flex items-center">
{#if database.configuration.general.type == 'mongodb'}
@@ -59,9 +74,7 @@
customClass="w-10 h-10 fill-current text-red-600 absolute top-0 left-0 -m-4"
/>
{:else if database.configuration.general.type == 'redis'}
<Redis
customClass="w-10 h-10 absolute top-0 left-0 -m-4"
/>
<Redis customClass="w-10 h-10 absolute top-0 left-0 -m-4" />
{:else if database.configuration.general.type == 'clickhouse'}
<Clickhouse
customClass="w-10 h-10 fill-current text-red-600 absolute top-0 left-0 -m-4"

View File

@@ -2,6 +2,14 @@
import { goto } from '$app/navigation';
import { dashboard } from '$store';
import { fade } from 'svelte/transition';
async function openConfiguration(service) {
if (service.serviceName === 'wordpress') {
goto(`/service/${service.configuration.deployId}/configuration`);
} else {
goto(`/service/${service.serviceName}/configuration`);
}
}
</script>
<div
@@ -34,10 +42,10 @@
<div
in:fade={{ duration: 200 }}
class="px-4 pb-4"
on:click={() => goto(`/service/${service.serviceName}/configuration`)}
on:click={() => openConfiguration(service)}
>
<div
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-blue-500 text-white shadow-md cursor-pointer ease-in-out transform hover:scale-105 duration-100 group"
class="relative rounded-xl p-6 bg-warmGray-800 border-2 border-dashed border-transparent hover:border-blue-500 text-white shadow-md cursor-pointer ease-in-out hover:scale-105 duration-100 group"
>
<div class="flex items-center">
{#if service.serviceName == 'plausible'}
@@ -49,6 +57,60 @@
/>
<div class="text-white font-bold">Plausible Analytics</div>
</div>
{:else if service.serviceName == 'nocodb'}
<div>
<img
alt="nocodedb"
class="w-10 absolute top-0 left-0 -m-6"
src="https://cdn.coollabs.io/assets/coolify/services/nocodb/nocodb.png"
/>
<div class="text-white font-bold">NocoDB</div>
</div>
{:else if service.serviceName == 'code-server'}
<div>
<svg class="w-10 absolute top-0 left-0 -m-6" viewBox="0 0 128 128">
<path
d="M3.656 45.043s-3.027-2.191.61-5.113l8.468-7.594s2.426-2.559 4.989-.328l78.175 59.328v28.45s-.039 4.468-5.757 3.976zm0 0"
fill="#2489ca"
/><path
d="M23.809 63.379L3.656 81.742s-2.07 1.543 0 4.305l9.356 8.527s2.222 2.395 5.508-.328l21.359-16.238zm0 0"
fill="#1070b3"
/><path
d="M59.184 63.531l36.953-28.285-.239-28.297S94.32.773 89.055 3.99L39.879 48.851zm0 0"
fill="#0877b9"
/><path
d="M90.14 123.797c2.145 2.203 4.747 1.48 4.747 1.48l28.797-14.222c3.687-2.52 3.171-5.645 3.171-5.645V20.465c0-3.735-3.812-5.024-3.812-5.024L98.082 3.38c-5.453-3.379-9.027.61-9.027.61s4.593-3.317 6.843 2.96v112.317c0 .773-.164 1.53-.492 2.214-.656 1.332-2.086 2.57-5.504 2.051zm0 0"
fill="#3c99d4"
/>
</svg>
<div class="text-white font-bold">VSCode Server</div>
</div>
{:else if service.serviceName == 'minio'}
<div>
<img
alt="minio"
class="w-7 absolute top-0 left-0 -my-7 -mx-3"
src="https://cdn.coollabs.io/assets/coolify/services/minio/MINIO_Bird.png"
/>
<div class="text-white font-bold">MinIO</div>
</div>
{:else if service.serviceName.match(/wp-/)}
<svg class="w-10 absolute top-0 left-0 -m-6" viewBox="0 0 128 128">
<path
fill-rule="evenodd"
clip-rule="evenodd"
fill="white"
d="M64.094 126.224c34.275-.052 62.021-27.933 62.021-62.325 0-33.833-27.618-61.697-60.613-62.286C30.85.995 1.894 29.113 1.885 63.21c-.01 35.079 27.612 63.064 62.209 63.014zM63.993 4.63c32.907-.011 59.126 26.725 59.116 60.28-.011 31.679-26.925 58.18-59.092 58.187-32.771.007-59.125-26.563-59.124-59.608.002-32.193 26.766-58.848 59.1-58.859zM39.157 35.896c.538 1.793-.968 2.417-2.569 2.542-1.685.13-3.369.257-5.325.406 6.456 19.234 12.815 38.183 19.325 57.573.464-.759.655-.973.739-1.223 3.574-10.682 7.168-21.357 10.651-32.069.318-.977.16-2.271-.188-3.275-1.843-5.32-4.051-10.524-5.667-15.908-1.105-3.686-2.571-6.071-6.928-5.644-.742.073-1.648-1.524-2.479-2.349 1.005-.6 2.003-1.704 3.017-1.719a849.593 849.593 0 0126.618.008c1.018.017 2.016 1.15 3.021 1.765-.88.804-1.639 2.01-2.668 2.321-1.651.498-3.482.404-5.458.58l19.349 57.56c2.931-9.736 5.658-18.676 8.31-27.639 2.366-8.001.956-15.473-3.322-22.52-1.286-2.119-2.866-4.175-3.595-6.486-.828-2.629-1.516-5.622-1.077-8.259.745-4.469 4.174-6.688 8.814-7.113C74.333.881 34.431 9.317 19.728 34.922c5.66-.261 11.064-.604 16.472-.678 1.022-.013 2.717.851 2.957 1.652zm10.117 77.971c-.118.345-.125.729-.218 1.302 10.943 3.034 21.675 2.815 32.659-.886l-16.78-45.96c-5.37 15.611-10.52 30.575-15.661 45.544zm-8.456-2.078l-25.281-69.35c-11.405 22.278-2.729 56.268 25.281 69.35zm76.428-44.562c.802-10.534-2.832-25.119-5.97-27.125-.35 3.875-.106 8.186-1.218 12.114-2.617 9.255-5.817 18.349-8.899 27.468-3.35 9.912-6.832 19.779-10.257 29.666 16.092-9.539 24.935-23.618 26.344-42.123z"
/>
</svg>
<div class="text-white font-bold text-center">
Wordpress<span
class="flex text-xs items-center justify-center text-warmGray-300 group-hover:text-white"
>({service.configuration.baseURL.replace('https://', '')})</span
>
</div>
{/if}
</div>
</div>

View File

@@ -67,9 +67,7 @@
<div class="pb-2 pt-5 space-y-4">
<div class="text-2xl font-bold border-gradient w-32">Database</div>
<div class="flex items-center pt-4">
{#if $database.config.general.type !== 'redis'}
<div class="font-bold w-64 text-warmGray-400">Connection string</div>
{/if}
<div class="font-bold w-64 text-warmGray-400">Connection string</div>
{#if $database.config.general.type === 'mongodb'}
<PasswordField
value={`mongodb://${$database.envs.MONGODB_USERNAME}:${$database.envs.MONGODB_PASSWORD}@${$database.config.general.deployId}:27017/${$database.envs.MONGODB_DATABASE}`}
@@ -86,6 +84,10 @@
<PasswordField
value={`http://${$database.envs.COUCHDB_USER}:${$database.envs.COUCHDB_PASSWORD}@${$database.config.general.deployId}:5984`}
/>
{:else if $database.config.general.type === 'redis'}
<PasswordField
value={`redis://${$database.envs.REDIS_PASSWORD}@${$database.config.general.deployId}:6379`}
/>
{:else if $database.config.general.type === 'clickhouse'}
<!-- {JSON.stringify($database)} -->
<!-- <textarea

View File

@@ -1,10 +1,15 @@
<script>
import { browser } from '$app/env';
import { goto } from '$app/navigation';
import { session } from '$app/stores';
import { toast } from '@zerodevx/svelte-toast';
import PasswordField from '$components/PasswordField.svelte';
import { request } from '$lib/request';
import { settings } from '$store';
import Loading from '$components/Loading.svelte';
let loading = false;
let email = null;
let password = null;
async function login() {
const left = screen.width / 2 - 1020 / 2;
const top = screen.height / 2 - 618 / 2;
@@ -20,13 +25,32 @@
', toolbar=0, menubar=0, status=0'
);
const timer = setInterval(() => {
if (newWindow.closed) {
if (newWindow?.closed) {
clearInterval(timer);
browser && location.reload()
// WHY need to navigate to / to get cookies?!
browser && window.location.replace('/')
}
}, 100);
}
async function loginWithEmail() {
try {
loading = true;
const { message } = await request('/api/v1/login/email', $session, {
body: {
email,
password
}
});
toast.push(message);
setTimeout(() => {
// WHY need to navigate to / to get cookies?!
browser && window.location.replace('/')
}, 1000);
} catch (error) {
loading = false;
browser && toast.push(error.error || error || 'Ooops something went wrong.');
}
}
</script>
<div class="flex justify-center items-center h-screen w-full bg-warmGray-900">
@@ -37,24 +61,56 @@
>
<span class="border-gradient">Coolify</span>
</p>
<h2 class="text-2xl md:text-3xl font-extrabold text-white">
<h2 class="text-2xl md:text-3xl font-extrabold text-white py-10">
An open-source, hassle-free, self-hostable<br />
<span class="text-indigo-400">Heroku</span>
& <span class="text-green-400">Netlify</span> alternative
</h2>
<div class="text-center py-10">
{#if !$session.isLoggedIn}
<button
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
on:click={login}>Login with Github</button
>
{:else}
<button
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
on:click={() => goto('/dashboard/applications')}>Get Started</button
>
{/if}
</div>
{#if loading}
<Loading fullscreen={false} />
{:else}
<div class="text-center py-10 max-w-7xl">
{#if !$session.isLoggedIn}
{#if $settings.clientId}
<button
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
on:click={login}>Login with GitHub</button
>
{:else}
<div>
<div class="grid grid-flow-row gap-2 items-center pb-6">
<div class="grid grid-flow-row">
<label for="Email" class="">Email address</label>
<input
class="border-2"
id="Email"
bind:value={email}
placeholder="hi@coollabs.io"
/>
</div>
<div class="grid grid-flow-row">
<label for="Password" class="">Password</label>
<PasswordField bind:value={password} isEditable />
</div>
</div>
<div class="space-x-4 pt-10">
<button
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
on:click={loginWithEmail}>Login with Email</button
>
</div>
</div>
{/if}
{:else}
<button
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
on:click={() =>
$settings.clientId ? goto('/dashboard/applications') : goto('/dashboard/services')}
>Get Started</button
>
{/if}
</div>
{/if}
</div>
</div>
</div>

View File

@@ -0,0 +1,101 @@
<script context="module">
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load({ fetch }) {
try {
const { hostname, filesystems,dockerReclaimable } = await (await fetch(`/api/v1/servers`)).json();
return {
props: {
hostname,
filesystems,
dockerReclaimable
}
};
} catch (error) {
return {
props: {
hostname: null,
filesystems: null,
dockerReclaimable: null
}
};
}
}
</script>
<script>
export let hostname;
export let filesystems;
export let dockerReclaimable;
import { browser } from '$app/env';
import { session } from '$app/stores';
import { request } from '$lib/request';
import { toast } from '@zerodevx/svelte-toast';
import { fade } from 'svelte/transition';
async function refetch() {
const data = await request('/api/v1/servers', $session)
filesystems = data.filesystems
dockerReclaimable = data.dockerReclaimable
}
async function cleanupVolumes() {
const { output } = await request('/api/v1/servers/cleanups/volumes', $session, {
body: {}
});
browser && toast.push(output);
await refetch()
}
async function cleanupImages() {
const { output } = await request('/api/v1/servers/cleanups/images', $session, {
body: {}
});
browser && toast.push(output);
await refetch()
}
async function cleanupBuildCache() {
const { output } = await request('/api/v1/servers/cleanups/caches', $session, {
body: {}
});
browser && toast.push(output);
await refetch()
}
async function cleanupContainers() {
const { output } = await request('/api/v1/servers/cleanups/containers', $session, {
body: {}
});
browser && toast.push(output);
await refetch()
}
</script>
<div class="min-h-full text-white" in:fade={{ duration: 100 }}>
<div class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center">
<div>Servers</div>
</div>
</div>
<div in:fade={{ duration: 100 }}>
<div class="max-w-4xl mx-auto px-6 pb-4 h-64 ">
<div class="text-center font-bold text-xl">{hostname}</div>
<div class="font-bold">Filesystem Usage</div>
{#each filesystems as filesystem}
<!-- <div>{JSON.stringify(filesystem)}</div> -->
<div class="text-xs">
{filesystem.mount}: {(filesystem.available / 1024 / 1024).toFixed()}MB ({filesystem.use}%) free of {(filesystem.size /1024 /1024).toFixed()}MB
</div>
{/each}
<div class="font-bold">Docker Reclaimable</div>
{#each dockerReclaimable as reclaimable}
<div class="text-xs">
{reclaimable.Type}: {reclaimable.Reclaimable} of {reclaimable.Size}
</div>
{/each}
<button class="button hover:bg-warmGray-700 bg-warmGray-800 rounded p-2 font-bold" on:click={cleanupVolumes}>Cleanup unused volumes</button>
<button class="button hover:bg-warmGray-700 bg-warmGray-800 rounded p-2 font-bold" on:click={cleanupImages}>Cleanup unused images</button>
<button class="button hover:bg-warmGray-700 bg-warmGray-800 rounded p-2 font-bold" on:click={cleanupBuildCache}>Cleanup build caches</button>
<button class="button hover:bg-warmGray-700 bg-warmGray-800 rounded p-2 font-bold" on:click={cleanupContainers}>Cleanup containers</button>
</div>
</div>

View File

@@ -8,29 +8,23 @@
import Loading from '$components/Loading.svelte';
import Plausible from '$components/Service/Plausible.svelte';
import { browser } from '$app/env';
import CodeServer from '$components/Service/CodeServer.svelte';
import MinIo from '$components/Service/MinIO.svelte';
let service = {};
async function loadServiceConfig() {
if ($page.params.name) {
try {
service = await request(`/api/v1/services/${$page.params.name}`, $session);
} catch (error) {
browser && toast.push(`Cannot find service ${$page.params.name}?!`);
goto(`/dashboard/services`, { replaceState: true });
if (browser) {
toast.push(`Cannot find service ${$page.params.name}?!`);
goto(`/dashboard/services`, { replaceState: true });
}
}
}
}
async function activate() {
try {
await request(`/api/v1/services/deploy/${$page.params.name}/activate`, $session, {
method: 'PATCH',
body: {}
});
browser && toast.push(`All users are activated for Plausible.`);
} catch (error) {
console.log(error);
browser && toast.push(`Ooops, there was an error activating users for Plausible?!`);
}
}
</script>
{#await loadServiceConfig()}
@@ -38,7 +32,18 @@
{:then}
<div class="min-h-full text-white">
<div class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center">
<div>{$page.params.name === 'plausible' ? 'Plausible Analytics' : $page.params.name}</div>
{#if $page.params.name === 'plausible'}
<div>Plausible Analytics</div>
{:else if $page.params.name === 'nocodb'}
<div>NocoDB</div>
{:else if $page.params.name === 'code-server'}
<div>VSCode Server</div>
{:else if $page.params.name === 'minio'}
<div>MinIO</div>
{:else if $page.params.name.match(/wp-/)}
<div>Wordpress<span class="flex text-xs items-center justify-center">({service.config.baseURL.replace('https://','')})</span></div>
{/if}
<div class="px-4">
{#if $page.params.name === 'plausible'}
<img
@@ -46,37 +51,75 @@
class="w-6 mx-auto"
src="https://cdn.coollabs.io/assets/coolify/services/plausible/logo_sm.png"
/>
{:else if $page.params.name === 'nocodb'}
<img
alt="nocodb logo"
class="w-8 mx-auto"
src="https://cdn.coollabs.io/assets/coolify/services/nocodb/nocodb.png"
/>
{:else if $page.params.name === 'code-server'}
<svg class="w-8 mx-auto" viewBox="0 0 128 128">
<path
d="M3.656 45.043s-3.027-2.191.61-5.113l8.468-7.594s2.426-2.559 4.989-.328l78.175 59.328v28.45s-.039 4.468-5.757 3.976zm0 0"
fill="#2489ca"
/><path
d="M23.809 63.379L3.656 81.742s-2.07 1.543 0 4.305l9.356 8.527s2.222 2.395 5.508-.328l21.359-16.238zm0 0"
fill="#1070b3"
/><path
d="M59.184 63.531l36.953-28.285-.239-28.297S94.32.773 89.055 3.99L39.879 48.851zm0 0"
fill="#0877b9"
/><path
d="M90.14 123.797c2.145 2.203 4.747 1.48 4.747 1.48l28.797-14.222c3.687-2.52 3.171-5.645 3.171-5.645V20.465c0-3.735-3.812-5.024-3.812-5.024L98.082 3.38c-5.453-3.379-9.027.61-9.027.61s4.593-3.317 6.843 2.96v112.317c0 .773-.164 1.53-.492 2.214-.656 1.332-2.086 2.57-5.504 2.051zm0 0"
fill="#3c99d4"
/>
</svg>
{:else if $page.params.name === 'minio'}
<img
alt="minio logo"
class="w-7 mx-auto"
src="https://cdn.coollabs.io/assets/coolify/services/minio/MINIO_Bird.png"
/>
{:else if $page.params.name.match(/wp-/)}
<svg class="w-8 mx-auto" viewBox="0 0 128 128">
<path
fill-rule="evenodd"
clip-rule="evenodd"
fill="white"
d="M64.094 126.224c34.275-.052 62.021-27.933 62.021-62.325 0-33.833-27.618-61.697-60.613-62.286C30.85.995 1.894 29.113 1.885 63.21c-.01 35.079 27.612 63.064 62.209 63.014zM63.993 4.63c32.907-.011 59.126 26.725 59.116 60.28-.011 31.679-26.925 58.18-59.092 58.187-32.771.007-59.125-26.563-59.124-59.608.002-32.193 26.766-58.848 59.1-58.859zM39.157 35.896c.538 1.793-.968 2.417-2.569 2.542-1.685.13-3.369.257-5.325.406 6.456 19.234 12.815 38.183 19.325 57.573.464-.759.655-.973.739-1.223 3.574-10.682 7.168-21.357 10.651-32.069.318-.977.16-2.271-.188-3.275-1.843-5.32-4.051-10.524-5.667-15.908-1.105-3.686-2.571-6.071-6.928-5.644-.742.073-1.648-1.524-2.479-2.349 1.005-.6 2.003-1.704 3.017-1.719a849.593 849.593 0 0126.618.008c1.018.017 2.016 1.15 3.021 1.765-.88.804-1.639 2.01-2.668 2.321-1.651.498-3.482.404-5.458.58l19.349 57.56c2.931-9.736 5.658-18.676 8.31-27.639 2.366-8.001.956-15.473-3.322-22.52-1.286-2.119-2.866-4.175-3.595-6.486-.828-2.629-1.516-5.622-1.077-8.259.745-4.469 4.174-6.688 8.814-7.113C74.333.881 34.431 9.317 19.728 34.922c5.66-.261 11.064-.604 16.472-.678 1.022-.013 2.717.851 2.957 1.652zm10.117 77.971c-.118.345-.125.729-.218 1.302 10.943 3.034 21.675 2.815 32.659-.886l-16.78-45.96c-5.37 15.611-10.52 30.575-15.661 45.544zm-8.456-2.078l-25.281-69.35c-11.405 22.278-2.729 56.268 25.281 69.35zm76.428-44.562c.802-10.534-2.832-25.119-5.97-27.125-.35 3.875-.106 8.186-1.218 12.114-2.617 9.255-5.817 18.349-8.899 27.468-3.35 9.912-6.832 19.779-10.257 29.666 16.092-9.539 24.935-23.618 26.344-42.123z"
/>
</svg>
{/if}
</div>
<a
target="_blank"
class="icon mx-2"
href={service.config.baseURL}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
<a target="_blank" class="icon mx-2" href={service.config.baseURL}>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg></a
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg></a
>
</div>
</div>
<div class="space-y-2 max-w-4xl mx-auto px-6" in:fade={{ duration: 100 }}>
<div class="block text-center py-4">
{#if $page.params.name === 'plausible'}
<Plausible {service} />
{:else if $page.params.name === 'nocodb'}
<div class="font-bold">Nothing to show here. Enjoy using NocoDB!</div>
{:else if $page.params.name === 'code-server'}
<CodeServer {service} />
{:else if $page.params.name === 'minio'}
<MinIo {service} />
{:else if $page.params.name.match(/wp-/)}
<div class="font-bold">Nothing to show here. Enjoy using WordPress!</div>
{/if}
</div>
</div>

View File

@@ -1,8 +1,6 @@
<script>
import { browser } from '$app/env';
import { goto } from '$app/navigation';
import { page, session } from '$app/stores';
import Loading from '$components/Loading.svelte';
import { request } from '$lib/request';
@@ -14,13 +12,11 @@
async function checkService() {
try {
const data = await request(`/api/v1/services/${$page.params.type}`, $session);
if (!data?.success) {
if (data?.success) {
if (browser) {
goto(`/dashboard/services`, { replaceState: true });
goto(`/service/${$page.params.type}/configuration`, { replaceState: true });
toast.push(
`${
$page.params.type === 'plausible' ? 'Plausible Analytics' : $page.params.type
} already deployed.`
`Service already deployed.`
);
}
}

View File

@@ -2,7 +2,7 @@
import { fade } from 'svelte/transition';
import { toast } from '@zerodevx/svelte-toast';
import { newService } from '$store';
import { newService, newWordpressService } from '$store';
import { page, session } from '$app/stores';
import { request } from '$lib/request';
import { goto } from '$app/navigation';
@@ -10,7 +10,7 @@
import TooltipInfo from '$components/TooltipInfo.svelte';
import { browser } from '$app/env';
$: deployable =
$: deployablePlausible =
$newService.baseURL === '' ||
$newService.baseURL === null ||
$newService.email === '' ||
@@ -21,8 +21,13 @@
$newService.userPassword === null ||
$newService.userPassword.length <= 6 ||
$newService.userPassword !== $newService.userPasswordAgain;
$: deployableNocoDB = $newService.baseURL === '' || $newService.baseURL === null;
$: deployableCodeServer = $newService.baseURL === '' || $newService.baseURL === null;
$: deployableMinIO = $newService.baseURL === '' || $newService.baseURL === null;
$: deployableWordpress = false
let loading = false;
async function deploy() {
async function deployPlausible() {
try {
loading = true;
const payload = $newService;
@@ -44,6 +49,95 @@
loading = false;
}
}
async function deployNocodb() {
try {
loading = true;
await request(`/api/v1/services/deploy/${$page.params.type}`, $session, {
body: {
baseURL: $newService.baseURL
}
});
if (browser) {
toast.push(
'Service deployment queued.<br><br><br>It could take 2-5 minutes to be ready, be patient and grab a coffee/tea!',
{ duration: 4000 }
);
goto(`/dashboard/services`, { replaceState: true });
}
} catch (error) {
console.log(error);
browser && toast.push('Oops something went wrong. See console.log.');
} finally {
loading = false;
}
}
async function deployCodeServer() {
try {
loading = true;
await request(`/api/v1/services/deploy/${$page.params.type}`, $session, {
body: {
baseURL: $newService.baseURL
}
});
if (browser) {
toast.push(
'Service deployment queued.<br><br><br>It could take 2-5 minutes to be ready, be patient and grab a coffee/tea!',
{ duration: 4000 }
);
goto(`/dashboard/services`, { replaceState: true });
}
} catch (error) {
console.log(error);
browser && toast.push('Oops something went wrong. See console.log.');
} finally {
loading = false;
}
}
async function deployMinIO() {
try {
loading = true;
await request(`/api/v1/services/deploy/${$page.params.type}`, $session, {
body: {
baseURL: $newService.baseURL
}
});
if (browser) {
toast.push(
'Service deployment queued.<br><br><br>It could take 2-5 minutes to be ready, be patient and grab a coffee/tea!',
{ duration: 4000 }
);
goto(`/dashboard/services`, { replaceState: true });
}
} catch (error) {
console.log(error);
browser && toast.push('Oops something went wrong. See console.log.');
} finally {
loading = false;
}
}
async function deployWordpress() {
try {
loading = true;
await request(`/api/v1/services/deploy/${$page.params.type}`, $session, {
body: {
...$newWordpressService
}
});
if (browser) {
toast.push(
'Service deployment queued.<br><br><br>It could take 2-5 minutes to be ready, be patient and grab a coffee/tea!',
{ duration: 4000 }
);
goto(`/dashboard/services`, { replaceState: true });
}
} catch (error) {
console.log(error);
browser && toast.push('Oops something went wrong. See console.log.');
} finally {
loading = false;
}
}
</script>
<div class="min-h-full text-white">
@@ -51,18 +145,26 @@
Deploy new
{#if $page.params.type === 'plausible'}
<span class="text-blue-500 px-2 capitalize">Plausible Analytics</span>
{:else if $page.params.type === 'nocodb'}
<span class="text-blue-500 px-2 capitalize">NocoDB</span>
{:else if $page.params.type === 'code-server'}
<span class="text-blue-500 px-2 capitalize">VSCode Server</span>
{:else if $page.params.type === 'minio'}
<span class="text-blue-500 px-2 capitalize">MinIO</span>
{:else if $page.params.type === 'wordpress'}
<span class="text-blue-500 px-2 capitalize">Wordpress</span>
{/if}
</div>
</div>
{#if loading}
<Loading />
{:else}
<div class="space-y-2 max-w-4xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
{:else if $page.params.type === 'plausible'}
<div class="space-y-2 max-w-xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
<div class="grid grid-flow-row">
<label for="Domain"
>Domain <TooltipInfo
position="right"
label={`You will have your Plausible instance at here.`}
label={`You could reach your Plausible Analytics instance here.`}
/></label
>
<input
@@ -114,15 +216,292 @@
/>
</div>
<button
disabled={deployable}
class:cursor-not-allowed={deployable}
class:bg-blue-500={!deployable}
class:hover:bg-blue-400={!deployable}
class:hover:bg-transparent={deployable}
class:text-warmGray-700={deployable}
class:text-white={!deployable}
disabled={deployablePlausible}
class:cursor-not-allowed={deployablePlausible}
class:bg-blue-500={!deployablePlausible}
class:hover:bg-blue-400={!deployablePlausible}
class:hover:bg-transparent={deployablePlausible}
class:text-warmGray-700={deployablePlausible}
class:text-white={!deployablePlausible}
class="button p-2"
on:click={deploy}
on:click={deployPlausible}
>
Deploy
</button>
</div>
{:else if $page.params.type === 'nocodb'}
<div class="space-y-2 max-w-xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
<div class="grid grid-flow-row pb-5">
<label for="Domain"
>Domain <TooltipInfo
position="right"
label={`You could reach your NocoDB instance here.`}
/></label
>
<input
id="Domain"
class:border-red-500={$newService.baseURL == null || $newService.baseURL == ''}
bind:value={$newService.baseURL}
placeholder="nocodb.coollabs.io"
/>
</div>
<button
disabled={deployableNocoDB}
class:cursor-not-allowed={deployableNocoDB}
class:bg-blue-500={!deployableNocoDB}
class:hover:bg-blue-400={!deployableNocoDB}
class:hover:bg-transparent={deployableNocoDB}
class:text-warmGray-700={deployableNocoDB}
class:text-white={!deployableNocoDB}
class="button p-2 w-64 bg-blue-500 hover:bg-blue-400 text-white"
on:click={deployNocodb}
>
Deploy
</button>
</div>
{:else if $page.params.type === 'code-server'}
<div class="space-y-2 max-w-xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
<div class="grid grid-flow-row pb-5">
<label for="Domain"
>Domain <TooltipInfo
position="right"
label={`You could reach your Code Server instance here.`}
/></label
>
<input
id="Domain"
class:border-red-500={$newService.baseURL == null || $newService.baseURL == ''}
bind:value={$newService.baseURL}
placeholder="code.coollabs.io"
/>
</div>
<button
disabled={deployableCodeServer}
class:cursor-not-allowed={deployableCodeServer}
class:bg-blue-500={!deployableCodeServer}
class:hover:bg-blue-400={!deployableCodeServer}
class:hover:bg-transparent={deployableCodeServer}
class:text-warmGray-700={deployableCodeServer}
class:text-white={!deployableCodeServer}
class="button p-2 w-64 bg-blue-500 hover:bg-blue-400 text-white"
on:click={deployCodeServer}
>
Deploy
</button>
</div>
{:else if $page.params.type === 'minio'}
<div class="space-y-2 max-w-xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
<div class="grid grid-flow-row pb-5">
<label for="Domain"
>Domain <TooltipInfo
position="right"
label={`You could reach your MinIO instance here.`}
/></label
>
<input
id="Domain"
class:border-red-500={$newService.baseURL == null || $newService.baseURL == ''}
bind:value={$newService.baseURL}
placeholder="minio.coollabs.io"
/>
</div>
<button
disabled={deployableMinIO}
class:cursor-not-allowed={deployableMinIO}
class:bg-blue-500={!deployableMinIO}
class:hover:bg-blue-400={!deployableMinIO}
class:hover:bg-transparent={deployableMinIO}
class:text-warmGray-700={deployableMinIO}
class:text-white={!deployableMinIO}
class="button p-2 w-64 bg-blue-500 hover:bg-blue-400 text-white"
on:click={deployMinIO}
>
Deploy
</button>
</div>
{:else if $page.params.type === 'wordpress'}
<div class="space-y-2 max-w-xl mx-auto px-6 flex-col text-center" in:fade={{ duration: 100 }}>
<div class="grid grid-flow-row pb-5">
<label for="Domain"
>Domain <TooltipInfo
position="right"
label={`You could reach your Wordpress instance here.`}
/></label
>
<input
id="Domain"
class:border-red-500={$newWordpressService.baseURL == null || $newWordpressService.baseURL == ''}
bind:value={$newWordpressService.baseURL}
placeholder="wordpress.coollabs.io"
/>
</div>
<div class="">
<div class="px-4 sm:px-6">
<ul class="divide-y divide-warmGray-800">
<li class="py-4 flex items-center justify-between text-left">
<div class="flex flex-col">
<p class="text-base font-bold text-warmGray-100">Use remote MySQL database?</p>
<p class="text-sm font-medium text-warmGray-400">
If not, Coolify will create a local database for you.
</p>
</div>
<button
type="button"
on:click={() => ($newWordpressService.remoteDB = !$newWordpressService.remoteDB)}
aria-pressed="true"
class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200"
class:bg-green-600={$newWordpressService.remoteDB}
class:bg-warmGray-700={!$newWordpressService.remoteDB}
>
<span class="sr-only">Use setting</span>
<span
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transition ease-in-out duration-200 transform"
class:translate-x-5={$newWordpressService.remoteDB}
class:translate-x-0={!$newWordpressService.remoteDB}
>
<span
class=" ease-in duration-200 absolute inset-0 h-full w-full flex items-center justify-center transition-opacity"
class:opacity-0={$newWordpressService.remoteDB}
class:opacity-100={!$newWordpressService.remoteDB}
aria-hidden="true"
>
<svg class="bg-white h-3 w-3 text-red-600" fill="none" viewBox="0 0 12 12">
<path
d="M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</span>
<span
class="ease-out duration-100 absolute inset-0 h-full w-full flex items-center justify-center transition-opacity"
aria-hidden="true"
class:opacity-100={$newWordpressService.remoteDB}
class:opacity-0={!$newWordpressService.remoteDB}
>
<svg
class="bg-white h-3 w-3 text-green-600"
fill="currentColor"
viewBox="0 0 12 12"
>
<path
d="M3.707 5.293a1 1 0 00-1.414 1.414l1.414-1.414zM5 8l-.707.707a1 1 0 001.414 0L5 8zm4.707-3.293a1 1 0 00-1.414-1.414l1.414 1.414zm-7.414 2l2 2 1.414-1.414-2-2-1.414 1.414zm3.414 2l4-4-1.414-1.414-4 4 1.414 1.414z"
/>
</svg>
</span>
</span>
</button>
</li>
</ul>
</div>
{#if $newWordpressService.remoteDB}
<div class="grid grid-flow-row pb-5">
<label for="database.host"
>DB Host <TooltipInfo
position="right"
label={`IP address of a remote Mysql instance.`}
/></label
>
<input
id="database.host"
class:border-red-500={$newWordpressService.database.host == null ||
$newWordpressService.database.host == ''}
bind:value={$newWordpressService.database.host}
placeholder="10.10.10.10:3306"
/>
</div>
<div class="grid grid-flow-row pb-5">
<label for="database.user"
>DB User <TooltipInfo position="right" label={`Database user.`} /></label
>
<input
id="database.user"
class:border-red-500={$newWordpressService.database.user == null ||
$newWordpressService.database.user == ''}
bind:value={$newWordpressService.database.user}
placeholder="wordpressuser"
/>
</div>
<div class="grid grid-flow-row pb-5">
<label for="database.password"
>DB Password <TooltipInfo
position="right"
label={`Database password for the database user.`}
/></label
>
<input
id="database.password"
class:border-red-500={$newWordpressService.database.password == null ||
$newWordpressService.database.password == ''}
bind:value={$newWordpressService.database.password}
placeholder="supersecretuserpasswordforwordpress"
/>
</div>
<div class="grid grid-flow-row pb-5">
<label for="database.name"
>DB Name<TooltipInfo
position="right"
label={`Database name`}
/></label
>
<input
id="database.name"
class:border-red-500={$newWordpressService.database.name == null ||
$newWordpressService.database.name == ''}
bind:value={$newWordpressService.database.name}
placeholder="wordpress"
/>
</div>
<div class="grid grid-flow-row pb-5">
<label for="database.tablePrefix"
>DB Table Prefix <TooltipInfo
position="right"
label={`Table prefix for wordpress`}
/></label
>
<input
id="database.tablePrefix"
class:border-red-500={$newWordpressService.database.tablePrefix == null ||
$newWordpressService.database.tablePrefix == ''}
bind:value={$newWordpressService.database.tablePrefix}
placeholder="wordpress"
/>
</div>
{/if}
<div class="grid grid-flow-row py-5">
<label for="wordpressExtraConfiguration"
>Wordpress Configuration Extra <TooltipInfo
position="right"
label={`Database password for the database user.`}
/></label
>
<textarea
class="h-32"
id="wordpressExtraConfiguration"
bind:value={$newWordpressService.wordpressExtraConfiguration}
placeholder="// Example Extra Configuration
define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);"
/>
</div>
</div>
<button
disabled={deployableWordpress}
class:cursor-not-allowed={deployableWordpress}
class:bg-blue-500={!deployableWordpress}
class:hover:bg-blue-400={!deployableWordpress}
class:hover:bg-transparent={deployableWordpress}
class:text-warmGray-700={deployableWordpress}
class:text-white={!deployableWordpress}
class="button p-2 w-64 bg-blue-500 hover:bg-blue-400 text-white"
on:click={deployWordpress}
>
Deploy
</button>

View File

@@ -1,8 +1,8 @@
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { fade } from 'svelte/transition';
</script>
<div class="min-h-full text-white">
@@ -10,11 +10,11 @@
Select a service
</div>
</div>
<div class="text-center space-y-2 max-w-4xl mx-auto px-6" in:fade={{ duration: 100 }}>
<div class="text-center space-y-2 max-w-7xl mx-auto px-6" in:fade={{ duration: 100 }}>
{#if $page.path === '/service/new'}
<div class="flex justify-center space-x-4 font-bold pb-6">
<div class="flex justify-center font-bold pb-6 flex-wrap">
<div
class="text-center flex-col items-center cursor-pointer ease-in-out transform hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 rounded bg-warmGray-800"
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 m-2 rounded bg-warmGray-800 w-48"
on:click={() => goto('/service/new/plausible')}
>
<img
@@ -24,6 +24,67 @@
/>
<div class="text-white">Plausible Analytics</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 m-2 rounded bg-warmGray-800 w-48"
on:click={() => goto('/service/new/nocodb')}
>
<img
alt="nocodb logo"
class="w-14 mx-auto pb-2"
src="https://cdn.coollabs.io/assets/coolify/services/nocodb/nocodb.png"
/>
<div class="flex-1" />
<div class="text-white">NocoDB</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 m-2 rounded bg-warmGray-800 w-48"
on:click={() => goto('/service/new/code-server')}
>
<svg class="w-14 mx-auto pb-2" viewBox="0 0 128 128">
<path
d="M3.656 45.043s-3.027-2.191.61-5.113l8.468-7.594s2.426-2.559 4.989-.328l78.175 59.328v28.45s-.039 4.468-5.757 3.976zm0 0"
fill="#2489ca"
/><path
d="M23.809 63.379L3.656 81.742s-2.07 1.543 0 4.305l9.356 8.527s2.222 2.395 5.508-.328l21.359-16.238zm0 0"
fill="#1070b3"
/><path
d="M59.184 63.531l36.953-28.285-.239-28.297S94.32.773 89.055 3.99L39.879 48.851zm0 0"
fill="#0877b9"
/><path
d="M90.14 123.797c2.145 2.203 4.747 1.48 4.747 1.48l28.797-14.222c3.687-2.52 3.171-5.645 3.171-5.645V20.465c0-3.735-3.812-5.024-3.812-5.024L98.082 3.38c-5.453-3.379-9.027.61-9.027.61s4.593-3.317 6.843 2.96v112.317c0 .773-.164 1.53-.492 2.214-.656 1.332-2.086 2.57-5.504 2.051zm0 0"
fill="#3c99d4"
/>
</svg>
<div class="flex-1" />
<div class="text-white">VSCode Server</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 m-2 rounded bg-warmGray-800 w-48"
on:click={() => goto('/service/new/minio')}
>
<img
alt="minio logo"
class="w-7 mx-auto pb-2"
src="https://cdn.coollabs.io/assets/coolify/services/minio/MINIO_Bird.png"
/>
<div class="flex-1" />
<div class="text-white">MinIO</div>
</div>
<div
class="text-center flex-col items-center cursor-pointer ease-in-out hover:scale-105 duration-100 border-2 border-dashed border-transparent hover:border-blue-500 p-2 m-2 rounded bg-warmGray-800 w-48"
on:click={() => goto('/service/new/wordpress')}
>
<svg class="w-14 mx-auto pb-2" viewBox="0 0 128 128">
<path
fill-rule="evenodd"
clip-rule="evenodd"
fill="white"
d="M64.094 126.224c34.275-.052 62.021-27.933 62.021-62.325 0-33.833-27.618-61.697-60.613-62.286C30.85.995 1.894 29.113 1.885 63.21c-.01 35.079 27.612 63.064 62.209 63.014zM63.993 4.63c32.907-.011 59.126 26.725 59.116 60.28-.011 31.679-26.925 58.18-59.092 58.187-32.771.007-59.125-26.563-59.124-59.608.002-32.193 26.766-58.848 59.1-58.859zM39.157 35.896c.538 1.793-.968 2.417-2.569 2.542-1.685.13-3.369.257-5.325.406 6.456 19.234 12.815 38.183 19.325 57.573.464-.759.655-.973.739-1.223 3.574-10.682 7.168-21.357 10.651-32.069.318-.977.16-2.271-.188-3.275-1.843-5.32-4.051-10.524-5.667-15.908-1.105-3.686-2.571-6.071-6.928-5.644-.742.073-1.648-1.524-2.479-2.349 1.005-.6 2.003-1.704 3.017-1.719a849.593 849.593 0 0126.618.008c1.018.017 2.016 1.15 3.021 1.765-.88.804-1.639 2.01-2.668 2.321-1.651.498-3.482.404-5.458.58l19.349 57.56c2.931-9.736 5.658-18.676 8.31-27.639 2.366-8.001.956-15.473-3.322-22.52-1.286-2.119-2.866-4.175-3.595-6.486-.828-2.629-1.516-5.622-1.077-8.259.745-4.469 4.174-6.688 8.814-7.113C74.333.881 34.431 9.317 19.728 34.922c5.66-.261 11.064-.604 16.472-.678 1.022-.013 2.717.851 2.957 1.652zm10.117 77.971c-.118.345-.125.729-.218 1.302 10.943 3.034 21.675 2.815 32.659-.886l-16.78-45.96c-5.37 15.611-10.52 30.575-15.661 45.544zm-8.456-2.078l-25.281-69.35c-11.405 22.278-2.729 56.268 25.281 69.35zm76.428-44.562c.802-10.534-2.832-25.119-5.97-27.125-.35 3.875-.106 8.186-1.218 12.114-2.617 9.255-5.817 18.349-8.899 27.468-3.35 9.912-6.832 19.779-10.257 29.666 16.092-9.539 24.935-23.618 26.344-42.123z"
/>
</svg>
<div class="flex-1" />
<div class="text-white">Wordpress</div>
</div>
</div>
{/if}
</div>

View File

@@ -26,9 +26,9 @@
<script>
export let allowRegistration;
export let sendErrors;
import { browser } from '$app/env';
import { session } from '$app/stores';
import { request } from '$lib/request';
import { toast } from '@zerodevx/svelte-toast';
import { fade } from 'svelte/transition';
@@ -83,7 +83,7 @@
>
<span class="sr-only">Use setting</span>
<span
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transition ease-in-out duration-200 transform"
class:translate-x-5={settings?.allowRegistration}
class:translate-x-0={!settings?.allowRegistration}
>
@@ -143,7 +143,7 @@
>
<span class="sr-only">Use setting</span>
<span
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"
class="pointer-events-none relative inline-block h-5 w-5 rounded-full bg-white shadow transition ease-in-out duration-200 transform"
class:translate-x-5={settings?.sendErrors}
class:translate-x-0={!settings?.sendErrors}
>

View File

@@ -6,7 +6,9 @@ import type {
GithubInstallations
} from 'src/global';
import { writable } from 'svelte/store';
export const settings = writable({
clientId: null
})
export const dashboard = writable<Dashboard>({
databases: {
deployed: []
@@ -48,7 +50,9 @@ export const application = writable<Application>({
general: {
deployId: null,
nickname: null,
workdir: null
workdir: null,
isPreviewDeploymentEnabled: false,
pullRequest: 0
},
build: {
pack: 'static',
@@ -76,6 +80,7 @@ export const application = writable<Application>({
secrets: []
}
});
export const prApplication = writable([]);
export const initConf = writable({});
@@ -97,7 +102,9 @@ export const initialApplication: Application = {
general: {
deployId: null,
nickname: null,
workdir: null
workdir: null,
isPreviewDeploymentEnabled: false,
pullRequest: 0
},
build: {
pack: 'static',
@@ -162,3 +169,17 @@ export const initialNewService = {
userPasswordAgain: null,
baseURL: null
};
export const newWordpressService = writable({
baseURL: null,
remoteDB: false,
database: {
host: null,
name: 'wordpress',
user: null,
password: null,
tablePrefix: 'wordpress'
},
wordpressExtraConfiguration: null
});
export const isPullRequestPermissionsGranted = writable(false);