Compare commits

...

20 Commits

Author SHA1 Message Date
Andras Bacsai
19553ce5c8 Merge pull request #874 from coollabsio/next
v3.12.17
2023-01-20 21:14:06 +01:00
Andras Bacsai
18ed2527e8 fix 2023-01-20 20:51:37 +01:00
Andras Bacsai
b0652bc884 Merge pull request #872 from coollabsio/next
Next
2023-01-20 14:07:46 +01:00
Andras Bacsai
15c9ad23fe fix: stucked containers 2023-01-20 14:06:55 +01:00
Andras Bacsai
578bb12562 test new release gh action 2023-01-20 14:05:07 +01:00
Andras Bacsai
f82cfda07f version++ 2023-01-20 13:55:05 +01:00
Andras Bacsai
9e52b2788d Pocketbase GH release updated 2023-01-20 13:49:39 +01:00
Andras Bacsai
2e56a113d9 Test GH release thing 2023-01-20 13:48:57 +01:00
Andras Bacsai
4722d777e6 Merge pull request #871 from coollabsio/next
v3.12.15
2023-01-20 13:22:11 +01:00
Andras Bacsai
2141d54ae0 fix 2023-01-20 13:15:52 +01:00
Andras Bacsai
e346225136 fix 2023-01-20 13:10:40 +01:00
Andras Bacsai
012d4dae56 testing 2023-01-20 11:15:38 +01:00
Andras Bacsai
b4d9fe70af fix 2023-01-20 10:43:21 +01:00
Andras Bacsai
85e83b5441 Test new gh actions 2023-01-20 10:42:13 +01:00
Andras Bacsai
6b2a453b8f fix: deletion + cleanupStuckedContainers 2023-01-20 10:10:36 +01:00
Andras Bacsai
27021538d8 fix: cleanup stucked containers 2023-01-20 09:40:29 +01:00
Andras Bacsai
8b57a2b055 fix: cleanup function 2023-01-20 09:26:48 +01:00
Andras Bacsai
75dd894685 Merge pull request #867 from coollabsio/next
v3.12.14
2023-01-19 14:36:05 +01:00
Andras Bacsai
9101ef8774 version++ 2023-01-19 14:33:33 +01:00
Andras Bacsai
5932540630 fix: www redirect 2023-01-19 14:33:20 +01:00
20 changed files with 184 additions and 143 deletions

View File

@@ -5,7 +5,9 @@ on:
paths:
- "others/pocketbase/*"
- ".github/workflows/pocketbase-release.yml"
branches:
- next
- main
jobs:
arm64:
runs-on: [self-hosted, arm64]

View File

@@ -54,7 +54,7 @@ jobs:
context: .
platforms: linux/amd64
push: true
tags: coollabsio/coolify:${{steps.package-version.outputs.current-version}}-amd64
tags: coollabsio/coolify:${{steps.package-version.outputs.current-version}}
cache-from: type=registry,ref=coollabsio/coolify:buildcache-amd64
cache-to: type=registry,ref=coollabsio/coolify:buildcache-amd64,mode=max
aarch64:
@@ -103,10 +103,10 @@ jobs:
id: package-version
- name: Create & publish manifest
run: |
docker manifest create coollabsio/coolify:${{steps.package-version.outputs.current-version}} --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-amd64 --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-aarch64
docker manifest create coollabsio/coolify:latest --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-amd64 --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-aarch64
docker manifest push coollabsio/coolify:${{steps.package-version.outputs.current-version}}
docker manifest push coollabsio/coolify:latest
docker buildx imagetools create --append coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 --append coollabsio/coolify:${{steps.package-version.outputs.current-version}}-aarch64 --tag coollabsio/coolify:${{steps.package-version.outputs.current-version}}
docker tag coollabsio/coolify:${{steps.package-version.outputs.current-version}} coollabsio/coolify:latest
docker push coollabsio/coolify:latest
docker buildx imagetools create --append coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 --append coollabsio/coolify:${{steps.package-version.outputs.current-version}}-aarch64 --tag coollabsio/coolify:latest
- uses: sarisia/actions-status-discord@v1
if: always()
with:

View File

@@ -65,7 +65,7 @@ jobs:
context: .
platforms: linux/amd64
push: true
tags: coollabsio/coolify:next-amd64
tags: coollabsio/coolify:next
cache-from: type=registry,ref=coollabsio/coolify:buildcache-next-amd64
cache-to: type=registry,ref=coollabsio/coolify:buildcache-next-amd64,mode=max
merge-manifest:
@@ -85,8 +85,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create & publish manifest
run: |
docker manifest create coollabsio/coolify:next --amend coollabsio/coolify:next-amd64 --amend coollabsio/coolify:next-arm64
docker manifest push coollabsio/coolify:next
docker buildx imagetools create --append coollabsio/coolify:next-arm64 --tag coollabsio/coolify:next
- uses: sarisia/actions-status-discord@v1
if: always()
with:

View File

@@ -171,6 +171,11 @@ const host = '0.0.0.0';
await cleanupStorage();
}, 60000 * 15);
// Cleanup stucked containers (not defined in Coolify, but still running and managed by Coolify)
// setInterval(async () => {
// await cleanupStuckedContainers();
// }, 60000 * 5);
// checkProxies, checkFluentBit & refresh templates
setInterval(async () => {
await checkProxies();
@@ -197,7 +202,13 @@ const host = '0.0.0.0';
await copySSLCertificates();
}, 10000);
await Promise.all([getTagsTemplates(), getArch(), getIPAddress(), configureRemoteDockers()]);
await Promise.all([
getTagsTemplates(),
getArch(),
getIPAddress(),
configureRemoteDockers()
// cleanupStuckedContainers()
]);
} catch (error) {
console.error(error);
process.exit(1);
@@ -311,6 +322,42 @@ async function getArch() {
} catch (error) {}
}
async function cleanupStuckedContainers() {
try {
const destinationDockers = await prisma.destinationDocker.findMany();
let enginesDone = new Set();
for (const destination of destinationDockers) {
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress))
return;
if (destination.engine) {
enginesDone.add(destination.engine);
}
if (destination.remoteIpAddress) {
if (!destination.remoteVerified) continue;
enginesDone.add(destination.remoteIpAddress);
}
const { stdout: containers } = await executeCommand({
dockerId: destination.id,
command: `docker container ps -a --filter "label=coolify.managed=true" --format '{{ .Names}}'`
});
if (containers) {
const containersArray = containers.trim().split('\n');
if (containersArray.length > 0) {
for (const container of containersArray) {
const application = await prisma.application.findFirst({ where: { id: container } });
const service = await prisma.service.findFirst({ where: { id: container } });
const database = await prisma.database.findFirst({ where: { id: container } });
if (!application && !service && !database) {
await executeCommand({ command: `docker container rm -f ${container}` });
}
}
}
}
}
} catch (error) {
console.log(error);
}
}
async function configureRemoteDockers() {
try {
const remoteDocker = await prisma.destinationDocker.findMany({
@@ -543,9 +590,13 @@ async function cleanupStorage() {
let enginesDone = new Set();
for (const destination of destinationDockers) {
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress)) return;
if (destination.engine) enginesDone.add(destination.engine);
if (destination.remoteIpAddress) enginesDone.add(destination.remoteIpAddress);
let force = false;
if (destination.engine) {
enginesDone.add(destination.engine);
}
if (destination.remoteIpAddress) {
if (!destination.remoteVerified) continue;
enginesDone.add(destination.remoteIpAddress);
}
let lowDiskSpace = false;
try {
let stdout = null;
@@ -591,6 +642,8 @@ async function cleanupStorage() {
}
}
} catch (error) {}
await cleanupDockerStorage(destination.id, lowDiskSpace, force);
if (lowDiskSpace) {
await cleanupDockerStorage(destination.id);
}
}
}

View File

@@ -66,10 +66,12 @@ export default async function (data) {
}
}
}
if (build.length > 0 || buildArgs.length > 0 ) {
value['build'] = {
...build,
args: finalArgs
};
}
value['labels'] = labels;
// TODO: If we support separated volume for each service, we need to add it here
@@ -116,7 +118,6 @@ export default async function (data) {
dockerComposeYaml['networks'] = Object.assign({ ...networks }, { [network]: { external: true } });
await fs.writeFile(fileYaml, yaml.dump(dockerComposeYaml));
console.log(yaml.dump(dockerComposeYaml));
await executeCommand({
debug,
buildId,

View File

@@ -19,7 +19,7 @@ import { saveBuildLog, saveDockerRegistryCredentials } from './buildPacks/common
import { scheduler } from './scheduler';
import type { ExecaChildProcess } from 'execa';
export const version = '3.12.13';
export const version = '3.12.17';
export const isDev = process.env.NODE_ENV === 'development';
export const sentryDSN =
'https://409f09bcb7af47928d3e0f46b78987f3@o1082494.ingest.sentry.io/4504236622217216';
@@ -1714,78 +1714,24 @@ export function convertTolOldVolumeNames(type) {
}
}
export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) {
// Cleanup old coolify images
export async function cleanupDockerStorage(dockerId) {
// Cleanup images that are not used by any container
try {
let { stdout: images } = await executeCommand({
dockerId,
command: `docker images coollabsio/coolify --filter before="coollabsio/coolify:${version}" -q | xargs -r`,
shell: true
});
images = images.trim();
if (images) {
await executeCommand({
dockerId,
command: `docker rmi -f ${images}" -q | xargs -r`,
shell: true
});
}
await executeCommand({ dockerId, command: `docker image prune -af` });
} catch (error) {}
if (lowDiskSpace || force) {
// Cleanup images that are not used
try {
await executeCommand({ dockerId, command: `docker image prune -f` });
} catch (error) {}
const { numberOfDockerImagesKeptLocally } = await prisma.setting.findUnique({
where: { id: '0' }
});
const { stdout: images } = await executeCommand({
// Prune coolify managed containers
try {
await executeCommand({
dockerId,
command: `docker images|grep -v "<none>"|grep -v REPOSITORY|awk '{print $1, $2}'`,
shell: true
command: `docker container prune -f --filter "label=coolify.managed=true"`
});
const imagesArray = images.trim().replaceAll(' ', ':').split('\n');
const imagesSet = new Set(imagesArray.map((image) => image.split(':')[0]));
let deleteImage = [];
for (const image of imagesSet) {
let keepImage = [];
for (const image2 of imagesArray) {
if (image2.startsWith(image)) {
if (force) {
deleteImage.push(image2);
continue;
}
if (keepImage.length >= numberOfDockerImagesKeptLocally) {
deleteImage.push(image2);
} else {
keepImage.push(image2);
}
}
}
}
for (const image of deleteImage) {
try {
await executeCommand({ dockerId, command: `docker image rm -f ${image}` });
} catch (error) {
console.log(error);
}
}
} catch (error) {}
// Prune coolify managed containers
try {
await executeCommand({
dockerId,
command: `docker container prune -f --filter "label=coolify.managed=true"`
});
} catch (error) {}
// Cleanup build caches
try {
await executeCommand({ dockerId, command: `docker builder prune -a -f` });
} catch (error) {}
}
// Cleanup build caches
try {
await executeCommand({ dockerId, command: `docker builder prune -af` });
} catch (error) {}
}
export function persistentVolumes(id, persistentStorage, config) {

View File

@@ -732,14 +732,15 @@ export async function deleteApplication(
) {
try {
const { id } = request.params;
const { force } = request.body;
const { teamId } = request.user;
const application = await prisma.application.findUnique({
where: { id },
include: { destinationDocker: true }
include: { destinationDocker: true, teams: true }
});
if (!force && application?.destinationDockerId && application.destinationDocker?.network) {
if (!application.teams.find((team) => team.id === teamId) || teamId !== '0') {
throw { status: 403, message: 'You are not allowed to delete this application.' };
}
if (application?.destinationDocker?.id && application.destinationDocker?.network) {
const { stdout: containers } = await executeCommand({
dockerId: application.destinationDocker.id,
command: `docker ps -a --filter network=${application.destinationDocker.network} --filter name=${id} --format '{{json .}}'`

View File

@@ -427,19 +427,15 @@ export async function deleteDatabase(request: FastifyRequest<DeleteDatabase>) {
try {
const teamId = request.user.teamId;
const { id } = request.params;
const { force } = request.body;
const database = await prisma.database.findFirst({
where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } },
include: { destinationDocker: true, settings: true }
});
if (!force) {
if (database.dbUserPassword) database.dbUserPassword = decrypt(database.dbUserPassword);
if (database.rootUserPassword) database.rootUserPassword = decrypt(database.rootUserPassword);
if (database.destinationDockerId) {
const everStarted = await stopDatabaseContainer(database);
if (everStarted)
await stopTcpHttpProxy(id, database.destinationDocker, database.publicPort);
}
if (database.dbUserPassword) database.dbUserPassword = decrypt(database.dbUserPassword);
if (database.rootUserPassword) database.rootUserPassword = decrypt(database.rootUserPassword);
if (database.destinationDockerId) {
const everStarted = await stopDatabaseContainer(database);
if (everStarted) await stopTcpHttpProxy(id, database.destinationDocker, database.publicPort);
}
await prisma.databaseSettings.deleteMany({ where: { databaseId: id } });
await prisma.databaseSecret.deleteMany({ where: { databaseId: id } });

View File

@@ -4,7 +4,7 @@ export interface SaveDatabaseType extends OnlyId {
Body: { type: string }
}
export interface DeleteDatabase extends OnlyId {
Body: { force: string }
Body: { }
}
export interface SaveVersion extends OnlyId {
Body: {

View File

@@ -59,7 +59,7 @@ export async function cleanupManually(request: FastifyRequest) {
const destination = await prisma.destinationDocker.findUnique({
where: { id: serverId }
});
await cleanupDockerStorage(destination.id, true, true);
await cleanupDockerStorage(destination.id);
return {};
} catch ({ status, message }) {
return errorHandler({ status, message });

View File

@@ -617,6 +617,29 @@ export async function getServiceLogs(request: FastifyRequest<GetServiceLogs>) {
export async function deleteService(request: FastifyRequest<OnlyId>) {
try {
const { id } = request.params;
const teamId = request.user.teamId;
const { destinationDockerId } = await getServiceFromDB({ id, teamId });
if (destinationDockerId) {
const { stdout: containers } = await executeCommand({
dockerId: destinationDockerId,
command: `docker ps -a --filter 'label=com.docker.compose.project=${id}' --format {{.ID}}`
});
if (containers) {
const containerArray = containers.split('\n');
if (containerArray.length > 0) {
for (const container of containerArray) {
await executeCommand({
dockerId: destinationDockerId,
command: `docker stop -t 0 ${container}`
});
await executeCommand({
dockerId: destinationDockerId,
command: `docker rm --force ${container}`
});
}
}
}
}
await removeService({ id });
return {};
} catch ({ status, message }) {

View File

@@ -50,6 +50,9 @@ function generateRouters(
isHttp2 = false
) {
let rule = `Host(\`${nakedDomain}\`)${pathPrefix ? ` && PathPrefix(\`${pathPrefix}\`)` : ''}`;
let ruleWWW = `Host(\`www.${nakedDomain}\`)${
pathPrefix ? ` && PathPrefix(\`${pathPrefix}\`)` : ''
}`;
let http: any = {
entrypoints: ['web'],
rule,
@@ -69,14 +72,14 @@ function generateRouters(
};
let httpWWW: any = {
entrypoints: ['web'],
rule,
rule: ruleWWW,
service: `${serviceId}`,
priority: 2,
middlewares: []
};
let httpsWWW: any = {
entrypoints: ['websecure'],
rule,
rule: ruleWWW,
service: `${serviceId}`,
priority: 2,
tls: {

View File

@@ -827,6 +827,29 @@ export const servicesRouter = router({
.mutation(async ({ input }) => {
// todo: check if user is allowed to delete service
const { id } = input;
const teamId = ctx.user?.teamId;
const { destinationDockerId } = await getServiceFromDB({ id, teamId });
if (destinationDockerId) {
const { stdout: containers } = await executeCommand({
dockerId: destinationDockerId,
command: `docker ps -a --filter 'label=com.docker.compose.project=${id}' --format {{.ID}}`
});
if (containers) {
const containerArray = containers.split('\n');
if (containerArray.length > 0) {
for (const container of containerArray) {
await executeCommand({
dockerId: destinationDockerId,
command: `docker stop -t 0 ${container}`
});
await executeCommand({
dockerId: destinationDockerId,
command: `docker rm --force ${container}`
});
}
}
}
}
await prisma.serviceSecret.deleteMany({ where: { serviceId: id } });
await prisma.serviceSetting.deleteMany({ where: { serviceId: id } });
await prisma.servicePersistentStorage.deleteMany({ where: { serviceId: id } });

View File

@@ -89,7 +89,7 @@
const sure = confirm($t('application.confirm_to_delete', { name }));
if (sure) {
try {
await del(`/applications/${id}`, { id, force });
await del(`/applications/${id}`, {});
return await goto('/');
} catch (error) {
if (error.message.startsWith(`Command failed: SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid`)) {

View File

@@ -34,7 +34,7 @@
if (sure) {
$status.application.initialLoading = true;
try {
await del(`/applications/${id}`, { id, force });
await del(`/applications/${id}`,{});
return await goto('/')
} catch (error) {
if (error.message.startsWith(`Command failed: SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid`)) {

View File

@@ -75,7 +75,7 @@
if (sure) {
$status.database.initialLoading = true;
try {
await del(`/databases/${database.id}`, { id: database.id, force });
await del(`/databases/${database.id}`, {});
return await window.location.assign('/');
} catch (error) {
return errorNotification(error);

View File

@@ -437,7 +437,7 @@
try {
const sure = confirm('Are you sure? This will delete this application!');
if (sure) {
await del(`/applications/${id}`, { force: true });
await del(`/applications/${id}`, {});
return window.location.reload();
}
} catch (error) {
@@ -459,7 +459,7 @@
try {
const sure = confirm('Are you sure? This will delete this database!');
if (sure) {
await del(`/databases/${id}`, { force: true });
await del(`/databases/${id}`, { });
return window.location.reload();
}
} catch (error) {
@@ -784,11 +784,11 @@
</a>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-green-500"
on:click|stopPropagation|preventDefault={() =>
deleteApplication(application.id)}><DeleteIcon /></button
>
<button
class="icons hover:bg-green-500"
on:click|stopPropagation|preventDefault={() =>
deleteApplication(application.id)}><DeleteIcon /></button
>
{/if}
</div>
</div>
@@ -899,11 +899,11 @@
</a>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-green-500"
on:click|stopPropagation|preventDefault={() =>
deleteApplication(application.id)}><DeleteIcon /></button
>
<button
class="icons hover:bg-green-500"
on:click|stopPropagation|preventDefault={() =>
deleteApplication(application.id)}><DeleteIcon /></button
>
{/if}
</div>
</div>
@@ -996,11 +996,11 @@
</a>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-pink-500"
on:click|stopPropagation|preventDefault={() => deleteService(service.id)}
><DeleteIcon /></button
>
<button
class="icons hover:bg-pink-500"
on:click|stopPropagation|preventDefault={() => deleteService(service.id)}
><DeleteIcon /></button
>
{/if}
</div>
</div>
@@ -1084,11 +1084,11 @@
</a>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-pink-500"
on:click|stopPropagation|preventDefault={() => deleteService(service.id)}
><DeleteIcon /></button
>
<button
class="icons hover:bg-pink-500"
on:click|stopPropagation|preventDefault={() => deleteService(service.id)}
><DeleteIcon /></button
>
{/if}
</div>
</div>
@@ -1182,11 +1182,11 @@
</div>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-databases-100"
on:click|stopPropagation|preventDefault={() => deleteDatabase(database.id)}
><DeleteIcon /></button
>
<button
class="icons hover:bg-databases-100"
on:click|stopPropagation|preventDefault={() =>
deleteDatabase(database.id)}><DeleteIcon /></button
>
{/if}
</div>
</div>
@@ -1270,11 +1270,11 @@
</div>
{/if}
{#if $appSession.isAdmin}
<button
class="icons hover:bg-databases"
on:click|stopPropagation|preventDefault={() => deleteDatabase(database.id)}
><DeleteIcon /></button
>
<button
class="icons hover:bg-databases"
on:click|stopPropagation|preventDefault={() => deleteDatabase(database.id)}
><DeleteIcon /></button
>
{/if}
</div>
</div>

View File

@@ -85,9 +85,7 @@
if (sure) {
$status.service.initialLoading = true;
try {
if (service.type && $status.service.isRunning)
await post(`/services/${service.id}/stop`, {});
await del(`/services/${service.id}`, { id: service.id });
await del(`/services/${service.id}`, {});
return await goto('/');
} catch (error) {
return errorNotification(error);

View File

@@ -28,16 +28,12 @@
import { goto } from '$app/navigation';
const { id } = $page.params;
let forceDelete = false;
async function deleteService() {
const sure = confirm($t('application.confirm_to_delete', { name: service.name }));
if (sure) {
$status.service.initialLoading = true;
try {
if (service.type && $status.service.overallStatus !== 'stopped') {
await post(`/services/${service.id}/stop`, {});
}
await del(`/services/${service.id}`, { id: service.id });
await del(`/services/${service.id}`, {});
return await goto('/');
} catch (error) {
return errorNotification(error);

View File

@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.12.13",
"version": "3.12.17",
"license": "Apache-2.0",
"repository": "github:coollabsio/coolify",
"scripts": {