- Update sequence a bit optimized.
- Dependency updates.
- Edge case on repo/branch selection handled.
- More default templates. Thanks to @SaraVieira
This commit is contained in:
Andras Bacsai 2021-04-06 23:22:48 +02:00 committed by GitHub
parent c691c52751
commit 703d941f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 2913 additions and 3152 deletions

View File

@ -11,4 +11,4 @@
"svelteBracketNewLine": true, "svelteBracketNewLine": true,
"svelteAllowShorthand": true, "svelteAllowShorthand": true,
"plugins": ["prettier-plugin-svelte"] "plugins": ["prettier-plugin-svelte"]
} }

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
preTasks() {
echo ' echo '
############################## ##############################
#### Pulling Git Updates ##### #### Pulling Git Updates #####
@ -39,9 +41,10 @@ if [ $? -ne 0 ]; then
##################################' ##################################'
exit 1 exit 1
fi fi
}
case "$1" in case "$1" in
"all") "all")
preTasks
echo ' echo '
################################# #################################
#### Rebuilding everything. ##### #### Rebuilding everything. #####
@ -49,6 +52,7 @@ case "$1" in
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type all docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type all
;; ;;
"coolify") "coolify")
preTasks
echo ' echo '
############################## ##############################
#### Rebuilding Coolify. ##### #### Rebuilding Coolify. #####
@ -56,6 +60,7 @@ case "$1" in
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type coolify docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type coolify
;; ;;
"proxy") "proxy")
preTasks
echo ' echo '
############################ ############################
#### Rebuilding Proxy. ##### #### Rebuilding Proxy. #####
@ -63,6 +68,7 @@ case "$1" in
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type proxy docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify:/data/coolify -u root -w /usr/src/app coolify-base node install/install.js --type proxy
;; ;;
"upgrade-phase-1") "upgrade-phase-1")
preTasks
echo ' echo '
################################ ################################
#### Upgrading Coolify P1. ##### #### Upgrading Coolify P1. #####

View File

@ -1,5 +1,5 @@
FROM coolify-base FROM coolify-base
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN yarn build RUN pnpm build
CMD ["yarn", "start"] CMD ["pnpm", "start"]
EXPOSE 3000 EXPOSE 3000

View File

@ -9,9 +9,10 @@ RUN apt update && apt install -y docker-ce-cli && apt clean all
FROM node:14 as modules FROM node:14 as modules
COPY --from=binaries /usr/bin/docker /usr/bin/docker COPY --from=binaries /usr/bin/docker /usr/bin/docker
COPY --from=binaries /usr/bin/envsubst /usr/bin/envsubst COPY --from=binaries /usr/bin/envsubst /usr/bin/envsubst
RUN curl -L https://pnpm.js.org/pnpm.js | node - add --global pnpm
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./package*.json . COPY ./package*.json .
RUN yarn install RUN pnpm install
FROM modules FROM modules
WORKDIR /usr/src/app WORKDIR /usr/src/app

View File

@ -13,7 +13,8 @@ program
program.parse(process.argv) program.parse(process.argv)
if (program.check) { const options = program.opts()
if (options.check) {
checkConfig().then(() => { checkConfig().then(() => {
console.log('Config: OK') console.log('Config: OK')
}).catch((err) => { }).catch((err) => {
@ -26,17 +27,17 @@ if (program.check) {
console.error(`Please run as root! Current user: ${user}`) console.error(`Please run as root! Current user: ${user}`)
process.exit(1) process.exit(1)
} }
shell.exec(`docker network create ${process.env.DOCKER_NETWORK} --driver overlay`, { silent: !program.debug }) shell.exec(`docker network create ${process.env.DOCKER_NETWORK} --driver overlay`, { silent: !options.debug })
shell.exec('docker build -t coolify -f install/Dockerfile .') shell.exec('docker build -t coolify -f install/Dockerfile .')
if (program.type === 'all') { if (options.type === 'all') {
shell.exec('docker stack rm coollabs-coolify', { silent: !program.debug }) shell.exec('docker stack rm coollabs-coolify', { silent: !options.debug })
} else if (program.type === 'coolify') { } else if (options.type === 'coolify') {
shell.exec('docker service rm coollabs-coolify_coolify') shell.exec('docker service rm coollabs-coolify_coolify')
} else if (program.type === 'proxy') { } else if (options.type === 'proxy') {
shell.exec('docker service rm coollabs-coolify_proxy') shell.exec('docker service rm coollabs-coolify_proxy')
} }
if (program.type !== 'upgrade') { if (options.type !== 'upgrade') {
shell.exec('set -a && source .env && set +a && envsubst < install/coolify-template.yml | docker stack deploy -c - coollabs-coolify', { silent: !program.debug, shell: '/bin/bash' }) shell.exec('set -a && source .env && set +a && envsubst < install/coolify-template.yml | docker stack deploy -c - coollabs-coolify', { silent: !options.debug, shell: '/bin/bash' })
} }
} }

View File

@ -10,13 +10,13 @@ program
.option('-t, --type <type>', 'Deploy type.') .option('-t, --type <type>', 'Deploy type.')
program.parse(process.argv) program.parse(process.argv)
const options = program.opts()
if (user !== 'root') { if (user !== 'root') {
console.error(`Please run as root! Current user: ${user}`) console.error(`Please run as root! Current user: ${user}`)
process.exit(1) process.exit(1)
} }
if (program.type === 'upgrade') { if (options.type === 'upgrade') {
shell.exec('docker service rm coollabs-coolify_coolify') shell.exec('docker service rm coollabs-coolify_coolify')
shell.exec('set -a && source .env && set +a && envsubst < install/coolify-template.yml | docker stack deploy -c - coollabs-coolify', { silent: !program.debug, shell: '/bin/bash' }) shell.exec('set -a && source .env && set +a && envsubst < install/coolify-template.yml | docker stack deploy -c - coollabs-coolify', { silent: !options.debug, shell: '/bin/bash' })
} }

View File

@ -16,45 +16,45 @@
"build:svite": "svite build" "build:svite": "svite build"
}, },
"dependencies": { "dependencies": {
"@roxi/routify": "^2.7.3", "@roxi/routify": "^2.15.1",
"@zerodevx/svelte-toast": "^0.1.4", "@zerodevx/svelte-toast": "^0.2.0",
"axios": "^0.21.0", "axios": "^0.21.1",
"commander": "^6.2.1", "commander": "^7.2.0",
"compare-versions": "^3.6.0", "compare-versions": "^3.6.0",
"cuid": "^2.1.8", "cuid": "^2.1.8",
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"deepmerge": "^4.2.2", "deepmerge": "^4.2.2",
"dockerode": "^3.2.1", "dockerode": "^3.2.1",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"fastify": "^3.9.1", "fastify": "^3.14.1",
"fastify-env": "^2.1.0", "fastify-env": "^2.1.0",
"fastify-jwt": "^2.1.3", "fastify-jwt": "^2.4.0",
"fastify-plugin": "^3.0.0", "fastify-plugin": "^3.0.0",
"fastify-static": "^3.3.0", "fastify-static": "^4.0.1",
"generate-password": "^1.6.0", "generate-password": "^1.6.0",
"js-yaml": "^4.0.0", "js-yaml": "^4.0.0",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"mongoose": "^5.11.4", "mongoose": "^5.12.3",
"shelljs": "^0.8.4", "shelljs": "^0.8.4",
"svelte-select": "^3.17.0", "svelte-select": "^3.17.0",
"unique-names-generator": "^4.4.0" "unique-names-generator": "^4.4.0"
}, },
"devDependencies": { "devDependencies": {
"mongodb-memory-server-core": "^6.9.3", "mongodb-memory-server-core": "^6.9.6",
"nodemon": "^2.0.6", "nodemon": "^2.0.7",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"postcss": "^7.0.35", "postcss": "^8.2.9",
"postcss-import": "^12.0.1", "postcss-import": "^14.0.1",
"postcss-load-config": "^3.0.0", "postcss-load-config": "^3.0.1",
"postcss-preset-env": "^6.7.0", "postcss-preset-env": "^6.7.0",
"prettier": "1.19", "prettier": "2.2.1",
"prettier-plugin-svelte": "^2.1.6", "prettier-plugin-svelte": "^2.2.0",
"standard": "^16.0.3", "standard": "^16.0.3",
"svelte": "^3.29.7", "svelte": "^3.37.0",
"svelte-hmr": "^0.12.2", "svelte-hmr": "^0.14.0",
"svelte-preprocess": "^4.6.1", "svelte-preprocess": "^4.6.1",
"svite": "0.8.1", "svite": "0.8.1",
"tailwindcss": "compat" "tailwindcss": "2.1.1"
}, },
"keywords": [ "keywords": [
"svelte", "svelte",

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@
</script> </script>
<style lang="postcss"> <style lang="postcss">
:global(.main) {
width: calc(100% - 4rem);
margin-left: 4rem;
}
:global(._toastMsg) { :global(._toastMsg) {
@apply text-sm font-bold !important; @apply text-sm font-bold !important;
} }
@ -57,6 +61,22 @@
:global(.h-271) { :global(.h-271) {
min-height: 271px !important; min-height: 271px !important;
} }
:global(.repository-select-search .listItem .item),
:global(.repository-select-search .empty) {
@apply text-sm py-3 font-bold bg-warmGray-800 text-white cursor-pointer border-none hover:bg-warmGray-700 !important;
}
:global(.repository-select-search .listContainer) {
@apply bg-transparent !important;
}
:global(.repository-select-search .clearSelect) {
@apply text-white cursor-pointer !important;
}
:global(.repository-select-search .selectedItem) {
@apply text-white relative cursor-pointer font-bold text-sm flex items-center !important;
}
</style> </style>
<SvelteToast options="{options}" /> <SvelteToast options="{options}" />

View File

@ -1,24 +1,46 @@
<script> <script>
export let loading, branches; export let loading, branches;
import { isActive } from "@roxi/routify";
import { application } from "@store"; import { application } from "@store";
import Select from "svelte-select";
const selectedValue =
!$isActive("/application/new") && $application.repository.branch
function handleSelect(event) {
$application.repository.branch = null;
setTimeout(() => {
$application.repository.branch = event.detail.value;
}, 1);
}
</script> </script>
{#if loading} {#if loading}
<div class="grid grid-cols-1"> <div class="grid grid-cols-1">
<label for="branch">Branch</label> <label for="branch">Branch</label>
<select disabled> <div class="repository-select-search col-span-2">
<option selected>Loading branches</option> <Select
</select> containerClasses="w-full border-none bg-transparent"
placeholder="Loading branches..."
isDisabled
/>
</div>
</div> </div>
{:else} {:else}
<div class="grid grid-cols-1"> <div class="grid grid-cols-1">
<label for="branch">Branch</label> <label for="branch">Branch</label>
<!-- svelte-ignore a11y-no-onchange --> <div class="repository-select-search col-span-2">
<select id="branch" bind:value="{$application.repository.branch}"> <Select
<option disabled selected>Select a branch</option> containerClasses="w-full border-none bg-transparent"
{#each branches as branch} on:select="{handleSelect}"
<option value="{branch.name}" class="font-bold">{branch.name}</option> selectedValue="{selectedValue}"
{/each} isClearable="{false}"
</select> items="{branches.map(b => ({ label: b.name, value: b.name }))}"
showIndicator="{$isActive('/application/new')}"
noOptionsMessage="No branches found"
placeholder="Select a branch"
isDisabled="{!$isActive('/application/new')}"
/>
</div>
</div> </div>
{/if} {/if}

View File

@ -29,6 +29,7 @@
async function loadBranches() { async function loadBranches() {
loading.branches = true; loading.branches = true;
if ($isActive("/application/new")) $application.repository.branch = null
const selectedRepository = repositories.find( const selectedRepository = repositories.find(
r => r.id === $application.repository.id, r => r.id === $application.repository.id,
); );
@ -80,7 +81,6 @@
$application.github.installation.id, $application.github.installation.id,
page, page,
); );
repositories = repositories.concat(repos.repositories); repositories = repositories.concat(repos.repositories);
} }
} }
@ -97,8 +97,10 @@
} }
} catch (error) { } catch (error) {
return false; return false;
} finally {
loading.github = false;
} }
loading.github = false;
} }
function modifyGithubAppConfig() { function modifyGithubAppConfig() {
const left = screen.width / 2 - 1020 / 2; const left = screen.width / 2 - 1020 / 2;

View File

@ -1,22 +1,3 @@
<style lang="postcss">
:global(.repository-select-search .listItem .item),
:global(.repository-select-search .empty) {
@apply text-sm py-3 font-bold bg-warmGray-800 text-white cursor-pointer border-none hover:bg-warmGray-700 !important;
}
:global(.repository-select-search .listContainer) {
@apply bg-transparent !important;
}
:global(.repository-select-search .clearSelect) {
@apply text-white cursor-pointer !important;
}
:global(.repository-select-search .selectedItem) {
@apply text-white relative cursor-pointer font-bold text-sm flex items-center !important;
}
</style>
<script> <script>
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import { isActive } from "@roxi/routify"; import { isActive } from "@roxi/routify";
@ -53,6 +34,7 @@
selectedValue="{selectedValue}" selectedValue="{selectedValue}"
isClearable="{false}" isClearable="{false}"
items="{items}" items="{items}"
showIndicator="{$isActive('/application/new')}"
noOptionsMessage="No Repositories found" noOptionsMessage="No Repositories found"
placeholder="Select a Repository" placeholder="Select a Repository"
isDisabled="{!$isActive('/application/new')}" isDisabled="{!$isActive('/application/new')}"

View File

@ -2,7 +2,7 @@
import { redirect, isActive } from "@roxi/routify"; import { redirect, isActive } from "@roxi/routify";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { toast } from "@zerodevx/svelte-toast"; import { toast } from "@zerodevx/svelte-toast";
import templates from "../../../utils/templates";
import { application, fetch, deployments } from "@store"; import { application, fetch, deployments } from "@store";
import General from "./ActiveTab/General.svelte"; import General from "./ActiveTab/General.svelte";
import BuildStep from "./ActiveTab/BuildStep.svelte"; import BuildStep from "./ActiveTab/BuildStep.svelte";
@ -57,30 +57,43 @@
$application.build.pack = "custom"; $application.build.pack = "custom";
toast.push("Custom Dockerfile found. Build pack set to custom."); toast.push("Custom Dockerfile found. Build pack set to custom.");
} else if (packageJson) { } else if (packageJson) {
// Check here for things like nextjs,react,vue,blablabla
const { content } = await $fetch(packageJson.git_url); const { content } = await $fetch(packageJson.git_url);
const packageJsonContent = JSON.parse(atob(content)); const packageJsonContent = JSON.parse(atob(content));
const checkPackageJSONContents = dep => {
if (packageJsonContent.dependencies.hasOwnProperty("next")) { return(
// Next.js packageJsonContent?.dependencies?.hasOwnProperty(dep) ||
$application.build.pack = "nodejs"; packageJsonContent?.devDependencies?.hasOwnProperty(dep)
$application.build.command.installation = "yarn install";
if (packageJsonContent.scripts.hasOwnProperty("build")) {
$application.build.command.build = `yarn build`;
}
toast.push("Next.js App detected. Build pack set to Node.js.");
} else if (packageJsonContent.dependencies.hasOwnProperty("react")) {
// CRA
$application.build.pack = "static";
$application.publish.directory = "build";
$application.build.command.installation = "yarn install";
if (packageJsonContent.scripts.hasOwnProperty("build")) {
$application.build.command.build = `yarn build`;
}
toast.push(
"React App detected. Build pack set to static with build phase.",
); );
} };
Object.keys(templates).map(dep => {
if (checkPackageJSONContents(dep)) {
const config = templates[dep];
$application.build.pack = config.pack;
if (config.installation) {
$application.build.command.installation = config.installation;
}
if (config.port) {
$application.publish.port = config.port;
}
if (config.directory) {
$application.publish.directory = config.directory;
}
if (
packageJsonContent.scripts.hasOwnProperty("build") &&
config.build
) {
$application.build.command.build = config.build;
}
toast.push(
`${config.name} App detected. Default values set.`,
);
}
});
} }
} catch (error) { } catch (error) {
// Nothing detected // Nothing detected
@ -106,7 +119,7 @@
</script> </script>
{#if loading} {#if loading}
<Loading github githubLoadingText="Scanning repository 🤖" /> <Loading github githubLoadingText="Scanning repository..." />
{:else} {:else}
<div class="block text-center py-4"> <div class="block text-center py-4">
<nav <nav

View File

@ -50,7 +50,7 @@
{#if fullscreen} {#if fullscreen}
{#if github} {#if github}
<div class="fixed left-0 top-0 flex flex-wrap content-center h-full w-full"> <div class="fixed left-0 top-0 flex flex-wrap content-center h-full w-full">
<div class="w-full flex justify-center items-center"> <div class="main flex justify-center items-center">
<div class="w-64"> <div class="w-64">
<svg <svg
class=" w-28 animate-bounce mx-auto" class=" w-28 animate-bounce mx-auto"
@ -65,15 +65,15 @@
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" 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 ></path></svg
> >
<div class="w-full text-xl font-bold text-center"> <div class="text-xl font-bold text-center">
{githubLoadingText} {githubLoadingText}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{:else} {:else}
<div class="fixed left-0 top-0 flex flex-wrap content-center h-full w-full"> <div class="main fixed left-0 top-0 flex flex-wrap content-center h-full">
<span class="loader"></span> <span class=" loader"></span>
</div> </div>
{/if} {/if}
{/if} {/if}

View File

@ -17,6 +17,12 @@ :root {
--toastFont: 'Inter'; --toastFont: 'Inter';
} }
.border-gradient {
border-bottom: 2px solid transparent;
border-image: linear-gradient(0.25turn, rgba(255, 249, 34), rgba(255, 0, 128), rgba(56, 2, 155, 0));
border-image-slice: 1;
}
[aria-label][role~="tooltip"]::after { [aria-label][role~="tooltip"]::after {
background: rgba(41, 37, 36, 0.9); background: rgba(41, 37, 36, 0.9);
color: white; color: white;

View File

@ -2,10 +2,6 @@
.min-w-4rem { .min-w-4rem {
min-width: 4rem; min-width: 4rem;
} }
.main {
width: calc(100% - 4rem);
margin-left: 4rem;
}
</style> </style>
<script> <script>

View File

@ -151,7 +151,6 @@ import Tooltip from "../../components/Tooltip/Tooltip.svelte";
<div class="border border-warmGray-700 h-8"></div> <div class="border border-warmGray-700 h-8"></div>
<Tooltip position="bottom" label="Logs" > <Tooltip position="bottom" label="Logs" >
<button <button
class="icon" class="icon"
class:text-warmGray-700="{$isActive('/application/new')}" class:text-warmGray-700="{$isActive('/application/new')}"
disabled="{$isActive('/application/new')}" disabled="{$isActive('/application/new')}"

View File

@ -43,7 +43,7 @@
<p <p
class="mt-1 pb-8 font-extrabold text-white text-5xl sm:tracking-tight lg:text-6xl text-center" class="mt-1 pb-8 font-extrabold text-white text-5xl sm:tracking-tight lg:text-6xl text-center"
> >
Coolify <span class="border-gradient">Coolify</span>
</p> </p>
<h2 class="text-2xl md:text-3xl font-extrabold text-white"> <h2 class="text-2xl md:text-3xl font-extrabold text-white">
An open-source, hassle-free, self-hostable<br /> An open-source, hassle-free, self-hostable<br />

51
src/utils/templates.js Normal file
View File

@ -0,0 +1,51 @@
const defaultBuildAndDeploy = {
installation: 'yarn install',
build: 'yarn build'
}
const templates = {
next: {
pack: 'nodejs',
...defaultBuildAndDeploy,
port: 3000,
name: 'Next.js'
},
nuxt: {
pack: 'nodejs',
...defaultBuildAndDeploy,
port: 8080,
name: 'Nuxt'
},
'react-scripts': {
pack: 'static',
...defaultBuildAndDeploy,
directory: 'build',
name: 'Create React'
},
'parcel-bundler': {
pack: 'static',
...defaultBuildAndDeploy,
directory: 'dist',
name: 'Parcel'
},
'vue-cli-service': {
pack: 'static',
...defaultBuildAndDeploy,
directory: 'dist',
name: 'Vue CLI'
},
gatsby: {
pack: 'static',
...defaultBuildAndDeploy,
directory: 'public',
name: 'Gatsby'
},
'preact-cli': {
pack: 'static',
...defaultBuildAndDeploy,
directory: 'build',
name: 'Preact CLI'
}
}
export default templates