@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "coolify",
|
"name": "coolify",
|
||||||
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
|
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
|
||||||
"version": "2.0.28",
|
"version": "2.0.29",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
|
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
|
||||||
|
19
prisma/migrations/20220311213422_autodeploy/migration.sql
Normal file
19
prisma/migrations/20220311213422_autodeploy/migration.sql
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_ApplicationSettings" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"applicationId" TEXT NOT NULL,
|
||||||
|
"dualCerts" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"debug" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"previews" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"autodeploy" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "ApplicationSettings_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_ApplicationSettings" ("applicationId", "createdAt", "debug", "dualCerts", "id", "previews", "updatedAt") SELECT "applicationId", "createdAt", "debug", "dualCerts", "id", "previews", "updatedAt" FROM "ApplicationSettings";
|
||||||
|
DROP TABLE "ApplicationSettings";
|
||||||
|
ALTER TABLE "new_ApplicationSettings" RENAME TO "ApplicationSettings";
|
||||||
|
CREATE UNIQUE INDEX "ApplicationSettings_applicationId_key" ON "ApplicationSettings"("applicationId");
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
@@ -104,6 +104,7 @@ model ApplicationSettings {
|
|||||||
dualCerts Boolean @default(false)
|
dualCerts Boolean @default(false)
|
||||||
debug Boolean @default(false)
|
debug Boolean @default(false)
|
||||||
previews Boolean @default(false)
|
previews Boolean @default(false)
|
||||||
|
autodeploy Boolean @default(true)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
@@ -4,13 +4,19 @@ import { promises as fs } from 'fs';
|
|||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const { applicationId, tag, port, startCommand, workdir, baseDirectory } = data;
|
const { applicationId, tag, port, startCommand, workdir, baseDirectory } = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm = startCommand.includes('pnpm');
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
|
if (isPnpm) {
|
||||||
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
|
}
|
||||||
Dockerfile.push(
|
Dockerfile.push(
|
||||||
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${baseDirectory || ''} ./`
|
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${baseDirectory || ''} ./`
|
||||||
);
|
);
|
||||||
|
|
||||||
Dockerfile.push(`EXPOSE ${port}`);
|
Dockerfile.push(`EXPOSE ${port}`);
|
||||||
Dockerfile.push(`CMD ${startCommand}`);
|
Dockerfile.push(`CMD ${startCommand}`);
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
|
@@ -13,7 +13,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm =
|
||||||
|
installCommand.includes('pnpm') ||
|
||||||
|
buildCommand.includes('pnpm') ||
|
||||||
|
startCommand.includes('pnpm');
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -32,6 +35,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isPnpm) {
|
||||||
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||||
try {
|
try {
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
await fs.stat(`${workdir}/yarn.lock`);
|
||||||
|
@@ -13,7 +13,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm =
|
||||||
|
installCommand.includes('pnpm') ||
|
||||||
|
buildCommand.includes('pnpm') ||
|
||||||
|
startCommand.includes('pnpm');
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -32,6 +35,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isPnpm) {
|
||||||
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||||
try {
|
try {
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
await fs.stat(`${workdir}/yarn.lock`);
|
||||||
|
@@ -13,7 +13,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm =
|
||||||
|
installCommand.includes('pnpm') ||
|
||||||
|
buildCommand.includes('pnpm') ||
|
||||||
|
startCommand.includes('pnpm');
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -32,6 +35,10 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isPnpm) {
|
||||||
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||||
try {
|
try {
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
await fs.stat(`${workdir}/yarn.lock`);
|
||||||
|
@@ -11,6 +11,7 @@ import { version as currentVersion } from '../../package.json';
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import Cookie from 'cookie';
|
import Cookie from 'cookie';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import cuid from 'cuid';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
@@ -13,7 +13,7 @@ export function findBuildPack(pack, packageManager = 'npm') {
|
|||||||
if (pack === 'node') {
|
if (pack === 'node') {
|
||||||
return {
|
return {
|
||||||
...metaData,
|
...metaData,
|
||||||
installCommand: null,
|
...defaultBuildAndDeploy(packageManager),
|
||||||
buildCommand: null,
|
buildCommand: null,
|
||||||
startCommand: null,
|
startCommand: null,
|
||||||
publishDirectory: null,
|
publishDirectory: null,
|
||||||
|
@@ -58,15 +58,6 @@ export async function removeApplication({ id, teamId }) {
|
|||||||
const id = containerObj.ID;
|
const id = containerObj.ID;
|
||||||
const preview = containerObj.Image.split('-')[1];
|
const preview = containerObj.Image.split('-')[1];
|
||||||
await removeDestinationDocker({ id, engine: destinationDocker.engine });
|
await removeDestinationDocker({ id, engine: destinationDocker.engine });
|
||||||
try {
|
|
||||||
if (preview) {
|
|
||||||
await removeProxyConfiguration({ domain: `${preview}.${domain}` });
|
|
||||||
} else {
|
|
||||||
await removeProxyConfiguration({ domain });
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,8 +70,8 @@ export async function removeApplication({ id, teamId }) {
|
|||||||
|
|
||||||
export async function getApplicationWebhook({ projectId, branch }) {
|
export async function getApplicationWebhook({ projectId, branch }) {
|
||||||
try {
|
try {
|
||||||
let body = await prisma.application.findFirst({
|
let application = await prisma.application.findFirst({
|
||||||
where: { projectId, branch },
|
where: { projectId, branch, settings: { autodeploy: true } },
|
||||||
include: {
|
include: {
|
||||||
destinationDocker: true,
|
destinationDocker: true,
|
||||||
settings: true,
|
settings: true,
|
||||||
@@ -88,30 +79,38 @@ export async function getApplicationWebhook({ projectId, branch }) {
|
|||||||
secrets: true
|
secrets: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (application.gitSource?.githubApp?.clientSecret) {
|
||||||
if (body.gitSource?.githubApp?.clientSecret) {
|
application.gitSource.githubApp.clientSecret = decrypt(
|
||||||
body.gitSource.githubApp.clientSecret = decrypt(body.gitSource.githubApp.clientSecret);
|
application.gitSource.githubApp.clientSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body.gitSource?.githubApp?.webhookSecret) {
|
if (application.gitSource?.githubApp?.webhookSecret) {
|
||||||
body.gitSource.githubApp.webhookSecret = decrypt(body.gitSource.githubApp.webhookSecret);
|
application.gitSource.githubApp.webhookSecret = decrypt(
|
||||||
|
application.gitSource.githubApp.webhookSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body.gitSource?.githubApp?.privateKey) {
|
if (application.gitSource?.githubApp?.privateKey) {
|
||||||
body.gitSource.githubApp.privateKey = decrypt(body.gitSource.githubApp.privateKey);
|
application.gitSource.githubApp.privateKey = decrypt(
|
||||||
|
application.gitSource.githubApp.privateKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.gitSource?.gitlabApp?.appSecret) {
|
if (application?.gitSource?.gitlabApp?.appSecret) {
|
||||||
body.gitSource.gitlabApp.appSecret = decrypt(body.gitSource.gitlabApp.appSecret);
|
application.gitSource.gitlabApp.appSecret = decrypt(
|
||||||
|
application.gitSource.gitlabApp.appSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.gitSource?.gitlabApp?.webhookToken) {
|
if (application?.gitSource?.gitlabApp?.webhookToken) {
|
||||||
body.gitSource.gitlabApp.webhookToken = decrypt(body.gitSource.gitlabApp.webhookToken);
|
application.gitSource.gitlabApp.webhookToken = decrypt(
|
||||||
|
application.gitSource.gitlabApp.webhookToken
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.secrets.length > 0) {
|
if (application?.secrets.length > 0) {
|
||||||
body.secrets = body.secrets.map((s) => {
|
application.secrets = application.secrets.map((s) => {
|
||||||
s.value = decrypt(s.value);
|
s.value = decrypt(s.value);
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return { ...application };
|
||||||
return { ...body };
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw { status: 404, body: { message: e.message } };
|
throw { status: 404, body: { message: e.message } };
|
||||||
}
|
}
|
||||||
@@ -157,24 +156,41 @@ export async function getApplication({ id, teamId }) {
|
|||||||
return { ...body };
|
return { ...body };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function configureGitRepository({ id, repository, branch, projectId, webhookToken }) {
|
export async function configureGitRepository({
|
||||||
|
id,
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
projectId,
|
||||||
|
webhookToken,
|
||||||
|
autodeploy
|
||||||
|
}) {
|
||||||
if (webhookToken) {
|
if (webhookToken) {
|
||||||
const encryptedWebhookToken = encrypt(webhookToken);
|
const encryptedWebhookToken = encrypt(webhookToken);
|
||||||
return await prisma.application.update({
|
await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
repository,
|
repository,
|
||||||
branch,
|
branch,
|
||||||
projectId,
|
projectId,
|
||||||
gitSource: { update: { gitlabApp: { update: { webhookToken: encryptedWebhookToken } } } }
|
gitSource: { update: { gitlabApp: { update: { webhookToken: encryptedWebhookToken } } } },
|
||||||
|
settings: { update: { autodeploy } }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return await prisma.application.update({
|
await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: { repository, branch, projectId }
|
data: { repository, branch, projectId, settings: { update: { autodeploy } } }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (!autodeploy) {
|
||||||
|
const applications = await prisma.application.findMany({ where: { branch, projectId } });
|
||||||
|
for (const application of applications) {
|
||||||
|
await prisma.applicationSettings.updateMany({
|
||||||
|
where: { applicationId: application.id },
|
||||||
|
data: { autodeploy: false }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function configureBuildPack({ id, buildPack }) {
|
export async function configureBuildPack({ id, buildPack }) {
|
||||||
@@ -209,10 +225,14 @@ export async function configureApplication({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setApplicationSettings({ id, debug, previews, dualCerts }) {
|
export async function checkDoubleBranch(branch, projectId) {
|
||||||
|
const applications = await prisma.application.findMany({ where: { branch, projectId } });
|
||||||
|
return applications.length > 1;
|
||||||
|
}
|
||||||
|
export async function setApplicationSettings({ id, debug, previews, dualCerts, autodeploy }) {
|
||||||
return await prisma.application.update({
|
return await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: { settings: { update: { debug, previews, dualCerts } } },
|
data: { settings: { update: { debug, previews, dualCerts, autodeploy } } },
|
||||||
include: { destinationDocker: true }
|
include: { destinationDocker: true }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
secrets,
|
secrets,
|
||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
|
const isPnpm = installCommand.includes('pnpm') || buildCommand.includes('pnpm');
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
Dockerfile.push(`FROM ${imageForBuild}`);
|
Dockerfile.push(`FROM ${imageForBuild}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
@@ -35,7 +36,10 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// TODO: If build command defined, install command should be the default yarn install
|
if (isPnpm) {
|
||||||
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
|
}
|
||||||
if (installCommand) {
|
if (installCommand) {
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||||
try {
|
try {
|
||||||
|
@@ -99,7 +99,8 @@ export async function letsEncrypt(domain, id = null, isCoolify = false) {
|
|||||||
export async function generateSSLCerts() {
|
export async function generateSSLCerts() {
|
||||||
const ssls = [];
|
const ssls = [];
|
||||||
const applications = await db.prisma.application.findMany({
|
const applications = await db.prisma.application.findMany({
|
||||||
include: { destinationDocker: true, settings: true }
|
include: { destinationDocker: true, settings: true },
|
||||||
|
orderBy: { createdAt: 'desc' }
|
||||||
});
|
});
|
||||||
for (const application of applications) {
|
for (const application of applications) {
|
||||||
const {
|
const {
|
||||||
@@ -139,7 +140,8 @@ export async function generateSSLCerts() {
|
|||||||
plausibleAnalytics: true,
|
plausibleAnalytics: true,
|
||||||
vscodeserver: true,
|
vscodeserver: true,
|
||||||
wordpress: true
|
wordpress: true
|
||||||
}
|
},
|
||||||
|
orderBy: { createdAt: 'desc' }
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
|
@@ -120,7 +120,7 @@ buildWorker.on('completed', async (job: Bullmq.Job) => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
} finally {
|
} finally {
|
||||||
const workdir = `/tmp/build-sources/${job.data.repository}/`;
|
const workdir = `/tmp/build-sources/${job.data.repository}/${job.data.build_id}`;
|
||||||
await asyncExecShell(`rm -fr ${workdir}`);
|
await asyncExecShell(`rm -fr ${workdir}`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@@ -108,11 +108,9 @@
|
|||||||
try {
|
try {
|
||||||
loading = true;
|
loading = true;
|
||||||
await post(`/applications/${id}/stop.json`, {});
|
await post(`/applications/${id}/stop.json`, {});
|
||||||
isRunning = false;
|
return window.location.reload();
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
|
||||||
loading = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -25,9 +25,11 @@
|
|||||||
let selected = {
|
let selected = {
|
||||||
projectId: undefined,
|
projectId: undefined,
|
||||||
repository: undefined,
|
repository: undefined,
|
||||||
branch: undefined
|
branch: undefined,
|
||||||
|
autodeploy: application.settings.autodeploy || true
|
||||||
};
|
};
|
||||||
let showSave = false;
|
let showSave = false;
|
||||||
|
|
||||||
async function loadRepositoriesByPage(page = 0) {
|
async function loadRepositoriesByPage(page = 0) {
|
||||||
return await get(`${apiUrl}/installation/repositories?per_page=100&page=${page}`, {
|
return await get(`${apiUrl}/installation/repositories?per_page=100&page=${page}`, {
|
||||||
Authorization: `token ${$gitTokens.githubToken}`
|
Authorization: `token ${$gitTokens.githubToken}`
|
||||||
@@ -69,7 +71,14 @@
|
|||||||
`/applications/${id}/configuration/repository.json?repository=${selected.repository}&branch=${selected.branch}`
|
`/applications/${id}/configuration/repository.json?repository=${selected.repository}&branch=${selected.branch}`
|
||||||
);
|
);
|
||||||
if (data.used) {
|
if (data.used) {
|
||||||
errorNotification('This branch is already used by another application.');
|
const sure = confirm(
|
||||||
|
`This branch is already used by another application. Webhooks won't work in this case for both applications. Are you sure you want to use it?`
|
||||||
|
);
|
||||||
|
if (sure) {
|
||||||
|
selected.autodeploy = false;
|
||||||
|
showSave = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
showSave = false;
|
showSave = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
let projects = [];
|
let projects = [];
|
||||||
let branches = [];
|
let branches = [];
|
||||||
let showSave = false;
|
let showSave = false;
|
||||||
|
let autodeploy = application.settings.autodeploy || true;
|
||||||
|
|
||||||
let selected = {
|
let selected = {
|
||||||
group: undefined,
|
group: undefined,
|
||||||
@@ -138,7 +139,14 @@
|
|||||||
`/applications/${id}/configuration/repository.json?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
|
`/applications/${id}/configuration/repository.json?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
|
||||||
);
|
);
|
||||||
if (data.used) {
|
if (data.used) {
|
||||||
errorNotification('This branch is already used by another application.');
|
const sure = confirm(
|
||||||
|
`This branch is already used by another application. Webhooks won't work in this case for both applications. Are you sure you want to use it?`
|
||||||
|
);
|
||||||
|
if (sure) {
|
||||||
|
autodeploy = false;
|
||||||
|
showSave = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
showSave = false;
|
showSave = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -235,10 +243,14 @@
|
|||||||
|
|
||||||
const url = `/applications/${id}/configuration/repository.json`;
|
const url = `/applications/${id}/configuration/repository.json`;
|
||||||
try {
|
try {
|
||||||
|
const repository = `${selected.group.full_path.replace('-personal', '')}/${
|
||||||
|
selected.project.name
|
||||||
|
}`;
|
||||||
await post(url, {
|
await post(url, {
|
||||||
repository: `${selected.group.full_path}/${selected.project.name}`,
|
repository,
|
||||||
branch: selected.branch.name,
|
branch: selected.branch.name,
|
||||||
projectId: selected.project.id,
|
projectId: selected.project.id,
|
||||||
|
autodeploy,
|
||||||
webhookToken
|
webhookToken
|
||||||
});
|
});
|
||||||
return await goto(from || `/applications/${id}/configuration/buildpack`);
|
return await goto(from || `/applications/${id}/configuration/buildpack`);
|
||||||
|
@@ -30,14 +30,21 @@ export const post: RequestHandler = async (event) => {
|
|||||||
if (status === 401) return { status, body };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
let { repository, branch, projectId, webhookToken } = await event.request.json();
|
let { repository, branch, projectId, webhookToken, autodeploy } = await event.request.json();
|
||||||
|
|
||||||
repository = repository.toLowerCase();
|
repository = repository.toLowerCase();
|
||||||
branch = branch.toLowerCase();
|
branch = branch.toLowerCase();
|
||||||
projectId = Number(projectId);
|
projectId = Number(projectId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await db.configureGitRepository({ id, repository, branch, projectId, webhookToken });
|
await db.configureGitRepository({
|
||||||
|
id,
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
projectId,
|
||||||
|
webhookToken,
|
||||||
|
autodeploy
|
||||||
|
});
|
||||||
return { status: 201 };
|
return { status: 201 };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return ErrorHandler(error);
|
return ErrorHandler(error);
|
||||||
|
@@ -56,6 +56,7 @@
|
|||||||
let debug = application.settings.debug;
|
let debug = application.settings.debug;
|
||||||
let previews = application.settings.previews;
|
let previews = application.settings.previews;
|
||||||
let dualCerts = application.settings.dualCerts;
|
let dualCerts = application.settings.dualCerts;
|
||||||
|
let autodeploy = application.settings.autodeploy;
|
||||||
|
|
||||||
if (browser && window.location.hostname === 'demo.coolify.io' && !application.fqdn) {
|
if (browser && window.location.hostname === 'demo.coolify.io' && !application.fqdn) {
|
||||||
application.fqdn = `http://${cuid()}.demo.coolify.io`;
|
application.fqdn = `http://${cuid()}.demo.coolify.io`;
|
||||||
@@ -75,10 +76,32 @@
|
|||||||
if (name === 'dualCerts') {
|
if (name === 'dualCerts') {
|
||||||
dualCerts = !dualCerts;
|
dualCerts = !dualCerts;
|
||||||
}
|
}
|
||||||
|
if (name === 'autodeploy') {
|
||||||
|
autodeploy = !autodeploy;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await post(`/applications/${id}/settings.json`, { previews, debug, dualCerts });
|
await post(`/applications/${id}/settings.json`, {
|
||||||
|
previews,
|
||||||
|
debug,
|
||||||
|
dualCerts,
|
||||||
|
autodeploy,
|
||||||
|
branch: application.branch,
|
||||||
|
projectId: application.projectId
|
||||||
|
});
|
||||||
return toast.push('Settings saved.');
|
return toast.push('Settings saved.');
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
|
if (name === 'debug') {
|
||||||
|
debug = !debug;
|
||||||
|
}
|
||||||
|
if (name === 'previews') {
|
||||||
|
previews = !previews;
|
||||||
|
}
|
||||||
|
if (name === 'dualCerts') {
|
||||||
|
dualCerts = !dualCerts;
|
||||||
|
}
|
||||||
|
if (name === 'autodeploy') {
|
||||||
|
autodeploy = !autodeploy;
|
||||||
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,22 +406,23 @@
|
|||||||
<div class="flex space-x-1 pb-5 font-bold">
|
<div class="flex space-x-1 pb-5 font-bold">
|
||||||
<div class="title">Features</div>
|
<div class="title">Features</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <ul class="mt-2 divide-y divide-stone-800">
|
|
||||||
<Setting
|
|
||||||
bind:setting={forceSSL}
|
|
||||||
on:click={() => changeSettings('forceSSL')}
|
|
||||||
title="Force https"
|
|
||||||
description="Creates a https redirect for all requests from http and also generates a https certificate for the domain through Let's Encrypt."
|
|
||||||
/>
|
|
||||||
</ul> -->
|
|
||||||
<div class="px-10 pb-10">
|
<div class="px-10 pb-10">
|
||||||
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
<Setting
|
||||||
|
isCenter={false}
|
||||||
|
bind:setting={autodeploy}
|
||||||
|
on:click={() => changeSettings('autodeploy')}
|
||||||
|
title="Enable Automatic Deployment"
|
||||||
|
description="Enable automatic deployment through webhooks."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<Setting
|
<Setting
|
||||||
isCenter={false}
|
isCenter={false}
|
||||||
bind:setting={previews}
|
bind:setting={previews}
|
||||||
on:click={() => changeSettings('previews')}
|
on:click={() => changeSettings('previews')}
|
||||||
title="Enable MR/PR Previews"
|
title="Enable MR/PR Previews"
|
||||||
description="Creates previews from pull and merge requests."
|
description="Enable preview deployments from pull or merge requests."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
@@ -8,10 +8,17 @@ export const post: RequestHandler = async (event) => {
|
|||||||
if (status === 401) return { status, body };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
const { debug, previews, dualCerts } = await event.request.json();
|
const { debug, previews, dualCerts, autodeploy, branch, projectId } = await event.request.json();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await db.setApplicationSettings({ id, debug, previews, dualCerts });
|
const isDouble = await db.checkDoubleBranch(branch, projectId);
|
||||||
|
if (isDouble && autodeploy) {
|
||||||
|
throw {
|
||||||
|
message:
|
||||||
|
'Cannot activate automatic deployments until only one application is defined for this repository / branch.'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
await db.setApplicationSettings({ id, debug, previews, dualCerts, autodeploy });
|
||||||
return { status: 201 };
|
return { status: 201 };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return ErrorHandler(error);
|
return ErrorHandler(error);
|
||||||
|
@@ -9,7 +9,7 @@ import { dev } from '$app/env';
|
|||||||
|
|
||||||
export const options: RequestHandler = async () => {
|
export const options: RequestHandler = async () => {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 204,
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
||||||
|
@@ -9,7 +9,7 @@ import { dev } from '$app/env';
|
|||||||
|
|
||||||
export const options: RequestHandler = async () => {
|
export const options: RequestHandler = async () => {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 204,
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
||||||
|
@@ -7,7 +7,7 @@ import cookie from 'cookie';
|
|||||||
|
|
||||||
export const options: RequestHandler = async () => {
|
export const options: RequestHandler = async () => {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 204,
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
const defaultTheme = require('tailwindcss/defaultTheme');
|
const defaultTheme = require('tailwindcss/defaultTheme');
|
||||||
const colors = require('tailwindcss/colors');
|
// const colors = require('tailwindcss/colors');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: ['./**/*.html', './src/**/*.{js,jsx,ts,tsx,svelte}'],
|
content: ['./**/*.html', './src/**/*.{js,jsx,ts,tsx,svelte}'],
|
||||||
important: true,
|
important: true,
|
||||||
@@ -18,7 +18,6 @@ module.exports = {
|
|||||||
sans: ['Poppins', ...defaultTheme.fontFamily.sans]
|
sans: ['Poppins', ...defaultTheme.fontFamily.sans]
|
||||||
},
|
},
|
||||||
colors: {
|
colors: {
|
||||||
...colors,
|
|
||||||
coollabs: '#6B16ED',
|
coollabs: '#6B16ED',
|
||||||
'coollabs-100': '#7317FF',
|
'coollabs-100': '#7317FF',
|
||||||
coolblack: '#161616',
|
coolblack: '#161616',
|
||||||
|
Reference in New Issue
Block a user