mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-25 20:49:28 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1c1988db4 | ||
|
|
af99ea4678 | ||
|
|
1281a0f7e4 | ||
|
|
d8350cd4ee | ||
|
|
e3b7c23ed9 | ||
|
|
eae1ea21d6 | ||
|
|
541aa76b64 | ||
|
|
7b8555d524 | ||
|
|
fdf998c181 | ||
|
|
3d6b343adc | ||
|
|
e338cecc14 | ||
|
|
e5537a33fb | ||
|
|
35384deb68 | ||
|
|
547ca60c2a | ||
|
|
376f6f7455 | ||
|
|
abe92dedff | ||
|
|
4b521ceedc | ||
|
|
6dfcb9e52b | ||
|
|
335e3216e2 | ||
|
|
5b22bb4818 |
@@ -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.29",
|
"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,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 {
|
||||||
|
|||||||
@@ -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'));
|
||||||
|
|||||||
@@ -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,10 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
const isPnpm =
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
installCommand.includes('pnpm') ||
|
|
||||||
buildCommand.includes('pnpm') ||
|
|
||||||
startCommand.includes('pnpm');
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -39,17 +37,9 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
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('RUN pnpm add -g pnpm');
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
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 || ''} ./`);
|
|
||||||
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,10 +14,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
const isPnpm =
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
installCommand.includes('pnpm') ||
|
|
||||||
buildCommand.includes('pnpm') ||
|
|
||||||
startCommand.includes('pnpm');
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -39,17 +38,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
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('RUN pnpm add -g pnpm');
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
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 || ''} ./`);
|
|
||||||
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,10 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
const isPnpm =
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
installCommand.includes('pnpm') ||
|
|
||||||
buildCommand.includes('pnpm') ||
|
|
||||||
startCommand.includes('pnpm');
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /usr/src/app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
@@ -39,17 +37,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
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('RUN pnpm add -g pnpm');
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
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 || ''} ./`);
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -69,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;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export async function removeApplication({ id, teamId }) {
|
|||||||
|
|
||||||
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 } } } });
|
||||||
}
|
}
|
||||||
@@ -79,17 +80,20 @@ export async function getApplicationWebhook({ projectId, branch }) {
|
|||||||
secrets: true
|
secrets: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (application.gitSource?.githubApp?.clientSecret) {
|
if (!application) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (application?.gitSource?.githubApp?.clientSecret) {
|
||||||
application.gitSource.githubApp.clientSecret = decrypt(
|
application.gitSource.githubApp.clientSecret = decrypt(
|
||||||
application.gitSource.githubApp.clientSecret
|
application.gitSource.githubApp.clientSecret
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (application.gitSource?.githubApp?.webhookSecret) {
|
if (application?.gitSource?.githubApp?.webhookSecret) {
|
||||||
application.gitSource.githubApp.webhookSecret = decrypt(
|
application.gitSource.githubApp.webhookSecret = decrypt(
|
||||||
application.gitSource.githubApp.webhookSecret
|
application.gitSource.githubApp.webhookSecret
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (application.gitSource?.githubApp?.privateKey) {
|
if (application?.gitSource?.githubApp?.privateKey) {
|
||||||
application.gitSource.githubApp.privateKey = decrypt(
|
application.gitSource.githubApp.privateKey = decrypt(
|
||||||
application.gitSource.githubApp.privateKey
|
application.gitSource.githubApp.privateKey
|
||||||
);
|
);
|
||||||
@@ -152,6 +156,9 @@ export async function getApplication({ id, teamId }) {
|
|||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (body?.phpModules) {
|
||||||
|
body.phpModules = body.phpModules.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
return { ...body };
|
return { ...body };
|
||||||
}
|
}
|
||||||
@@ -207,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 },
|
||||||
@@ -220,7 +228,8 @@ export async function configureApplication({
|
|||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory,
|
publishDirectory,
|
||||||
name
|
name,
|
||||||
|
phpModules
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,7 +17,7 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
secrets,
|
secrets,
|
||||||
pullmergeRequestId
|
pullmergeRequestId
|
||||||
} = data;
|
} = data;
|
||||||
const isPnpm = installCommand.includes('pnpm') || buildCommand.includes('pnpm');
|
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');
|
||||||
@@ -40,19 +41,10 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
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('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 });
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}/${job.data.build_id}`;
|
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!',
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -57,7 +175,6 @@
|
|||||||
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;
|
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`;
|
||||||
}
|
}
|
||||||
@@ -108,8 +225,9 @@
|
|||||||
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')) {
|
||||||
@@ -363,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"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user