commit
1a7c4310d0
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"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.32",
|
"version": "2.1.0",
|
||||||
"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",
|
||||||
"dev:stop": "docker-compose -f docker-compose-dev.yaml down",
|
"dev:stop": "docker-compose -f docker-compose-dev.yaml down",
|
||||||
"dev:logs": "docker-compose -f docker-compose-dev.yaml logs -f --tail 10",
|
"dev:logs": "docker-compose -f docker-compose-dev.yaml logs -f --tail 10",
|
||||||
"studio": "npx prisma studio",
|
"studio": "npx prisma studio",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"@sveltejs/kit": "1.0.0-next.288",
|
"@sveltejs/kit": "1.0.0-next.288",
|
||||||
"@types/bcrypt": "5.0.0",
|
"@types/bcrypt": "5.0.0",
|
||||||
"@types/js-cookie": "3.0.1",
|
"@types/js-cookie": "3.0.1",
|
||||||
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/node": "17.0.21",
|
"@types/node": "17.0.21",
|
||||||
"@types/node-forge": "1.0.0",
|
"@types/node-forge": "1.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "4.31.1",
|
"@typescript-eslint/eslint-plugin": "4.31.1",
|
||||||
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -9,6 +9,7 @@ specifiers:
|
|||||||
'@sveltejs/kit': 1.0.0-next.288
|
'@sveltejs/kit': 1.0.0-next.288
|
||||||
'@types/bcrypt': 5.0.0
|
'@types/bcrypt': 5.0.0
|
||||||
'@types/js-cookie': 3.0.1
|
'@types/js-cookie': 3.0.1
|
||||||
|
'@types/js-yaml': ^4.0.5
|
||||||
'@types/node': 17.0.21
|
'@types/node': 17.0.21
|
||||||
'@types/node-forge': 1.0.0
|
'@types/node-forge': 1.0.0
|
||||||
'@typescript-eslint/eslint-plugin': 4.31.1
|
'@typescript-eslint/eslint-plugin': 4.31.1
|
||||||
@ -84,6 +85,7 @@ devDependencies:
|
|||||||
'@sveltejs/kit': 1.0.0-next.288_svelte@3.46.4
|
'@sveltejs/kit': 1.0.0-next.288_svelte@3.46.4
|
||||||
'@types/bcrypt': 5.0.0
|
'@types/bcrypt': 5.0.0
|
||||||
'@types/js-cookie': 3.0.1
|
'@types/js-cookie': 3.0.1
|
||||||
|
'@types/js-yaml': 4.0.5
|
||||||
'@types/node': 17.0.21
|
'@types/node': 17.0.21
|
||||||
'@types/node-forge': 1.0.0
|
'@types/node-forge': 1.0.0
|
||||||
'@typescript-eslint/eslint-plugin': 4.31.1_386b67ad67ef29c6a0ccaf3e9b60f945
|
'@typescript-eslint/eslint-plugin': 4.31.1_386b67ad67ef29c6a0ccaf3e9b60f945
|
||||||
@ -537,6 +539,13 @@ packages:
|
|||||||
}
|
}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@types/js-yaml/4.0.5:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==
|
||||||
|
}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/json-schema/7.0.9:
|
/@types/json-schema/7.0.9:
|
||||||
resolution:
|
resolution:
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ApplicationPersistentStorage" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"applicationId" TEXT NOT NULL,
|
||||||
|
"path" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "ApplicationPersistentStorage_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ApplicationPersistentStorage_applicationId_key" ON "ApplicationPersistentStorage"("applicationId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ApplicationPersistentStorage_path_key" ON "ApplicationPersistentStorage"("path");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ApplicationPersistentStorage_applicationId_path_key" ON "ApplicationPersistentStorage"("applicationId", "path");
|
@ -86,6 +86,7 @@ model Application {
|
|||||||
startCommand String?
|
startCommand String?
|
||||||
baseDirectory String?
|
baseDirectory String?
|
||||||
publishDirectory String?
|
publishDirectory String?
|
||||||
|
phpModules String?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
settings ApplicationSettings?
|
settings ApplicationSettings?
|
||||||
@ -95,7 +96,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?
|
persistentStorage ApplicationPersistentStorage[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model ApplicationSettings {
|
model ApplicationSettings {
|
||||||
@ -110,6 +111,17 @@ model ApplicationSettings {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model ApplicationPersistentStorage {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
application Application @relation(fields: [applicationId], references: [id])
|
||||||
|
applicationId String @unique
|
||||||
|
path String @unique
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
@@unique([applicationId, path])
|
||||||
|
}
|
||||||
|
|
||||||
model Secret {
|
model Secret {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
name String
|
name String
|
||||||
|
5
src/app.d.ts
vendored
5
src/app.d.ts
vendored
@ -7,7 +7,10 @@ declare namespace App {
|
|||||||
}
|
}
|
||||||
interface Platform {}
|
interface Platform {}
|
||||||
interface Session extends SessionData {}
|
interface Session extends SessionData {}
|
||||||
interface Stuff {}
|
interface Stuff {
|
||||||
|
application: any;
|
||||||
|
isRunning: boolean;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SessionData {
|
interface SessionData {
|
||||||
|
@ -29,10 +29,10 @@ export function makeLabelForStandaloneApplication({
|
|||||||
fqdn = `${protocol}://${pullmergeRequestId}.${domain}`;
|
fqdn = `${protocol}://${pullmergeRequestId}.${domain}`;
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'--label coolify.managed=true',
|
'coolify.managed=true',
|
||||||
`--label coolify.version=${version}`,
|
`coolify.version=${version}`,
|
||||||
`--label coolify.type=standalone-application`,
|
`coolify.type=standalone-application`,
|
||||||
`--label coolify.configuration=${base64Encode(
|
`coolify.configuration=${base64Encode(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
applicationId,
|
applicationId,
|
||||||
fqdn,
|
fqdn,
|
||||||
@ -135,6 +135,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
|||||||
RewriteRule ^(.+)$ index.php [QSA,L]
|
RewriteRule ^(.+)$ index.php [QSA,L]
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R 1000 /app`);
|
||||||
saveBuildLog({ line: 'Copied default configuration file for PHP.', buildId, applicationId });
|
saveBuildLog({ line: 'Copied default configuration file for PHP.', buildId, applicationId });
|
||||||
} else if (staticDeployments.includes(buildPack)) {
|
} else if (staticDeployments.includes(buildPack)) {
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
@ -142,27 +143,35 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
|||||||
`user nginx;
|
`user nginx;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
error_log /docker.stdout;
|
||||||
pid /var/run/nginx.pid;
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /etc/nginx/mime.types;
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /docker.stdout main;
|
||||||
|
|
||||||
access_log off;
|
|
||||||
sendfile on;
|
sendfile on;
|
||||||
#tcp_nopush on;
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root /app;
|
||||||
index index.html;
|
index index.html;
|
||||||
try_files $uri $uri/index.html $uri/ /index.html =404;
|
try_files $uri $uri/index.html $uri/ /index.html =404;
|
||||||
}
|
}
|
||||||
@ -173,7 +182,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
|||||||
#
|
#
|
||||||
error_page 500 502 503 504 /50x.html;
|
error_page 500 502 503 504 /50x.html;
|
||||||
location = /50x.html {
|
location = /50x.html {
|
||||||
root /usr/share/nginx/html;
|
root /app;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,17 @@ const createDockerfile = async (data, imageforBuild): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${imageforBuild}`);
|
Dockerfile.push(`FROM ${imageforBuild}`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /app');
|
||||||
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 /app/${publishDirectory} ./`);
|
||||||
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'nginx:stable-alpine';
|
const image = 'webdevops/nginx:alpine';
|
||||||
const imageForBuild = 'node:lts';
|
const imageForBuild = 'node:lts';
|
||||||
|
|
||||||
await buildCacheImageWithNode(data, imageForBuild);
|
await buildCacheImageWithNode(data, imageForBuild);
|
||||||
|
@ -7,15 +7,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const isPnpm = startCommand.includes('pnpm');
|
const isPnpm = startCommand.includes('pnpm');
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (isPnpm) {
|
if (isPnpm) {
|
||||||
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(
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /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}`);
|
||||||
|
@ -16,7 +16,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
@ -17,7 +17,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
@ -16,7 +16,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
@ -6,26 +6,17 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
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('WORKDIR /app');
|
||||||
Dockerfile.push(
|
Dockerfile.push(`COPY .${baseDirectory || ''} /app`);
|
||||||
`ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/`
|
Dockerfile.push(`COPY /.htaccess .`);
|
||||||
);
|
Dockerfile.push(`COPY /entrypoint.sh /opt/docker/provision/entrypoint.d/30-entrypoint.sh`);
|
||||||
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('WORKDIR /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('RUN chown -R www-data /var/www/html');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'php:apache';
|
const image = 'webdevops/php-nginx';
|
||||||
await createDockerfile(data, image);
|
await createDockerfile(data, image);
|
||||||
await buildImage(data);
|
await buildImage(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -7,17 +7,16 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/${publishDirectory} ./`);
|
||||||
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'nginx:stable-alpine';
|
const image = 'webdevops/nginx:alpine';
|
||||||
const imageForBuild = 'node:lts';
|
const imageForBuild = 'node:lts';
|
||||||
await buildCacheImageWithNode(data, imageForBuild);
|
await buildCacheImageWithNode(data, imageForBuild);
|
||||||
await createDockerfile(data, image);
|
await createDockerfile(data, image);
|
||||||
|
@ -7,23 +7,21 @@ const createDockerfile = async (data, image, name): Promise<void> => {
|
|||||||
const { workdir, port, applicationId, tag } = data;
|
const { workdir, port, applicationId, tag } = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/src/app/target target`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/target target`);
|
||||||
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/local/cargo /usr/local/cargo`);
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /usr/local/cargo /usr/local/cargo`);
|
||||||
Dockerfile.push(`COPY . .`);
|
Dockerfile.push(`COPY . .`);
|
||||||
Dockerfile.push(`RUN cargo build --release --bin ${name}`);
|
Dockerfile.push(`RUN cargo build --release --bin ${name}`);
|
||||||
Dockerfile.push('FROM debian:buster-slim');
|
Dockerfile.push('FROM debian:buster-slim');
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(
|
Dockerfile.push(
|
||||||
`RUN apt-get update -y && apt-get install -y --no-install-recommends openssl libcurl4 ca-certificates && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*`
|
`RUN apt-get update -y && apt-get install -y --no-install-recommends openssl libcurl4 ca-certificates && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*`
|
||||||
);
|
);
|
||||||
Dockerfile.push(`RUN update-ca-certificates`);
|
Dockerfile.push(`RUN update-ca-certificates`);
|
||||||
Dockerfile.push(
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/target/release/${name} ${name}`);
|
||||||
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/target/release/${name} ${name}`
|
|
||||||
);
|
|
||||||
Dockerfile.push(`EXPOSE ${port}`);
|
Dockerfile.push(`EXPOSE ${port}`);
|
||||||
Dockerfile.push(`CMD ["/usr/src/app/${name}"]`);
|
Dockerfile.push(`CMD ["/app/${name}"]`);
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
@ -33,21 +33,18 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (buildCommand) {
|
if (buildCommand) {
|
||||||
Dockerfile.push(
|
Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /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(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'nginx:stable-alpine';
|
const image = 'webdevops/nginx:alpine';
|
||||||
const imageForBuild = 'node:lts';
|
const imageForBuild = 'node:lts';
|
||||||
if (data.buildCommand) await buildCacheImageWithNode(data, imageForBuild);
|
if (data.buildCommand) await buildCacheImageWithNode(data, imageForBuild);
|
||||||
await createDockerfile(data, image);
|
await createDockerfile(data, image);
|
||||||
|
@ -6,18 +6,17 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /app');
|
||||||
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 /app/${publishDirectory} ./`);
|
||||||
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'nginx:stable-alpine';
|
const image = 'webdevops/nginx:alpine';
|
||||||
const imageForBuild = 'node:lts';
|
const imageForBuild = 'node:lts';
|
||||||
|
|
||||||
await buildCacheImageWithNode(data, imageForBuild);
|
await buildCacheImageWithNode(data, imageForBuild);
|
||||||
|
@ -6,35 +6,19 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
|
|
||||||
Dockerfile.push(`FROM ${image}`);
|
Dockerfile.push(`FROM ${image}`);
|
||||||
Dockerfile.push('WORKDIR /usr/share/nginx/html');
|
Dockerfile.push('WORKDIR /app');
|
||||||
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 /app/${publishDirectory} ./`);
|
||||||
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);
|
||||||
Dockerfile.push(`EXPOSE 80`);
|
Dockerfile.push(`EXPOSE 80`);
|
||||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
|
||||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function (data) {
|
export default async function (data) {
|
||||||
try {
|
try {
|
||||||
const image = 'nginx:stable-alpine';
|
const image = 'webdevops/nginx: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) {
|
||||||
|
@ -9,7 +9,16 @@ export const dateOptions: DateTimeFormatOptions = {
|
|||||||
hour12: false
|
hour12: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export const staticDeployments = ['react', 'vuejs', 'static', 'svelte', 'gatsby', 'php'];
|
export const staticDeployments = [
|
||||||
|
'react',
|
||||||
|
'vuejs',
|
||||||
|
'static',
|
||||||
|
'svelte',
|
||||||
|
'gatsby',
|
||||||
|
'php',
|
||||||
|
'astro',
|
||||||
|
'eleventy'
|
||||||
|
];
|
||||||
export const notNodeDeployments = ['php', 'docker', 'rust'];
|
export const notNodeDeployments = ['php', 'docker', 'rust'];
|
||||||
|
|
||||||
export function getDomain(domain) {
|
export function getDomain(domain) {
|
||||||
|
@ -66,6 +66,7 @@ export async function removeApplication({ id, teamId }) {
|
|||||||
await prisma.buildLog.deleteMany({ where: { applicationId: id } });
|
await prisma.buildLog.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.build.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.applicationPersistentStorage.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.application.deleteMany({ where: { id, teams: { some: { id: teamId } } } });
|
await prisma.application.deleteMany({ where: { id, teams: { some: { id: teamId } } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +135,8 @@ export async function getApplication({ id, teamId }) {
|
|||||||
destinationDocker: true,
|
destinationDocker: true,
|
||||||
settings: true,
|
settings: true,
|
||||||
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
||||||
secrets: true
|
secrets: true,
|
||||||
|
persistentStorage: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -156,9 +158,6 @@ export async function getApplication({ id, teamId }) {
|
|||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (body?.phpModules) {
|
|
||||||
body.phpModules = body.phpModules.split(',');
|
|
||||||
}
|
|
||||||
|
|
||||||
return { ...body };
|
return { ...body };
|
||||||
}
|
}
|
||||||
@ -214,8 +213,7 @@ 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 },
|
||||||
@ -228,8 +226,7 @@ export async function configureApplication({
|
|||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
publishDirectory,
|
publishDirectory,
|
||||||
name,
|
name
|
||||||
phpModules
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -268,3 +265,7 @@ export async function createBuild({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getPersistentStorage(id) {
|
||||||
|
return await prisma.applicationPersistentStorage.findMany({ where: { applicationId: id } });
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
const isPnpm = checkPnpm(installCommand, buildCommand);
|
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 /app');
|
||||||
Dockerfile.push(`LABEL coolify.image=true`);
|
Dockerfile.push(`LABEL coolify.image=true`);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
@ -65,14 +65,14 @@ export async function buildCacheImageWithCargo(data, imageForBuild) {
|
|||||||
} = data;
|
} = data;
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
Dockerfile.push(`FROM ${imageForBuild} as planner-${applicationId}`);
|
Dockerfile.push(`FROM ${imageForBuild} as planner-${applicationId}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push('RUN cargo install cargo-chef');
|
Dockerfile.push('RUN cargo install cargo-chef');
|
||||||
Dockerfile.push('COPY . .');
|
Dockerfile.push('COPY . .');
|
||||||
Dockerfile.push('RUN cargo chef prepare --recipe-path recipe.json');
|
Dockerfile.push('RUN cargo chef prepare --recipe-path recipe.json');
|
||||||
Dockerfile.push(`FROM ${imageForBuild}`);
|
Dockerfile.push(`FROM ${imageForBuild}`);
|
||||||
Dockerfile.push('WORKDIR /usr/src/app');
|
Dockerfile.push('WORKDIR /app');
|
||||||
Dockerfile.push('RUN cargo install cargo-chef');
|
Dockerfile.push('RUN cargo install cargo-chef');
|
||||||
Dockerfile.push(`COPY --from=planner-${applicationId} /usr/src/app/recipe.json recipe.json`);
|
Dockerfile.push(`COPY --from=planner-${applicationId} /app/recipe.json recipe.json`);
|
||||||
Dockerfile.push('RUN cargo chef cook --release --recipe-path recipe.json');
|
Dockerfile.push('RUN cargo chef cook --release --recipe-path recipe.json');
|
||||||
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 });
|
||||||
|
@ -103,6 +103,7 @@ export async function generateSSLCerts() {
|
|||||||
orderBy: { createdAt: 'desc' }
|
orderBy: { createdAt: 'desc' }
|
||||||
});
|
});
|
||||||
for (const application of applications) {
|
for (const application of applications) {
|
||||||
|
try {
|
||||||
const {
|
const {
|
||||||
fqdn,
|
fqdn,
|
||||||
id,
|
id,
|
||||||
@ -132,6 +133,9 @@ export async function generateSSLCerts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`Error during generateSSLCerts with ${application.fqdn}: ${error}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const services = await db.prisma.service.findMany({
|
const services = await db.prisma.service.findMany({
|
||||||
include: {
|
include: {
|
||||||
@ -145,6 +149,7 @@ export async function generateSSLCerts() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
|
try {
|
||||||
const {
|
const {
|
||||||
fqdn,
|
fqdn,
|
||||||
id,
|
id,
|
||||||
@ -160,6 +165,9 @@ export async function generateSSLCerts() {
|
|||||||
if (isHttps) ssls.push({ domain, id, isCoolify: false });
|
if (isHttps) ssls.push({ domain, id, isCoolify: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`Error during generateSSLCerts with ${service.fqdn}: ${error}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const { fqdn } = await db.prisma.setting.findFirst();
|
const { fqdn } = await db.prisma.setting.findFirst();
|
||||||
if (fqdn) {
|
if (fqdn) {
|
||||||
|
@ -19,6 +19,7 @@ import {
|
|||||||
makeLabelForStandaloneApplication,
|
makeLabelForStandaloneApplication,
|
||||||
setDefaultConfiguration
|
setDefaultConfiguration
|
||||||
} from '$lib/buildPacks/common';
|
} from '$lib/buildPacks/common';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
export default async function (job) {
|
export default async function (job) {
|
||||||
/*
|
/*
|
||||||
@ -49,7 +50,8 @@ export default async function (job) {
|
|||||||
type,
|
type,
|
||||||
pullmergeRequestId = null,
|
pullmergeRequestId = null,
|
||||||
sourceBranch = null,
|
sourceBranch = null,
|
||||||
settings
|
settings,
|
||||||
|
persistentStorage
|
||||||
} = job.data;
|
} = job.data;
|
||||||
const { debug } = settings;
|
const { debug } = settings;
|
||||||
|
|
||||||
@ -66,8 +68,12 @@ export default async function (job) {
|
|||||||
});
|
});
|
||||||
let imageId = applicationId;
|
let imageId = applicationId;
|
||||||
let domain = getDomain(fqdn);
|
let domain = getDomain(fqdn);
|
||||||
const isHttps = fqdn.startsWith('https://');
|
let volumes =
|
||||||
|
persistentStorage?.map((storage) => {
|
||||||
|
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${
|
||||||
|
buildPack !== 'docker' ? '/app' : ''
|
||||||
|
}${storage.path}`;
|
||||||
|
}) || [];
|
||||||
// Previews, we need to get the source branch and set subdomain
|
// Previews, we need to get the source branch and set subdomain
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
branch = sourceBranch;
|
branch = sourceBranch;
|
||||||
@ -255,14 +261,53 @@ export default async function (job) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
|
saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
|
||||||
const { stderr } = await asyncExecShell(
|
// for await (const volume of volumes) {
|
||||||
`DOCKER_HOST=${host} docker run ${envFound && `--env-file=${workdir}/.env`} ${labels.join(
|
// const id = volume.split(':')[0];
|
||||||
' '
|
// try {
|
||||||
)} --name ${imageId} --network ${
|
// await asyncExecShell(`DOCKER_HOST=${host} docker volume inspect ${id}`);
|
||||||
docker.network
|
// } catch (error) {
|
||||||
} --restart always -d ${applicationId}:${tag}`
|
// await asyncExecShell(`DOCKER_HOST=${host} docker volume create ${id}`);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
const composeVolumes = volumes.map((volume) => {
|
||||||
|
return {
|
||||||
|
[`${volume.split(':')[0]}`]: {
|
||||||
|
name: volume.split(':')[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const compose = {
|
||||||
|
version: '3.8',
|
||||||
|
services: {
|
||||||
|
[imageId]: {
|
||||||
|
image: `${applicationId}:${tag}`,
|
||||||
|
container_name: imageId,
|
||||||
|
volumes,
|
||||||
|
env_file: envFound ? [`${workdir}/.env`] : [],
|
||||||
|
networks: [docker.network],
|
||||||
|
labels: labels,
|
||||||
|
depends_on: [],
|
||||||
|
restart: 'always'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
[docker.network]: {
|
||||||
|
external: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
volumes: Object.assign({}, ...composeVolumes)
|
||||||
|
};
|
||||||
|
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(compose));
|
||||||
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker compose --project-directory ${workdir} up -d`
|
||||||
);
|
);
|
||||||
if (stderr) console.log(stderr);
|
|
||||||
|
// const { stderr } = await asyncExecShell(
|
||||||
|
// `DOCKER_HOST=${host} docker run ${envFound && `--env-file=${workdir}/.env`} ${labels.join(
|
||||||
|
// ' '
|
||||||
|
// )} --name ${imageId} --network ${docker.network} --restart always ${volumes.length > 0 ? volumes : ''
|
||||||
|
// } -d ${applicationId}:${tag}`
|
||||||
|
// );
|
||||||
saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
saveBuildLog({ line: error, buildId, applicationId });
|
saveBuildLog({ line: error, buildId, applicationId });
|
||||||
|
@ -4,6 +4,7 @@ export default async function () {
|
|||||||
try {
|
try {
|
||||||
return await generateSSLCerts();
|
return await generateSSLCerts();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,6 +271,35 @@
|
|||||||
</svg></button
|
</svg></button
|
||||||
></a
|
></a
|
||||||
>
|
>
|
||||||
|
<a
|
||||||
|
href="/applications/{id}/storage"
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-pink-500 rounded"
|
||||||
|
class:text-pink-500={$page.url.pathname === `/applications/${id}/storage`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/storage`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
title="Persistent Storage"
|
||||||
|
class="icons bg-transparent tooltip-bottom text-sm disabled:text-red-500"
|
||||||
|
data-tooltip="Persistent Storage"
|
||||||
|
>
|
||||||
|
<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" />
|
||||||
|
<ellipse cx="12" cy="6" rx="8" ry="3" />
|
||||||
|
<path d="M4 6v6a8 3 0 0 0 16 0v-6" />
|
||||||
|
<path d="M4 12v6a8 3 0 0 0 16 0v-6" />
|
||||||
|
</svg>
|
||||||
|
</button></a
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
href="/applications/{id}/previews"
|
href="/applications/{id}/previews"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
|
@ -11,6 +11,7 @@ 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 { pullmergeRequestId = null, branch } = await event.request.json();
|
||||||
try {
|
try {
|
||||||
const buildId = cuid();
|
const buildId = cuid();
|
||||||
const applicationFound = await db.getApplication({ id, teamId });
|
const applicationFound = await db.getApplication({ id, teamId });
|
||||||
@ -42,7 +43,17 @@ export const post: RequestHandler = async (event) => {
|
|||||||
type: 'manual'
|
type: 'manual'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (pullmergeRequestId) {
|
||||||
|
await buildQueue.add(buildId, {
|
||||||
|
build_id: buildId,
|
||||||
|
type: 'manual',
|
||||||
|
...applicationFound,
|
||||||
|
sourceBranch: branch,
|
||||||
|
pullmergeRequestId
|
||||||
|
});
|
||||||
|
} else {
|
||||||
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,
|
||||||
body: {
|
body: {
|
||||||
|
@ -52,8 +52,7 @@ 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);
|
||||||
@ -69,8 +68,7 @@ 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,125 +47,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
@ -225,9 +107,8 @@
|
|||||||
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, phpModules: tempPhpModules });
|
await post(`/applications/${id}.json`, { ...application });
|
||||||
return window.location.reload();
|
return window.location.reload();
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
if (error.startsWith('DNS not set')) {
|
if (error.startsWith('DNS not set')) {
|
||||||
@ -481,19 +362,6 @@
|
|||||||
/>
|
/>
|
||||||
</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"
|
||||||
|
@ -26,15 +26,28 @@
|
|||||||
export let applicationSecrets;
|
export let applicationSecrets;
|
||||||
import { getDomain } from '$lib/components/common';
|
import { getDomain } from '$lib/components/common';
|
||||||
import Secret from '../secrets/_Secret.svelte';
|
import Secret from '../secrets/_Secret.svelte';
|
||||||
import { get } from '$lib/api';
|
import { get, post } from '$lib/api';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import Explainer from '$lib/components/Explainer.svelte';
|
import Explainer from '$lib/components/Explainer.svelte';
|
||||||
|
import { errorNotification } from '$lib/form';
|
||||||
|
import { toast } from '@zerodevx/svelte-toast';
|
||||||
|
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
async function refreshSecrets() {
|
async function refreshSecrets() {
|
||||||
const data = await get(`/applications/${id}/secrets.json`);
|
const data = await get(`/applications/${id}/secrets.json`);
|
||||||
PRMRSecrets = [...data.secrets];
|
PRMRSecrets = [...data.secrets];
|
||||||
}
|
}
|
||||||
|
async function redeploy(container) {
|
||||||
|
try {
|
||||||
|
await post(`/applications/${id}/deploy.json`, {
|
||||||
|
pullmergeRequestId: container.pullmergeRequestId,
|
||||||
|
branch: container.branch
|
||||||
|
});
|
||||||
|
toast.push('Application redeployed queued.');
|
||||||
|
} catch ({ error }) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex space-x-1 p-6 font-bold">
|
<div class="flex space-x-1 p-6 font-bold">
|
||||||
@ -90,6 +103,11 @@
|
|||||||
<div class="truncate text-center text-xl font-bold">{getDomain(container.fqdn)}</div>
|
<div class="truncate text-center text-xl font-bold">{getDomain(container.fqdn)}</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<button class="bg-coollabs hover:bg-coollabs-100" on:click={() => redeploy(container)}
|
||||||
|
>Redeploy</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
|
73
src/routes/applications/[id]/storage/_Storage.svelte
Normal file
73
src/routes/applications/[id]/storage/_Storage.svelte
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let isNew = false;
|
||||||
|
export let storage = {
|
||||||
|
id: null,
|
||||||
|
path: null
|
||||||
|
};
|
||||||
|
import { del, post } from '$lib/api';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
|
import { errorNotification } from '$lib/form';
|
||||||
|
import { toast } from '@zerodevx/svelte-toast';
|
||||||
|
const { id } = $page.params;
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
async function saveStorage(newStorage = false) {
|
||||||
|
try {
|
||||||
|
if (!storage.path) return errorNotification('Path is required.');
|
||||||
|
storage.path = storage.path.startsWith('/') ? storage.path : `/${storage.path}`;
|
||||||
|
storage.path = storage.path.endsWith('/') ? storage.path.slice(0, -1) : storage.path;
|
||||||
|
storage.path.replace(/\/\//g, '/');
|
||||||
|
await post(`/applications/${id}/storage.json`, {
|
||||||
|
path: storage.path,
|
||||||
|
storageId: storage.id,
|
||||||
|
newStorage
|
||||||
|
});
|
||||||
|
dispatch('refresh');
|
||||||
|
if (isNew) {
|
||||||
|
storage.path = null;
|
||||||
|
storage.id = null;
|
||||||
|
}
|
||||||
|
if (newStorage) toast.push('Storage saved.');
|
||||||
|
else toast.push('Storage updated.');
|
||||||
|
} catch ({ error }) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function removeStorage() {
|
||||||
|
try {
|
||||||
|
await del(`/applications/${id}/storage.json`, { path: storage.path });
|
||||||
|
dispatch('refresh');
|
||||||
|
toast.push('Storage deleted.');
|
||||||
|
} catch ({ error }) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
bind:value={storage.path}
|
||||||
|
required
|
||||||
|
placeholder="eg: /sqlite.db"
|
||||||
|
class=" border border-dashed border-coolgray-300"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{#if isNew}
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<button class="bg-green-600 hover:bg-green-500" on:click={() => saveStorage(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={() => saveStorage(false)}>Set</button>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center items-end">
|
||||||
|
<button class="bg-red-600 hover:bg-red-500" on:click={removeStorage}>Remove</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</td>
|
63
src/routes/applications/[id]/storage/index.json.ts
Normal file
63
src/routes/applications/[id]/storage/index.json.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import { 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 { status, body, teamId } = await getUserDetails(event, false);
|
||||||
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
|
const { id } = event.params;
|
||||||
|
try {
|
||||||
|
const persistentStorages = await db.getPersistentStorage(id);
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
persistentStorages
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} 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 { path, newStorage, storageId } = await event.request.json();
|
||||||
|
try {
|
||||||
|
if (newStorage) {
|
||||||
|
await db.prisma.applicationPersistentStorage.create({
|
||||||
|
data: { path, application: { connect: { id } } }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await db.prisma.applicationPersistentStorage.update({
|
||||||
|
where: { id: storageId },
|
||||||
|
data: { path }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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 { path } = await event.request.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await db.prisma.applicationPersistentStorage.deleteMany({ where: { applicationId: id, path } });
|
||||||
|
return {
|
||||||
|
status: 200
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return ErrorHandler(error);
|
||||||
|
}
|
||||||
|
};
|
73
src/routes/applications/[id]/storage/index.svelte
Normal file
73
src/routes/applications/[id]/storage/index.svelte
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<script context="module" lang="ts">
|
||||||
|
import type { Load } from '@sveltejs/kit';
|
||||||
|
export const load: Load = async ({ fetch, params, stuff }) => {
|
||||||
|
let endpoint = `/applications/${params.id}/storage.json`;
|
||||||
|
const res = await fetch(endpoint);
|
||||||
|
if (res.ok) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
application: stuff.application,
|
||||||
|
...(await res.json())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: res.status,
|
||||||
|
error: new Error(`Could not load ${endpoint}`)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let application;
|
||||||
|
|
||||||
|
export let persistentStorages;
|
||||||
|
import { getDomain } from '$lib/components/common';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import Storage from './_Storage.svelte';
|
||||||
|
import { get } from '$lib/api';
|
||||||
|
import Explainer from '$lib/components/Explainer.svelte';
|
||||||
|
|
||||||
|
const { id } = $page.params;
|
||||||
|
async function refreshStorage() {
|
||||||
|
const data = await get(`/applications/${id}/storage.json`);
|
||||||
|
persistentStorages = [...data.persistentStorages];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex space-x-1 p-6 font-bold">
|
||||||
|
<div class="mr-4 text-2xl tracking-tight">
|
||||||
|
Persistent storage for <a href={application.fqdn} target="_blank"
|
||||||
|
>{getDomain(application.fqdn)}</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
|
||||||
|
<div class="flex justify-center py-4 text-center">
|
||||||
|
<Explainer
|
||||||
|
customClass="w-full"
|
||||||
|
text={'You can specify any folder that you want to be persistent across deployments. <br>This is useful for storing data such as a database (SQLite) or a cache.'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<table class="mx-auto border-separate text-left">
|
||||||
|
<thead>
|
||||||
|
<tr class="h-12">
|
||||||
|
<th scope="col">Path</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each persistentStorages as storage}
|
||||||
|
{#key storage.id}
|
||||||
|
<tr>
|
||||||
|
<Storage on:refresh={refreshStorage} {storage} />
|
||||||
|
</tr>
|
||||||
|
{/key}
|
||||||
|
{/each}
|
||||||
|
<tr>
|
||||||
|
<Storage on:refresh={refreshStorage} isNew />
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user