mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-26 12:33:25 +00:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1c1988db4 | ||
|
|
af99ea4678 | ||
|
|
1281a0f7e4 | ||
|
|
d8350cd4ee | ||
|
|
e3b7c23ed9 | ||
|
|
eae1ea21d6 | ||
|
|
541aa76b64 | ||
|
|
7b8555d524 | ||
|
|
fdf998c181 | ||
|
|
3d6b343adc | ||
|
|
e338cecc14 | ||
|
|
e5537a33fb | ||
|
|
35384deb68 | ||
|
|
547ca60c2a | ||
|
|
376f6f7455 | ||
|
|
abe92dedff | ||
|
|
4b521ceedc | ||
|
|
6dfcb9e52b | ||
|
|
335e3216e2 | ||
|
|
5b22bb4818 | ||
|
|
0097004882 | ||
|
|
1bc9e4c2d3 | ||
|
|
36c7e1a3c3 | ||
|
|
c6b4d04e26 | ||
|
|
fa6cf068c7 | ||
|
|
7c273a3a48 | ||
|
|
3de2ea1523 | ||
|
|
c5c9f84503 | ||
|
|
16ea9a3e07 | ||
|
|
48f952c798 | ||
|
|
f78ea5de07 | ||
|
|
5adbd5e784 | ||
|
|
5b2afa79d7 | ||
|
|
dc4e6d02b7 | ||
|
|
8ae61c8f78 |
@@ -1,4 +1,5 @@
|
|||||||
FROM node:16.14.0-alpine
|
FROM node:16.14.0-alpine
|
||||||
|
RUN apk add --no-cache g++ cmake make python3
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json .
|
COPY package*.json .
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
|
|||||||
@@ -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.27",
|
"version": "2.0.32",
|
||||||
"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",
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
"svelte": "3.46.4",
|
"svelte": "3.46.4",
|
||||||
"svelte-check": "2.4.5",
|
"svelte-check": "2.4.5",
|
||||||
"svelte-preprocess": "4.10.4",
|
"svelte-preprocess": "4.10.4",
|
||||||
|
"svelte-select": "^4.4.7",
|
||||||
"tailwindcss": "3.0.23",
|
"tailwindcss": "3.0.23",
|
||||||
"ts-node": "10.6.0",
|
"ts-node": "10.6.0",
|
||||||
"tslib": "2.3.1",
|
"tslib": "2.3.1",
|
||||||
|
|||||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@@ -46,6 +46,7 @@ specifiers:
|
|||||||
svelte-check: 2.4.5
|
svelte-check: 2.4.5
|
||||||
svelte-kit-cookie-session: 2.1.2
|
svelte-kit-cookie-session: 2.1.2
|
||||||
svelte-preprocess: 4.10.4
|
svelte-preprocess: 4.10.4
|
||||||
|
svelte-select: ^4.4.7
|
||||||
tailwindcss: 3.0.23
|
tailwindcss: 3.0.23
|
||||||
tailwindcss-scrollbar: ^0.1.0
|
tailwindcss-scrollbar: ^0.1.0
|
||||||
ts-node: 10.6.0
|
ts-node: 10.6.0
|
||||||
@@ -103,6 +104,7 @@ devDependencies:
|
|||||||
svelte: 3.46.4
|
svelte: 3.46.4
|
||||||
svelte-check: 2.4.5_postcss@8.4.7+svelte@3.46.4
|
svelte-check: 2.4.5_postcss@8.4.7+svelte@3.46.4
|
||||||
svelte-preprocess: 4.10.4_e836cbb8ceb5bfaa7513362dd6308834
|
svelte-preprocess: 4.10.4_e836cbb8ceb5bfaa7513362dd6308834
|
||||||
|
svelte-select: 4.4.7
|
||||||
tailwindcss: 3.0.23_4b9e11f8e85900587b5e2272c5d4c20c
|
tailwindcss: 3.0.23_4b9e11f8e85900587b5e2272c5d4c20c
|
||||||
ts-node: 10.6.0_e79e62fe450383fd2d418267dc75e645
|
ts-node: 10.6.0_e79e62fe450383fd2d418267dc75e645
|
||||||
tslib: 2.3.1
|
tslib: 2.3.1
|
||||||
@@ -5277,6 +5279,13 @@ packages:
|
|||||||
typescript: 4.6.2
|
typescript: 4.6.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/svelte-select/4.4.7:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-fIf9Z8rPI6F8naHZ9wjXT0Pv5gLyhdHAFkHFJnCfVVfELE8e82uOoF0xEVQP6Kir+b4Q5yOvNAzZ61WbSU6A0A==
|
||||||
|
}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/svelte/3.46.4:
|
/svelte/3.46.4:
|
||||||
resolution:
|
resolution:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ServiceSecret" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"value" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"serviceId" TEXT NOT NULL,
|
||||||
|
CONSTRAINT "ServiceSecret_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ServiceSecret_name_serviceId_key" ON "ServiceSecret"("name", "serviceId");
|
||||||
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;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Application" ADD COLUMN "phpModules" TEXT;
|
||||||
@@ -95,6 +95,7 @@ model Application {
|
|||||||
gitSourceId String?
|
gitSourceId String?
|
||||||
gitSource GitSource? @relation(fields: [gitSourceId], references: [id])
|
gitSource GitSource? @relation(fields: [gitSourceId], references: [id])
|
||||||
secrets Secret[]
|
secrets Secret[]
|
||||||
|
phpModules String?
|
||||||
}
|
}
|
||||||
|
|
||||||
model ApplicationSettings {
|
model ApplicationSettings {
|
||||||
@@ -104,6 +105,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
|
||||||
}
|
}
|
||||||
@@ -122,6 +124,18 @@ model Secret {
|
|||||||
@@unique([name, applicationId, isPRMRSecret])
|
@@unique([name, applicationId, isPRMRSecret])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model ServiceSecret {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String
|
||||||
|
value String
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
service Service @relation(fields: [serviceId], references: [id])
|
||||||
|
serviceId String
|
||||||
|
|
||||||
|
@@unique([name, serviceId])
|
||||||
|
}
|
||||||
|
|
||||||
model BuildLog {
|
model BuildLog {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
applicationId String?
|
applicationId String?
|
||||||
@@ -252,6 +266,7 @@ model Service {
|
|||||||
minio Minio?
|
minio Minio?
|
||||||
vscodeserver Vscodeserver?
|
vscodeserver Vscodeserver?
|
||||||
wordpress Wordpress?
|
wordpress Wordpress?
|
||||||
|
serviceSecret ServiceSecret[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model PlausibleAnalytics {
|
model PlausibleAnalytics {
|
||||||
|
|||||||
@@ -84,7 +84,15 @@ export function makeLabelForServices(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const setDefaultConfiguration = async (data) => {
|
export const setDefaultConfiguration = async (data) => {
|
||||||
let { buildPack, port, installCommand, startCommand, buildCommand, publishDirectory } = data;
|
let {
|
||||||
|
buildPack,
|
||||||
|
port,
|
||||||
|
installCommand,
|
||||||
|
startCommand,
|
||||||
|
buildCommand,
|
||||||
|
publishDirectory,
|
||||||
|
baseDirectory
|
||||||
|
} = data;
|
||||||
const template = scanningTemplates[buildPack];
|
const template = scanningTemplates[buildPack];
|
||||||
if (!port) {
|
if (!port) {
|
||||||
port = template?.port || 3000;
|
port = template?.port || 3000;
|
||||||
@@ -97,6 +105,10 @@ export const setDefaultConfiguration = async (data) => {
|
|||||||
if (!startCommand) startCommand = template?.startCommand || 'yarn start';
|
if (!startCommand) startCommand = template?.startCommand || 'yarn start';
|
||||||
if (!buildCommand) buildCommand = template?.buildCommand || null;
|
if (!buildCommand) buildCommand = template?.buildCommand || null;
|
||||||
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
||||||
|
if (baseDirectory) {
|
||||||
|
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
||||||
|
if (!baseDirectory.endsWith('/')) baseDirectory = `${baseDirectory}/`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
buildPack,
|
buildPack,
|
||||||
@@ -104,7 +116,8 @@ export const setDefaultConfiguration = async (data) => {
|
|||||||
installCommand,
|
installCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
buildCommand,
|
buildCommand,
|
||||||
publishDirectory
|
publishDirectory,
|
||||||
|
baseDirectory
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,3 +188,11 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkPnpm(installCommand = null, buildCommand = null, startCommand = null) {
|
||||||
|
return (
|
||||||
|
installCommand?.includes('pnpm') ||
|
||||||
|
buildCommand?.includes('pnpm') ||
|
||||||
|
startCommand?.includes('pnpm')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default async function ({
|
|||||||
let file = `${workdir}/Dockerfile`;
|
let file = `${workdir}/Dockerfile`;
|
||||||
if (baseDirectory) {
|
if (baseDirectory) {
|
||||||
file = `${workdir}/${baseDirectory}/Dockerfile`;
|
file = `${workdir}/${baseDirectory}/Dockerfile`;
|
||||||
|
workdir = `${workdir}/${baseDirectory}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dockerfile: Array<string> = (await fs.readFile(`${file}`, 'utf8'))
|
const Dockerfile: Array<string> = (await fs.readFile(`${file}`, 'utf8'))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const createDockerfile = async (data, imageforBuild): Promise<void> => {
|
|||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
||||||
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
|
|||||||
@@ -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'));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { buildImage } from '$lib/docker';
|
import { buildImage } from '$lib/docker';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
import { checkPnpm } from './common';
|
||||||
|
|
||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
@@ -13,7 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
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,17 +33,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
if (isPnpm) {
|
||||||
try {
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
}
|
||||||
} catch (error) {}
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
try {
|
|
||||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
|
||||||
} catch (error) {}
|
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
|
||||||
if (buildCommand) {
|
if (buildCommand) {
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { buildImage } from '$lib/docker';
|
import { buildImage } from '$lib/docker';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
import { checkPnpm } from './common';
|
||||||
|
|
||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
@@ -13,6 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
@@ -32,17 +34,12 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
if (isPnpm) {
|
||||||
try {
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
}
|
||||||
} catch (error) {}
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
try {
|
|
||||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
|
||||||
} catch (error) {}
|
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
|
||||||
if (buildCommand) {
|
if (buildCommand) {
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { buildImage } from '$lib/docker';
|
import { buildImage } from '$lib/docker';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
import { checkPnpm } from './common';
|
||||||
|
|
||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
@@ -13,7 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
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,17 +33,12 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
if (isPnpm) {
|
||||||
try {
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
}
|
||||||
} catch (error) {}
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
try {
|
|
||||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
|
||||||
} catch (error) {}
|
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
|
||||||
if (buildCommand) {
|
if (buildCommand) {
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,19 @@ import { promises as fs } from 'fs';
|
|||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const { workdir, baseDirectory } = data;
|
const { workdir, baseDirectory } = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
|
if (data.phpModules?.length > 0) {
|
||||||
|
Dockerfile.push(
|
||||||
|
`ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/`
|
||||||
|
);
|
||||||
|
Dockerfile.push(`RUN chmod +x /usr/local/bin/install-php-extensions`);
|
||||||
|
Dockerfile.push(`RUN /usr/local/bin/install-php-extensions ${data.phpModules.join(' ')}`);
|
||||||
|
}
|
||||||
Dockerfile.push('RUN a2enmod rewrite');
|
Dockerfile.push('RUN a2enmod rewrite');
|
||||||
Dockerfile.push('WORKDIR /var/www/html');
|
Dockerfile.push('WORKDIR /var/www/html');
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} /var/www/html`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} /var/www/html`);
|
||||||
|
Dockerfile.push(`COPY /.htaccess /var/www/html/.htaccess`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["apache2-foreground"]');
|
Dockerfile.push('CMD ["apache2-foreground"]');
|
||||||
Dockerfile.push('RUN chown -R www-data /var/www/html');
|
Dockerfile.push('RUN chown -R www-data /var/www/html');
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
||||||
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`
|
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
}
|
}
|
||||||
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
||||||
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
||||||
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
@@ -19,6 +20,21 @@ export default async function (data) {
|
|||||||
const image = 'nginx:stable-alpine';
|
const image = 'nginx:stable-alpine';
|
||||||
const imageForBuild = 'node:lts';
|
const imageForBuild = 'node:lts';
|
||||||
await buildCacheImageWithNode(data, imageForBuild);
|
await buildCacheImageWithNode(data, imageForBuild);
|
||||||
|
// await fs.writeFile(`${data.workdir}/default.conf`, `server {
|
||||||
|
// listen 80;
|
||||||
|
// server_name localhost;
|
||||||
|
|
||||||
|
// location / {
|
||||||
|
// root /usr/share/nginx/html;
|
||||||
|
// try_files $uri $uri/ /index.html;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// error_page 500 502 503 504 /50x.html;
|
||||||
|
// location = /50x.html {
|
||||||
|
// root /usr/share/nginx/html;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// `);
|
||||||
await createDockerfile(data, image);
|
await createDockerfile(data, image);
|
||||||
await buildImage(data);
|
await buildImage(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
@@ -68,9 +69,9 @@ export const isTeamIdTokenAvailable = (request) => {
|
|||||||
|
|
||||||
export const getTeam = (event) => {
|
export const getTeam = (event) => {
|
||||||
const cookies = Cookie.parse(event.request.headers.get('cookie'));
|
const cookies = Cookie.parse(event.request.headers.get('cookie'));
|
||||||
if (cookies.teamId) {
|
if (cookies?.teamId) {
|
||||||
return cookies.teamId;
|
return cookies.teamId;
|
||||||
} else if (event.locals.session.data.teamId) {
|
} else if (event.locals.session.data?.teamId) {
|
||||||
return event.locals.session.data.teamId;
|
return event.locals.session.data.teamId;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -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,29 +58,21 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.applicationSettings.deleteMany({ where: { application: { id } } });
|
await prisma.applicationSettings.deleteMany({ where: { application: { id } } });
|
||||||
await prisma.buildLog.deleteMany({ where: { applicationId: id } });
|
await prisma.buildLog.deleteMany({ where: { applicationId: id } });
|
||||||
|
await prisma.build.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.secret.deleteMany({ where: { applicationId: id } });
|
await prisma.secret.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.application.deleteMany({ where: { id, teams: { some: { id: teamId } } } });
|
await prisma.application.deleteMany({ where: { id, teams: { some: { 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 +80,41 @@ export async function getApplicationWebhook({ projectId, branch }) {
|
|||||||
secrets: true
|
secrets: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!application) {
|
||||||
if (body.gitSource?.githubApp?.clientSecret) {
|
return null;
|
||||||
body.gitSource.githubApp.clientSecret = decrypt(body.gitSource.githubApp.clientSecret);
|
|
||||||
}
|
}
|
||||||
if (body.gitSource?.githubApp?.webhookSecret) {
|
if (application?.gitSource?.githubApp?.clientSecret) {
|
||||||
body.gitSource.githubApp.webhookSecret = decrypt(body.gitSource.githubApp.webhookSecret);
|
application.gitSource.githubApp.clientSecret = decrypt(
|
||||||
|
application.gitSource.githubApp.clientSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body.gitSource?.githubApp?.privateKey) {
|
if (application?.gitSource?.githubApp?.webhookSecret) {
|
||||||
body.gitSource.githubApp.privateKey = decrypt(body.gitSource.githubApp.privateKey);
|
application.gitSource.githubApp.webhookSecret = decrypt(
|
||||||
|
application.gitSource.githubApp.webhookSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.gitSource?.gitlabApp?.appSecret) {
|
if (application?.gitSource?.githubApp?.privateKey) {
|
||||||
body.gitSource.gitlabApp.appSecret = decrypt(body.gitSource.gitlabApp.appSecret);
|
application.gitSource.githubApp.privateKey = decrypt(
|
||||||
|
application.gitSource.githubApp.privateKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.gitSource?.gitlabApp?.webhookToken) {
|
if (application?.gitSource?.gitlabApp?.appSecret) {
|
||||||
body.gitSource.gitlabApp.webhookToken = decrypt(body.gitSource.gitlabApp.webhookToken);
|
application.gitSource.gitlabApp.appSecret = decrypt(
|
||||||
|
application.gitSource.gitlabApp.appSecret
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (body?.secrets.length > 0) {
|
if (application?.gitSource?.gitlabApp?.webhookToken) {
|
||||||
body.secrets = body.secrets.map((s) => {
|
application.gitSource.gitlabApp.webhookToken = decrypt(
|
||||||
|
application.gitSource.gitlabApp.webhookToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (application?.secrets.length > 0) {
|
||||||
|
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 } };
|
||||||
}
|
}
|
||||||
@@ -153,28 +156,48 @@ export async function getApplication({ id, teamId }) {
|
|||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (body?.phpModules) {
|
||||||
|
body.phpModules = body.phpModules.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
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 }) {
|
||||||
@@ -191,7 +214,8 @@ export async function configureApplication({
|
|||||||
buildCommand,
|
buildCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory
|
publishDirectory,
|
||||||
|
phpModules
|
||||||
}) {
|
}) {
|
||||||
return await prisma.application.update({
|
return await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
@@ -204,15 +228,20 @@ export async function configureApplication({
|
|||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory,
|
publishDirectory,
|
||||||
name
|
name,
|
||||||
|
phpModules
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ export async function isDockerNetworkExists({ network }) {
|
|||||||
return await prisma.destinationDocker.findFirst({ where: { network } });
|
return await prisma.destinationDocker.findFirst({ where: { network } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function isServiceSecretExists({ id, name }) {
|
||||||
|
return await prisma.serviceSecret.findFirst({ where: { name, serviceId: id } });
|
||||||
|
}
|
||||||
export async function isSecretExists({ id, name, isPRMRSecret }) {
|
export async function isSecretExists({ id, name, isPRMRSecret }) {
|
||||||
return await prisma.secret.findFirst({ where: { name, applicationId: id, isPRMRSecret } });
|
return await prisma.secret.findFirst({ where: { name, applicationId: id, isPRMRSecret } });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
import { encrypt, decrypt } from '$lib/crypto';
|
import { encrypt, decrypt } from '$lib/crypto';
|
||||||
import { prisma } from './common';
|
import { prisma } from './common';
|
||||||
|
|
||||||
|
export async function listServiceSecrets(serviceId: string) {
|
||||||
|
let secrets = await prisma.serviceSecret.findMany({
|
||||||
|
where: { serviceId },
|
||||||
|
orderBy: { createdAt: 'desc' }
|
||||||
|
});
|
||||||
|
secrets = secrets.map((secret) => {
|
||||||
|
secret.value = decrypt(secret.value);
|
||||||
|
return secret;
|
||||||
|
});
|
||||||
|
|
||||||
|
return secrets;
|
||||||
|
}
|
||||||
|
|
||||||
export async function listSecrets(applicationId: string) {
|
export async function listSecrets(applicationId: string) {
|
||||||
let secrets = await prisma.secret.findMany({
|
let secrets = await prisma.secret.findMany({
|
||||||
where: { applicationId },
|
where: { applicationId },
|
||||||
@@ -14,6 +27,12 @@ export async function listSecrets(applicationId: string) {
|
|||||||
return secrets;
|
return secrets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function createServiceSecret({ id, name, value }) {
|
||||||
|
value = encrypt(value);
|
||||||
|
return await prisma.serviceSecret.create({
|
||||||
|
data: { name, value, service: { connect: { id } } }
|
||||||
|
});
|
||||||
|
}
|
||||||
export async function createSecret({ id, name, value, isBuildSecret, isPRMRSecret }) {
|
export async function createSecret({ id, name, value, isBuildSecret, isPRMRSecret }) {
|
||||||
value = encrypt(value);
|
value = encrypt(value);
|
||||||
return await prisma.secret.create({
|
return await prisma.secret.create({
|
||||||
@@ -21,10 +40,24 @@ export async function createSecret({ id, name, value, isBuildSecret, isPRMRSecre
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateServiceSecret({ id, name, value }) {
|
||||||
|
value = encrypt(value);
|
||||||
|
const found = await prisma.serviceSecret.findFirst({ where: { serviceId: id, name } });
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
return await prisma.serviceSecret.updateMany({
|
||||||
|
where: { serviceId: id, name },
|
||||||
|
data: { value }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return await prisma.serviceSecret.create({
|
||||||
|
data: { name, value, service: { connect: { id } } }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
export async function updateSecret({ id, name, value, isBuildSecret, isPRMRSecret }) {
|
export async function updateSecret({ id, name, value, isBuildSecret, isPRMRSecret }) {
|
||||||
value = encrypt(value);
|
value = encrypt(value);
|
||||||
const found = await prisma.secret.findFirst({ where: { applicationId: id, name, isPRMRSecret } });
|
const found = await prisma.secret.findFirst({ where: { applicationId: id, name, isPRMRSecret } });
|
||||||
console.log(found);
|
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
return await prisma.secret.updateMany({
|
return await prisma.secret.updateMany({
|
||||||
@@ -38,6 +71,10 @@ export async function updateSecret({ id, name, value, isBuildSecret, isPRMRSecre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function removeServiceSecret({ id, name }) {
|
||||||
|
return await prisma.serviceSecret.deleteMany({ where: { serviceId: id, name } });
|
||||||
|
}
|
||||||
|
|
||||||
export async function removeSecret({ id, name }) {
|
export async function removeSecret({ id, name }) {
|
||||||
return await prisma.secret.deleteMany({ where: { applicationId: id, name } });
|
return await prisma.secret.deleteMany({ where: { applicationId: id, name } });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export async function getService({ id, teamId }) {
|
|||||||
plausibleAnalytics: true,
|
plausibleAnalytics: true,
|
||||||
minio: true,
|
minio: true,
|
||||||
vscodeserver: true,
|
vscodeserver: true,
|
||||||
wordpress: true
|
wordpress: true,
|
||||||
|
serviceSecret: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,6 +43,12 @@ export async function getService({ id, teamId }) {
|
|||||||
if (body.wordpress?.mysqlRootUserPassword)
|
if (body.wordpress?.mysqlRootUserPassword)
|
||||||
body.wordpress.mysqlRootUserPassword = decrypt(body.wordpress.mysqlRootUserPassword);
|
body.wordpress.mysqlRootUserPassword = decrypt(body.wordpress.mysqlRootUserPassword);
|
||||||
|
|
||||||
|
if (body?.serviceSecret.length > 0) {
|
||||||
|
body.serviceSecret = body.serviceSecret.map((s) => {
|
||||||
|
s.value = decrypt(s.value);
|
||||||
|
return s;
|
||||||
|
});
|
||||||
|
}
|
||||||
return { ...body };
|
return { ...body };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,5 +166,7 @@ export async function removeService({ id }) {
|
|||||||
await prisma.minio.deleteMany({ where: { serviceId: id } });
|
await prisma.minio.deleteMany({ where: { serviceId: id } });
|
||||||
await prisma.vscodeserver.deleteMany({ where: { serviceId: id } });
|
await prisma.vscodeserver.deleteMany({ where: { serviceId: id } });
|
||||||
await prisma.wordpress.deleteMany({ where: { serviceId: id } });
|
await prisma.wordpress.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.serviceSecret.deleteMany({ where: { serviceId: id } });
|
||||||
|
|
||||||
await prisma.service.delete({ where: { id } });
|
await prisma.service.delete({ where: { id } });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Dockerode from 'dockerode';
|
import Dockerode from 'dockerode';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
import { checkPnpm } from './buildPacks/common';
|
||||||
import { saveBuildLog } from './common';
|
import { saveBuildLog } from './common';
|
||||||
|
|
||||||
export async function buildCacheImageWithNode(data, imageForBuild) {
|
export async function buildCacheImageWithNode(data, imageForBuild) {
|
||||||
@@ -16,6 +17,7 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
secrets,
|
secrets,
|
||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
|
const isPnpm = checkPnpm(installCommand, buildCommand);
|
||||||
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,20 +37,14 @@ 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');
|
||||||
|
}
|
||||||
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
if (installCommand) {
|
if (installCommand) {
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
|
||||||
try {
|
|
||||||
await fs.stat(`${workdir}/yarn.lock`);
|
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
|
||||||
} catch (error) {}
|
|
||||||
try {
|
|
||||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
|
||||||
} catch (error) {}
|
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
||||||
await buildImage({ applicationId, tag, workdir, docker, buildId, isCache: true, debug });
|
await buildImage({ applicationId, tag, workdir, docker, buildId, isCache: true, debug });
|
||||||
|
|||||||
@@ -112,9 +112,15 @@ export async function haproxyInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function configureHAProxy() {
|
export async function configureHAProxy() {
|
||||||
|
const haproxy = await haproxyInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const haproxy = await haproxyInstance();
|
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
|
} catch (error) {
|
||||||
|
return 'Error: HAProxy is not running';
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
applications: [],
|
applications: [],
|
||||||
services: [],
|
services: [],
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ export async function completeTransaction(transactionId) {
|
|||||||
}
|
}
|
||||||
export async function deleteProxy({ id }) {
|
export async function deleteProxy({ id }) {
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
try {
|
||||||
|
await checkHAProxy(haproxy);
|
||||||
|
} catch (error) {
|
||||||
|
return 'Error: HAProxy is not running';
|
||||||
|
}
|
||||||
|
|
||||||
let transactionId;
|
let transactionId;
|
||||||
try {
|
try {
|
||||||
await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json();
|
await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json();
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export default async function ({
|
|||||||
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
||||||
return commit.replace('\n', '');
|
return commit.replace('\n', '');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log({ error });
|
||||||
return ErrorHandler(error);
|
return ErrorHandler(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ import fs from 'fs/promises';
|
|||||||
import * as buildpacks from '../buildPacks';
|
import * as buildpacks from '../buildPacks';
|
||||||
import * as importers from '../importers';
|
import * as importers from '../importers';
|
||||||
import { dockerInstance } from '../docker';
|
import { dockerInstance } from '../docker';
|
||||||
import { asyncExecShell, createDirectories, getDomain, getEngine, saveBuildLog } from '../common';
|
import {
|
||||||
|
asyncExecShell,
|
||||||
|
asyncSleep,
|
||||||
|
createDirectories,
|
||||||
|
getDomain,
|
||||||
|
getEngine,
|
||||||
|
saveBuildLog
|
||||||
|
} from '../common';
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { decrypt } from '$lib/crypto';
|
import { decrypt } from '$lib/crypto';
|
||||||
import { sentry } from '$lib/common';
|
import { sentry } from '$lib/common';
|
||||||
@@ -12,7 +19,6 @@ import {
|
|||||||
makeLabelForStandaloneApplication,
|
makeLabelForStandaloneApplication,
|
||||||
setDefaultConfiguration
|
setDefaultConfiguration
|
||||||
} from '$lib/buildPacks/common';
|
} from '$lib/buildPacks/common';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
|
|
||||||
export default async function (job) {
|
export default async function (job) {
|
||||||
/*
|
/*
|
||||||
@@ -39,6 +45,7 @@ export default async function (job) {
|
|||||||
publishDirectory,
|
publishDirectory,
|
||||||
projectId,
|
projectId,
|
||||||
secrets,
|
secrets,
|
||||||
|
phpModules,
|
||||||
type,
|
type,
|
||||||
pullmergeRequestId = null,
|
pullmergeRequestId = null,
|
||||||
sourceBranch = null,
|
sourceBranch = null,
|
||||||
@@ -46,6 +53,17 @@ export default async function (job) {
|
|||||||
} = job.data;
|
} = job.data;
|
||||||
const { debug } = settings;
|
const { debug } = settings;
|
||||||
|
|
||||||
|
await asyncSleep(1000);
|
||||||
|
|
||||||
|
await db.prisma.build.updateMany({
|
||||||
|
where: {
|
||||||
|
status: 'queued',
|
||||||
|
id: { not: buildId },
|
||||||
|
applicationId,
|
||||||
|
createdAt: { lt: new Date(new Date().getTime() - 60 * 60 * 1000) }
|
||||||
|
},
|
||||||
|
data: { status: 'failed' }
|
||||||
|
});
|
||||||
let imageId = applicationId;
|
let imageId = applicationId;
|
||||||
let domain = getDomain(fqdn);
|
let domain = getDomain(fqdn);
|
||||||
const isHttps = fqdn.startsWith('https://');
|
const isHttps = fqdn.startsWith('https://');
|
||||||
@@ -67,17 +85,8 @@ export default async function (job) {
|
|||||||
const docker = dockerInstance({ destinationDocker });
|
const docker = dockerInstance({ destinationDocker });
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
const build = await db.createBuild({
|
await db.prisma.build.update({ where: { id: buildId }, data: { status: 'running' } });
|
||||||
id: buildId,
|
const { workdir, repodir } = await createDirectories({ repository, buildId });
|
||||||
applicationId,
|
|
||||||
destinationDockerId: destinationDocker.id,
|
|
||||||
gitSourceId: gitSource.id,
|
|
||||||
githubAppId: gitSource.githubApp?.id,
|
|
||||||
gitlabAppId: gitSource.gitlabApp?.id,
|
|
||||||
type
|
|
||||||
});
|
|
||||||
|
|
||||||
const { workdir, repodir } = await createDirectories({ repository, buildId: build.id });
|
|
||||||
|
|
||||||
const configuration = await setDefaultConfiguration(job.data);
|
const configuration = await setDefaultConfiguration(job.data);
|
||||||
|
|
||||||
@@ -87,6 +96,7 @@ export default async function (job) {
|
|||||||
startCommand = configuration.startCommand;
|
startCommand = configuration.startCommand;
|
||||||
buildCommand = configuration.buildCommand;
|
buildCommand = configuration.buildCommand;
|
||||||
publishDirectory = configuration.publishDirectory;
|
publishDirectory = configuration.publishDirectory;
|
||||||
|
baseDirectory = configuration.baseDirectory;
|
||||||
|
|
||||||
let commit = await importers[gitSource.type]({
|
let commit = await importers[gitSource.type]({
|
||||||
applicationId,
|
applicationId,
|
||||||
@@ -97,19 +107,22 @@ export default async function (job) {
|
|||||||
gitlabAppId: gitSource.gitlabApp?.id,
|
gitlabAppId: gitSource.gitlabApp?.id,
|
||||||
repository,
|
repository,
|
||||||
branch,
|
branch,
|
||||||
buildId: build.id,
|
buildId,
|
||||||
apiUrl: gitSource.apiUrl,
|
apiUrl: gitSource.apiUrl,
|
||||||
projectId,
|
projectId,
|
||||||
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
|
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
|
||||||
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null
|
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null
|
||||||
});
|
});
|
||||||
|
if (!commit) {
|
||||||
|
throw new Error('No commit found?');
|
||||||
|
}
|
||||||
let tag = commit.slice(0, 7);
|
let tag = commit.slice(0, 7);
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
|
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await db.prisma.build.update({ where: { id: build.id }, data: { commit } });
|
db.prisma.build.update({ where: { id: buildId }, data: { commit } });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
@@ -160,7 +173,7 @@ export default async function (job) {
|
|||||||
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId);
|
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId);
|
||||||
if (buildpacks[buildPack])
|
if (buildpacks[buildPack])
|
||||||
await buildpacks[buildPack]({
|
await buildpacks[buildPack]({
|
||||||
buildId: build.id,
|
buildId,
|
||||||
applicationId,
|
applicationId,
|
||||||
domain,
|
domain,
|
||||||
name,
|
name,
|
||||||
@@ -181,7 +194,8 @@ export default async function (job) {
|
|||||||
buildCommand,
|
buildCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
secrets
|
secrets,
|
||||||
|
phpModules
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
|
saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ const cron = async () => {
|
|||||||
|
|
||||||
await queue.proxy.add('proxy', {}, { repeat: { every: 10000 } });
|
await queue.proxy.add('proxy', {}, { repeat: { every: 10000 } });
|
||||||
await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } });
|
await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } });
|
||||||
await queue.cleanup.add('cleanup', {}, { repeat: { every: dev ? 10000 : 300000 } });
|
if (!dev) await queue.cleanup.add('cleanup', {}, { repeat: { every: 300000 } });
|
||||||
await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } });
|
await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } });
|
||||||
|
|
||||||
const events = {
|
const events = {
|
||||||
@@ -110,18 +110,18 @@ cron().catch((error) => {
|
|||||||
const buildQueueName = 'build_queue';
|
const buildQueueName = 'build_queue';
|
||||||
const buildQueue = new Queue(buildQueueName, connectionOptions);
|
const buildQueue = new Queue(buildQueueName, connectionOptions);
|
||||||
const buildWorker = new Worker(buildQueueName, async (job) => await builder(job), {
|
const buildWorker = new Worker(buildQueueName, async (job) => await builder(job), {
|
||||||
concurrency: 2,
|
concurrency: 1,
|
||||||
...connectionOptions
|
...connectionOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
buildWorker.on('completed', async (job: Bullmq.Job) => {
|
buildWorker.on('completed', async (job: Bullmq.Job) => {
|
||||||
try {
|
try {
|
||||||
await prisma.build.update({ where: { id: job.data.build_id }, data: { status: 'success' } });
|
await prisma.build.update({ where: { id: job.data.build_id }, data: { status: 'success' } });
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
console.log(err);
|
console.log(error);
|
||||||
} 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}`);
|
if (!dev) await asyncExecShell(`rm -fr ${workdir}`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@@ -133,7 +133,7 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
const workdir = `/tmp/build-sources/${job.data.repository}`;
|
const workdir = `/tmp/build-sources/${job.data.repository}`;
|
||||||
await asyncExecShell(`rm -fr ${workdir}`);
|
if (!dev) await asyncExecShell(`rm -fr ${workdir}`);
|
||||||
}
|
}
|
||||||
saveBuildLog({
|
saveBuildLog({
|
||||||
line: 'Failed to deploy!',
|
line: 'Failed to deploy!',
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { dev } from '$app/env';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { configureHAProxy } from '$lib/haproxy/configuration';
|
import { configureHAProxy } from '$lib/haproxy/configuration';
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
import { del, post } from '$lib/api';
|
import { del, post } from '$lib/api';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { gitTokens } from '$lib/store';
|
import { gitTokens } from '$lib/store';
|
||||||
|
import { toast } from '@zerodevx/svelte-toast';
|
||||||
|
|
||||||
if (githubToken) $gitTokens.githubToken = githubToken;
|
if (githubToken) $gitTokens.githubToken = githubToken;
|
||||||
if (gitlabToken) $gitTokens.gitlabToken = gitlabToken;
|
if (gitlabToken) $gitTokens.gitlabToken = gitlabToken;
|
||||||
@@ -86,6 +87,7 @@
|
|||||||
async function handleDeploySubmit() {
|
async function handleDeploySubmit() {
|
||||||
try {
|
try {
|
||||||
const { buildId } = await post(`/applications/${id}/deploy.json`, { ...application });
|
const { buildId } = await post(`/applications/${id}/deploy.json`, { ...application });
|
||||||
|
toast.push('Deployment queued.');
|
||||||
return await goto(`/applications/${id}/logs/build?buildId=${buildId}`);
|
return await goto(`/applications/${id}/logs/build?buildId=${buildId}`);
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
@@ -108,11 +110,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);
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ export const post: RequestHandler = async (event) => {
|
|||||||
await db.prisma.application.update({ where: { id }, data: { configHash } });
|
await db.prisma.application.update({ where: { id }, data: { configHash } });
|
||||||
}
|
}
|
||||||
await db.prisma.application.update({ where: { id }, data: { updatedAt: new Date() } });
|
await db.prisma.application.update({ where: { id }, data: { updatedAt: new Date() } });
|
||||||
|
await db.prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: id,
|
||||||
|
destinationDockerId: applicationFound.destinationDocker.id,
|
||||||
|
gitSourceId: applicationFound.gitSource.id,
|
||||||
|
githubAppId: applicationFound.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'manual'
|
||||||
|
}
|
||||||
|
});
|
||||||
await buildQueue.add(buildId, { build_id: buildId, type: 'manual', ...applicationFound });
|
await buildQueue.add(buildId, { build_id: buildId, type: 'manual', ...applicationFound });
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
buildCommand,
|
buildCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory
|
publishDirectory,
|
||||||
|
phpModules
|
||||||
} = await event.request.json();
|
} = await event.request.json();
|
||||||
|
|
||||||
if (port) port = Number(port);
|
if (port) port = Number(port);
|
||||||
@@ -68,7 +69,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
buildCommand,
|
buildCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory
|
publishDirectory,
|
||||||
|
phpModules
|
||||||
});
|
});
|
||||||
return { status: 201 };
|
return { status: 201 };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -47,7 +47,125 @@
|
|||||||
import { post } from '$lib/api';
|
import { post } from '$lib/api';
|
||||||
import cuid from 'cuid';
|
import cuid from 'cuid';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/env';
|
||||||
|
import Select from 'svelte-select';
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
|
let collection = [
|
||||||
|
'amqp',
|
||||||
|
'apcu',
|
||||||
|
'apcu_bc',
|
||||||
|
'ast',
|
||||||
|
'bcmath',
|
||||||
|
'blackfire',
|
||||||
|
'bz2',
|
||||||
|
'calendar',
|
||||||
|
'cmark',
|
||||||
|
'csv',
|
||||||
|
'dba',
|
||||||
|
'decimal',
|
||||||
|
'ds',
|
||||||
|
'enchant',
|
||||||
|
'ev',
|
||||||
|
'event',
|
||||||
|
'excimer',
|
||||||
|
'exif',
|
||||||
|
'ffi',
|
||||||
|
'gd',
|
||||||
|
'gearman',
|
||||||
|
'geoip',
|
||||||
|
'geospatial',
|
||||||
|
'gettext',
|
||||||
|
'gmagick',
|
||||||
|
'gmp',
|
||||||
|
'gnupg',
|
||||||
|
'grpc',
|
||||||
|
'http',
|
||||||
|
'igbinary',
|
||||||
|
'imagick',
|
||||||
|
'imap',
|
||||||
|
'inotify',
|
||||||
|
'interbase',
|
||||||
|
'intl',
|
||||||
|
'ioncube_loader',
|
||||||
|
'jsmin',
|
||||||
|
'json_post',
|
||||||
|
'ldap',
|
||||||
|
'lzf',
|
||||||
|
'mailparse',
|
||||||
|
'maxminddb',
|
||||||
|
'mcrypt',
|
||||||
|
'memcache',
|
||||||
|
'memcached',
|
||||||
|
'mongo',
|
||||||
|
'mongodb',
|
||||||
|
'mosquitto',
|
||||||
|
'msgpack',
|
||||||
|
'mssql',
|
||||||
|
'mysqli',
|
||||||
|
'oauth',
|
||||||
|
'oci8',
|
||||||
|
'odbc',
|
||||||
|
'opcache',
|
||||||
|
'opencensus',
|
||||||
|
'openswoole',
|
||||||
|
'parallel',
|
||||||
|
'pcntl',
|
||||||
|
'pcov',
|
||||||
|
'pdo_dblib',
|
||||||
|
'pdo_firebird',
|
||||||
|
'pdo_mysql',
|
||||||
|
'pdo_oci',
|
||||||
|
'pdo_odbc',
|
||||||
|
'pdo_pgsql',
|
||||||
|
'pdo_sqlsrv',
|
||||||
|
'pgsql',
|
||||||
|
'propro',
|
||||||
|
'protobuf',
|
||||||
|
'pspell',
|
||||||
|
'pthreads',
|
||||||
|
'raphf',
|
||||||
|
'rdkafka',
|
||||||
|
'recode',
|
||||||
|
'redis',
|
||||||
|
'seaslog',
|
||||||
|
'shmop',
|
||||||
|
'smbclient',
|
||||||
|
'snmp',
|
||||||
|
'snuffleupagus',
|
||||||
|
'soap',
|
||||||
|
'sockets',
|
||||||
|
'solr',
|
||||||
|
'sourceguardian',
|
||||||
|
'spx',
|
||||||
|
'sqlsrv',
|
||||||
|
'ssh2',
|
||||||
|
'stomp',
|
||||||
|
'swoole',
|
||||||
|
'sybase_ct',
|
||||||
|
'sysvmsg',
|
||||||
|
'sysvsem',
|
||||||
|
'sysvshm',
|
||||||
|
'tensor',
|
||||||
|
'tidy',
|
||||||
|
'timezonedb',
|
||||||
|
'uopz',
|
||||||
|
'uploadprogress',
|
||||||
|
'uuid',
|
||||||
|
'vips',
|
||||||
|
'wddx',
|
||||||
|
'xdebug',
|
||||||
|
'xhprof',
|
||||||
|
'xlswriter',
|
||||||
|
'xmldiff',
|
||||||
|
'xmlrpc',
|
||||||
|
'xsl',
|
||||||
|
'yac',
|
||||||
|
'yaml',
|
||||||
|
'yar',
|
||||||
|
'zephir_parser',
|
||||||
|
'zip',
|
||||||
|
'zookeeper',
|
||||||
|
'zstd'
|
||||||
|
];
|
||||||
|
|
||||||
let domainEl: HTMLInputElement;
|
let domainEl: HTMLInputElement;
|
||||||
|
|
||||||
@@ -56,7 +174,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,18 +193,41 @@
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
|
const tempPhpModules = application.phpModules?.map((module) => module.value).toString() || '';
|
||||||
await post(`/applications/${id}/check.json`, { fqdn: application.fqdn, forceSave });
|
await post(`/applications/${id}/check.json`, { fqdn: application.fqdn, forceSave });
|
||||||
await post(`/applications/${id}.json`, { ...application });
|
await post(`/applications/${id}.json`, { ...application, phpModules: tempPhpModules });
|
||||||
return window.location.reload();
|
return window.location.reload();
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
if (error.startsWith('DNS not set')) {
|
if (error.startsWith('DNS not set')) {
|
||||||
@@ -340,7 +481,19 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if application.buildPack === 'php'}
|
||||||
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
<label for="startCommand" class="text-base font-bold text-stone-100">PHP Modules</label>
|
||||||
|
<div class="svelte-select">
|
||||||
|
<Select
|
||||||
|
isMulti={true}
|
||||||
|
bind:value={application.phpModules}
|
||||||
|
items={collection}
|
||||||
|
placeholder="Select PHP modules to add..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
<label for="baseDirectory" class="pt-2 text-base font-bold text-stone-100"
|
<label for="baseDirectory" class="pt-2 text-base font-bold text-stone-100"
|
||||||
@@ -383,22 +536,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">
|
||||||
|
|||||||
@@ -43,11 +43,11 @@
|
|||||||
logs = logs.concat(responseLogs.map((log) => ({ ...log, line: cleanAnsiCodes(log.line) })));
|
logs = logs.concat(responseLogs.map((log) => ({ ...log, line: cleanAnsiCodes(log.line) })));
|
||||||
loading = false;
|
loading = false;
|
||||||
streamInterval = setInterval(async () => {
|
streamInterval = setInterval(async () => {
|
||||||
if (status !== 'running') {
|
if (status !== 'running' && status !== 'queued') {
|
||||||
clearInterval(streamInterval);
|
clearInterval(streamInterval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const nextSequence = logs[logs.length - 1].time;
|
const nextSequence = logs[logs.length - 1]?.time || 0;
|
||||||
try {
|
try {
|
||||||
const data = await get(
|
const data = await get(
|
||||||
`/applications/${id}/logs/build/build.json?buildId=${buildId}&sequence=${nextSequence}`
|
`/applications/${id}/logs/build/build.json?buildId=${buildId}&sequence=${nextSequence}`
|
||||||
@@ -83,38 +83,42 @@
|
|||||||
{#if currentStatus === 'running'}
|
{#if currentStatus === 'running'}
|
||||||
<LoadingLogs />
|
<LoadingLogs />
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex justify-end sticky top-0 p-2">
|
{#if currentStatus === 'queued'}
|
||||||
<button
|
<div class="text-center">Queued and waiting for execution.</div>
|
||||||
on:click={followBuild}
|
{:else}
|
||||||
class="bg-transparent"
|
<div class="flex justify-end sticky top-0 p-2">
|
||||||
data-tooltip="Follow logs"
|
<button
|
||||||
class:text-green-500={followingBuild}
|
on:click={followBuild}
|
||||||
>
|
class="bg-transparent"
|
||||||
<svg
|
data-tooltip="Follow logs"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
class:text-green-500={followingBuild}
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
>
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<svg
|
||||||
<circle cx="12" cy="12" r="9" />
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<line x1="8" y1="12" x2="12" y2="16" />
|
class="w-6 h-6"
|
||||||
<line x1="12" y1="8" x2="12" y2="16" />
|
viewBox="0 0 24 24"
|
||||||
<line x1="16" y1="12" x2="12" y2="16" />
|
stroke-width="1.5"
|
||||||
</svg>
|
stroke="currentColor"
|
||||||
</button>
|
fill="none"
|
||||||
</div>
|
stroke-linecap="round"
|
||||||
<div
|
stroke-linejoin="round"
|
||||||
class="font-mono leading-6 text-left text-md tracking-tighter rounded bg-coolgray-200 py-5 px-6 whitespace-pre-wrap break-words overflow-auto max-h-[80vh] -mt-12 overflow-y-scroll scrollbar-w-1 scrollbar-thumb-coollabs scrollbar-track-coolgray-200"
|
>
|
||||||
bind:this={logsEl}
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
>
|
<circle cx="12" cy="12" r="9" />
|
||||||
{#each logs as log}
|
<line x1="8" y1="12" x2="12" y2="16" />
|
||||||
<div>{log.line + '\n'}</div>
|
<line x1="12" y1="8" x2="12" y2="16" />
|
||||||
{/each}
|
<line x1="16" y1="12" x2="12" y2="16" />
|
||||||
</div>
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="font-mono leading-6 text-left text-md tracking-tighter rounded bg-coolgray-200 py-5 px-6 whitespace-pre-wrap break-words overflow-auto max-h-[80vh] -mt-12 overflow-y-scroll scrollbar-w-1 scrollbar-thumb-coollabs scrollbar-track-coolgray-200"
|
||||||
|
bind:this={logsEl}
|
||||||
|
>
|
||||||
|
{#each logs as log}
|
||||||
|
<div>{log.line + '\n'}</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const get: RequestHandler = async (event) => {
|
|||||||
return {
|
return {
|
||||||
body: {
|
body: {
|
||||||
logs,
|
logs,
|
||||||
status: data?.status || 'running'
|
status: data?.status
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -121,6 +121,8 @@
|
|||||||
<div class="w-48 text-center text-xs">
|
<div class="w-48 text-center text-xs">
|
||||||
{#if build.status === 'running'}
|
{#if build.status === 'running'}
|
||||||
<div class="font-bold">Running</div>
|
<div class="font-bold">Running</div>
|
||||||
|
{:else if build.status === 'queued'}
|
||||||
|
<div class="font-bold">Queued</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div>{build.since}</div>
|
<div>{build.since}</div>
|
||||||
<div>Finished in <span class="font-bold">{build.took}s</span></div>
|
<div>Finished in <span class="font-bold">{build.took}s</span></div>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
define('WP_ALLOW_MULTISITE', true);
|
define('WP_ALLOW_MULTISITE', true);
|
||||||
define('MULTISITE', true);
|
define('MULTISITE', true);
|
||||||
define('SUBDOMAIN_INSTALL', false);`
|
define('SUBDOMAIN_INSTALL', false);`
|
||||||
: null}>{service.wordpress.extraConfig || 'N/A'}</textarea
|
: 'N/A'}>{service.wordpress.extraConfig}</textarea
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-1 py-5 font-bold">
|
<div class="flex space-x-1 py-5 font-bold">
|
||||||
|
|||||||
@@ -57,13 +57,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { session } from '$app/stores';
|
import { page, session } from '$app/stores';
|
||||||
import { errorNotification } from '$lib/form';
|
import { errorNotification } from '$lib/form';
|
||||||
import DeleteIcon from '$lib/components/DeleteIcon.svelte';
|
import DeleteIcon from '$lib/components/DeleteIcon.svelte';
|
||||||
import Loading from '$lib/components/Loading.svelte';
|
import Loading from '$lib/components/Loading.svelte';
|
||||||
import { del, post } from '$lib/api';
|
import { del, post } from '$lib/api';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { onMount } from 'svelte';
|
const { id } = $page.params;
|
||||||
|
|
||||||
export let service;
|
export let service;
|
||||||
export let isRunning;
|
export let isRunning;
|
||||||
@@ -168,6 +168,76 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="border border-stone-700 h-8" />
|
||||||
|
{/if}
|
||||||
|
{#if service.type && service.destinationDockerId && service.version}
|
||||||
|
<a
|
||||||
|
href="/services/{id}"
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-yellow-500 rounded"
|
||||||
|
class:text-yellow-500={$page.url.pathname === `/services/${id}`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/services/${id}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
title="Configurations"
|
||||||
|
class="icons bg-transparent tooltip-bottom text-sm disabled:text-red-500"
|
||||||
|
data-tooltip="Configurations"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-6 w-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<rect x="4" y="8" width="4" height="4" />
|
||||||
|
<line x1="6" y1="4" x2="6" y2="8" />
|
||||||
|
<line x1="6" y1="12" x2="6" y2="20" />
|
||||||
|
<rect x="10" y="14" width="4" height="4" />
|
||||||
|
<line x1="12" y1="4" x2="12" y2="14" />
|
||||||
|
<line x1="12" y1="18" x2="12" y2="20" />
|
||||||
|
<rect x="16" y="5" width="4" height="4" />
|
||||||
|
<line x1="18" y1="4" x2="18" y2="5" />
|
||||||
|
<line x1="18" y1="9" x2="18" y2="20" />
|
||||||
|
</svg></button
|
||||||
|
></a
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="/services/{id}/secrets"
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-pink-500 rounded"
|
||||||
|
class:text-pink-500={$page.url.pathname === `/services/${id}/secrets`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/services/${id}/secrets`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
title="Secrets"
|
||||||
|
class="icons bg-transparent tooltip-bottom text-sm disabled:text-red-500"
|
||||||
|
data-tooltip="Secrets"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path
|
||||||
|
d="M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3"
|
||||||
|
/>
|
||||||
|
<circle cx="12" cy="11" r="1" />
|
||||||
|
<line x1="12" y1="12" x2="12" y2="14.5" />
|
||||||
|
</svg></button
|
||||||
|
></a
|
||||||
|
>
|
||||||
|
<div class="border border-stone-700 h-8" />
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
on:click={deleteService}
|
on:click={deleteService}
|
||||||
|
|||||||
@@ -14,19 +14,32 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { type, version, destinationDockerId, destinationDocker } = service;
|
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service;
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
const image = getServiceImage(type);
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
image: `${image}:${version}`,
|
||||||
|
volume: `${id}-ngrams:/ngrams`,
|
||||||
|
environmentVariables: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
[id]: {
|
[id]: {
|
||||||
container_name: id,
|
container_name: id,
|
||||||
image: `${image}:${version}`,
|
image: config.image,
|
||||||
networks: [network],
|
networks: [network],
|
||||||
|
environment: config.environmentVariables,
|
||||||
restart: 'always',
|
restart: 'always',
|
||||||
volumes: [`${id}-ngrams:/ngrams`],
|
volumes: [`${id}-ngrams:/ngrams`],
|
||||||
labels: makeLabelForServices('languagetool')
|
labels: makeLabelForServices('languagetool')
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
|
|||||||
import { startHttpProxy } from '$lib/haproxy';
|
import { startHttpProxy } from '$lib/haproxy';
|
||||||
import getPort, { portNumbers } from 'get-port';
|
import getPort, { portNumbers } from 'get-port';
|
||||||
import { getDomain } from '$lib/components/common';
|
import { getDomain } from '$lib/components/common';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler, getServiceImage } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@@ -23,7 +23,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
fqdn,
|
fqdn,
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
minio: { rootUser, rootUserPassword }
|
minio: { rootUser, rootUserPassword },
|
||||||
|
serviceSecret
|
||||||
} = service;
|
} = service;
|
||||||
|
|
||||||
const data = await db.prisma.setting.findFirst();
|
const data = await db.prisma.setting.findFirst();
|
||||||
@@ -38,9 +39,10 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const apiPort = 9000;
|
const apiPort = 9000;
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
image: `minio/minio:${version}`,
|
image: `${image}:${version}`,
|
||||||
volume: `${id}-minio-data:/data`,
|
volume: `${id}-minio-data:/data`,
|
||||||
environmentVariables: {
|
environmentVariables: {
|
||||||
MINIO_ROOT_USER: rootUser,
|
MINIO_ROOT_USER: rootUser,
|
||||||
@@ -48,12 +50,17 @@ export const post: RequestHandler = async (event) => {
|
|||||||
MINIO_BROWSER_REDIRECT_URL: fqdn
|
MINIO_BROWSER_REDIRECT_URL: fqdn
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
[id]: {
|
[id]: {
|
||||||
container_name: id,
|
container_name: id,
|
||||||
image: `minio/minio:${version}`,
|
image: config.image,
|
||||||
command: `server /data --console-address ":${consolePort}"`,
|
command: `server /data --console-address ":${consolePort}"`,
|
||||||
environment: config.environmentVariables,
|
environment: config.environmentVariables,
|
||||||
networks: [network],
|
networks: [network],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler, getServiceImage } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@@ -14,19 +14,30 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { type, version, destinationDockerId, destinationDocker } = service;
|
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service;
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
image: `${image}:${version}`,
|
||||||
|
environmentVariables: {}
|
||||||
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
[id]: {
|
[id]: {
|
||||||
container_name: id,
|
container_name: id,
|
||||||
image: `nocodb/nocodb:${version}`,
|
image: config.image,
|
||||||
networks: [network],
|
networks: [network],
|
||||||
|
environment: config.environmentVariables,
|
||||||
restart: 'always',
|
restart: 'always',
|
||||||
labels: makeLabelForServices('nocodb')
|
labels: makeLabelForServices('nocodb')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler, getServiceImage } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@@ -20,6 +20,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
fqdn,
|
fqdn,
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
|
serviceSecret,
|
||||||
plausibleAnalytics: {
|
plausibleAnalytics: {
|
||||||
id: plausibleDbId,
|
id: plausibleDbId,
|
||||||
username,
|
username,
|
||||||
@@ -31,10 +32,11 @@ export const post: RequestHandler = async (event) => {
|
|||||||
secretKeyBase
|
secretKeyBase
|
||||||
}
|
}
|
||||||
} = service;
|
} = service;
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
plausibleAnalytics: {
|
plausibleAnalytics: {
|
||||||
image: `plausible/analytics:${version}`,
|
image: `${image}:${version}`,
|
||||||
environmentVariables: {
|
environmentVariables: {
|
||||||
ADMIN_USER_EMAIL: email,
|
ADMIN_USER_EMAIL: email,
|
||||||
ADMIN_USER_NAME: username,
|
ADMIN_USER_NAME: username,
|
||||||
@@ -68,6 +70,11 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.plausibleAnalytics.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
|
|||||||
87
src/routes/services/[id]/secrets/_Secret.svelte
Normal file
87
src/routes/services/[id]/secrets/_Secret.svelte
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<script>
|
||||||
|
export let name = '';
|
||||||
|
export let value = '';
|
||||||
|
export let isNewSecret = false;
|
||||||
|
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { del, post } from '$lib/api';
|
||||||
|
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
|
||||||
|
import { errorNotification } from '$lib/form';
|
||||||
|
import { toast } from '@zerodevx/svelte-toast';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
const { id } = $page.params;
|
||||||
|
async function removeSecret() {
|
||||||
|
try {
|
||||||
|
await del(`/services/${id}/secrets.json`, { name });
|
||||||
|
dispatch('refresh');
|
||||||
|
if (isNewSecret) {
|
||||||
|
name = '';
|
||||||
|
value = '';
|
||||||
|
}
|
||||||
|
} catch ({ error }) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function saveSecret(isNew = false) {
|
||||||
|
if (!name) return errorNotification('Name is required.');
|
||||||
|
if (!value) return errorNotification('Value is required.');
|
||||||
|
try {
|
||||||
|
await post(`/services/${id}/secrets.json`, {
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
|
||||||
|
isNew
|
||||||
|
});
|
||||||
|
dispatch('refresh');
|
||||||
|
if (isNewSecret) {
|
||||||
|
name = '';
|
||||||
|
value = '';
|
||||||
|
}
|
||||||
|
toast.push('Secret saved.');
|
||||||
|
} catch ({ error }) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
id={isNewSecret ? 'secretName' : 'secretNameNew'}
|
||||||
|
bind:value={name}
|
||||||
|
required
|
||||||
|
placeholder="EXAMPLE_VARIABLE"
|
||||||
|
class=" border border-dashed border-coolgray-300"
|
||||||
|
readonly={!isNewSecret}
|
||||||
|
class:bg-transparent={!isNewSecret}
|
||||||
|
class:cursor-not-allowed={!isNewSecret}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<CopyPasswordField
|
||||||
|
id={isNewSecret ? 'secretValue' : 'secretValueNew'}
|
||||||
|
name={isNewSecret ? 'secretValue' : 'secretValueNew'}
|
||||||
|
isPasswordField={true}
|
||||||
|
bind:value
|
||||||
|
required
|
||||||
|
placeholder="J$#@UIO%HO#$U%H"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{#if isNewSecret}
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<button class="bg-green-600 hover:bg-green-500" on:click={() => saveSecret(true)}>Add</button>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex flex-row justify-center space-x-2">
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<button class="" on:click={() => saveSecret(false)}>Set</button>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center items-end">
|
||||||
|
<button class="bg-red-600 hover:bg-red-500" on:click={removeSecret}>Remove</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
70
src/routes/services/[id]/secrets/index.json.ts
Normal file
70
src/routes/services/[id]/secrets/index.json.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { getTeam, getUserDetails } from '$lib/common';
|
||||||
|
import * as db from '$lib/database';
|
||||||
|
import { ErrorHandler } from '$lib/database';
|
||||||
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
export const get: RequestHandler = async (event) => {
|
||||||
|
const { teamId, status, body } = await getUserDetails(event);
|
||||||
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
|
const { id } = event.params;
|
||||||
|
try {
|
||||||
|
const secrets = await db.listServiceSecrets(id);
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
secrets: secrets.sort((a, b) => {
|
||||||
|
return ('' + a.name).localeCompare(b.name);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return ErrorHandler(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const post: RequestHandler = async (event) => {
|
||||||
|
const { teamId, status, body } = await getUserDetails(event);
|
||||||
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
|
const { id } = event.params;
|
||||||
|
const { name, value, isBuildSecret, isPRMRSecret, isNew } = await event.request.json();
|
||||||
|
try {
|
||||||
|
if (isNew) {
|
||||||
|
const found = await db.isServiceSecretExists({ id, name });
|
||||||
|
if (found) {
|
||||||
|
throw {
|
||||||
|
error: `Secret ${name} already exists.`
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
await db.createServiceSecret({ id, name, value });
|
||||||
|
return {
|
||||||
|
status: 201
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await db.updateServiceSecret({ id, name, value });
|
||||||
|
return {
|
||||||
|
status: 201
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return ErrorHandler(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const del: RequestHandler = async (event) => {
|
||||||
|
const { teamId, status, body } = await getUserDetails(event);
|
||||||
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
|
const { id } = event.params;
|
||||||
|
const { name } = await event.request.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await db.removeServiceSecret({ id, name });
|
||||||
|
return {
|
||||||
|
status: 200
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return ErrorHandler(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
67
src/routes/services/[id]/secrets/index.svelte
Normal file
67
src/routes/services/[id]/secrets/index.svelte
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<script context="module" lang="ts">
|
||||||
|
import type { Load } from '@sveltejs/kit';
|
||||||
|
export const load: Load = async ({ fetch, params, stuff }) => {
|
||||||
|
let endpoint = `/services/${params.id}/secrets.json`;
|
||||||
|
const res = await fetch(endpoint);
|
||||||
|
if (res.ok) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
service: stuff.service,
|
||||||
|
...(await res.json())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: res.status,
|
||||||
|
error: new Error(`Could not load ${endpoint}`)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let secrets;
|
||||||
|
export let service;
|
||||||
|
import Secret from './_Secret.svelte';
|
||||||
|
import { getDomain } from '$lib/components/common';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { get } from '$lib/api';
|
||||||
|
|
||||||
|
const { id } = $page.params;
|
||||||
|
|
||||||
|
async function refreshSecrets() {
|
||||||
|
const data = await get(`/services/${id}/secrets.json`);
|
||||||
|
secrets = [...data.secrets];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex space-x-1 p-6 font-bold">
|
||||||
|
<div class="mr-4 text-2xl tracking-tight">
|
||||||
|
Secrets {#if service.fqdn}
|
||||||
|
<a href={service.fqdn} target="_blank">{getDomain(service.fqdn)}</a>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
|
||||||
|
<table class="mx-auto border-separate text-left">
|
||||||
|
<thead>
|
||||||
|
<tr class="h-12">
|
||||||
|
<th scope="col">Name</th>
|
||||||
|
<th scope="col">Value</th>
|
||||||
|
<th scope="col" class="w-96 text-center">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each secrets as secret}
|
||||||
|
{#key secret.id}
|
||||||
|
<tr>
|
||||||
|
<Secret name={secret.name} value={secret.value} on:refresh={refreshSecrets} />
|
||||||
|
</tr>
|
||||||
|
{/key}
|
||||||
|
{/each}
|
||||||
|
<tr>
|
||||||
|
<Secret isNewSecret on:refresh={refreshSecrets} />
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
@@ -14,25 +14,31 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { type, version, destinationDockerId, destinationDocker } = service;
|
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service;
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
const baseImage = getServiceImage(type);
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
image: `${baseImage}:${version}`,
|
image: `${image}:${version}`,
|
||||||
volume: `${id}-vaultwarden-data:/data/`
|
volume: `${id}-vaultwarden-data:/data/`,
|
||||||
|
environmentVariables: {}
|
||||||
};
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
[id]: {
|
[id]: {
|
||||||
container_name: id,
|
container_name: id,
|
||||||
image: config.image,
|
image: config.image,
|
||||||
|
environment: config.environmentVariables,
|
||||||
networks: [network],
|
networks: [network],
|
||||||
volumes: [config.volume],
|
volumes: [config.volume],
|
||||||
restart: 'always',
|
restart: 'always',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler, getServiceImage } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@@ -19,6 +19,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
version,
|
version,
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
|
serviceSecret,
|
||||||
vscodeserver: { password }
|
vscodeserver: { password }
|
||||||
} = service;
|
} = service;
|
||||||
|
|
||||||
@@ -26,13 +27,20 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
image: `codercom/code-server:${version}`,
|
image: `${image}:${version}`,
|
||||||
volume: `${id}-vscodeserver-data:/home/coder`,
|
volume: `${id}-vscodeserver-data:/home/coder`,
|
||||||
environmentVariables: {
|
environmentVariables: {
|
||||||
PASSWORD: password
|
PASSWORD: password
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler, getServiceImage } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@@ -19,6 +19,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
version,
|
version,
|
||||||
fqdn,
|
fqdn,
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
|
serviceSecret,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
wordpress: {
|
wordpress: {
|
||||||
mysqlDatabase,
|
mysqlDatabase,
|
||||||
@@ -32,11 +33,12 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
const config = {
|
const config = {
|
||||||
wordpress: {
|
wordpress: {
|
||||||
image: `wordpress:${version}`,
|
image: `${image}:${version}`,
|
||||||
volume: `${id}-wordpress-data:/var/www/html`,
|
volume: `${id}-wordpress-data:/var/www/html`,
|
||||||
environmentVariables: {
|
environmentVariables: {
|
||||||
WORDPRESS_DB_HOST: `${id}-mysql`,
|
WORDPRESS_DB_HOST: `${id}-mysql`,
|
||||||
@@ -58,6 +60,11 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.wordpress.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
const composeFile = {
|
const composeFile = {
|
||||||
version: '3.8',
|
version: '3.8',
|
||||||
services: {
|
services: {
|
||||||
|
|||||||
@@ -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',
|
||||||
@@ -47,7 +47,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
const applicationFound = await db.getApplicationWebhook({ projectId, branch });
|
const applicationFound = await db.getApplicationWebhook({ projectId, branch });
|
||||||
if (applicationFound) {
|
if (applicationFound) {
|
||||||
const webhookSecret = applicationFound.gitSource.githubApp.webhookSecret;
|
const webhookSecret = applicationFound.gitSource.githubApp.webhookSecret || null;
|
||||||
const hmac = crypto.createHmac('sha256', webhookSecret);
|
const hmac = crypto.createHmac('sha256', webhookSecret);
|
||||||
const digest = Buffer.from(
|
const digest = Buffer.from(
|
||||||
'sha256=' + hmac.update(JSON.stringify(body)).digest('hex'),
|
'sha256=' + hmac.update(JSON.stringify(body)).digest('hex'),
|
||||||
@@ -88,6 +88,18 @@ export const post: RequestHandler = async (event) => {
|
|||||||
where: { id: applicationFound.id },
|
where: { id: applicationFound.id },
|
||||||
data: { updatedAt: new Date() }
|
data: { updatedAt: new Date() }
|
||||||
});
|
});
|
||||||
|
await db.prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: applicationFound.id,
|
||||||
|
destinationDockerId: applicationFound.destinationDocker.id,
|
||||||
|
gitSourceId: applicationFound.gitSource.id,
|
||||||
|
githubAppId: applicationFound.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_commit'
|
||||||
|
}
|
||||||
|
});
|
||||||
await buildQueue.add(buildId, {
|
await buildQueue.add(buildId, {
|
||||||
build_id: buildId,
|
build_id: buildId,
|
||||||
type: 'webhook_commit',
|
type: 'webhook_commit',
|
||||||
@@ -136,6 +148,18 @@ export const post: RequestHandler = async (event) => {
|
|||||||
where: { id: applicationFound.id },
|
where: { id: applicationFound.id },
|
||||||
data: { updatedAt: new Date() }
|
data: { updatedAt: new Date() }
|
||||||
});
|
});
|
||||||
|
await db.prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: applicationFound.id,
|
||||||
|
destinationDockerId: applicationFound.destinationDocker.id,
|
||||||
|
gitSourceId: applicationFound.gitSource.id,
|
||||||
|
githubAppId: applicationFound.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_pr'
|
||||||
|
}
|
||||||
|
});
|
||||||
await buildQueue.add(buildId, {
|
await buildQueue.add(buildId, {
|
||||||
build_id: buildId,
|
build_id: buildId,
|
||||||
type: 'webhook_pr',
|
type: 'webhook_pr',
|
||||||
|
|||||||
@@ -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',
|
||||||
@@ -52,6 +52,18 @@ export const post: RequestHandler = async (event) => {
|
|||||||
where: { id: applicationFound.id },
|
where: { id: applicationFound.id },
|
||||||
data: { updatedAt: new Date() }
|
data: { updatedAt: new Date() }
|
||||||
});
|
});
|
||||||
|
await db.prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: applicationFound.id,
|
||||||
|
destinationDockerId: applicationFound.destinationDocker.id,
|
||||||
|
gitSourceId: applicationFound.gitSource.id,
|
||||||
|
githubAppId: applicationFound.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_commit'
|
||||||
|
}
|
||||||
|
});
|
||||||
await buildQueue.add(buildId, {
|
await buildQueue.add(buildId, {
|
||||||
build_id: buildId,
|
build_id: buildId,
|
||||||
type: 'webhook_commit',
|
type: 'webhook_commit',
|
||||||
@@ -133,6 +145,18 @@ export const post: RequestHandler = async (event) => {
|
|||||||
where: { id: applicationFound.id },
|
where: { id: applicationFound.id },
|
||||||
data: { updatedAt: new Date() }
|
data: { updatedAt: new Date() }
|
||||||
});
|
});
|
||||||
|
await db.prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: applicationFound.id,
|
||||||
|
destinationDockerId: applicationFound.destinationDocker.id,
|
||||||
|
gitSourceId: applicationFound.gitSource.id,
|
||||||
|
githubAppId: applicationFound.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_mr'
|
||||||
|
}
|
||||||
|
});
|
||||||
await buildQueue.add(buildId, {
|
await buildQueue.add(buildId, {
|
||||||
build_id: buildId,
|
build_id: buildId,
|
||||||
type: 'webhook_mr',
|
type: 'webhook_mr',
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -42,7 +42,27 @@ textarea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@apply h-12 w-96 rounded bg-coolgray-200 p-2 text-xs font-bold tracking-tight text-white outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:text-stone-600 md:text-sm;
|
@apply h-12 w-96 rounded bg-coolgray-200 p-2 text-xs font-bold tracking-tight text-white placeholder-stone-600 outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:text-stone-600 md:text-sm;
|
||||||
|
}
|
||||||
|
.svelte-select {
|
||||||
|
--background: rgb(32 32 32);
|
||||||
|
--inputColor: white;
|
||||||
|
--multiItemPadding: 0;
|
||||||
|
--multiSelectPadding: 0 0.5rem 0 0.5rem;
|
||||||
|
--border: none;
|
||||||
|
--placeholderColor: rgb(87 83 78);
|
||||||
|
--listBackground: rgb(32 32 32);
|
||||||
|
--itemColor: white;
|
||||||
|
--itemHoverBG: rgb(107 22 237);
|
||||||
|
--multiItemBG: rgb(32 32 32);
|
||||||
|
--multiClearHoverBG: transparent;
|
||||||
|
--multiClearHoverFill: rgb(239 68 68);
|
||||||
|
--multiItemActiveBG: transparent;
|
||||||
|
--multiClearBG: transparent;
|
||||||
|
--clearSelectFocusColor: white;
|
||||||
|
--clearSelectHoverColor: rgb(239 68 68);
|
||||||
|
--multiItemBorderRadius: 0.25rem;
|
||||||
|
--listShadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
|||||||
@@ -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