commit
030cb124e5
@ -56,6 +56,7 @@ These are the predefined build packs, but with the Docker build pack, you can ho
|
|||||||
- Gatsby
|
- Gatsby
|
||||||
- Svelte
|
- Svelte
|
||||||
- PHP
|
- PHP
|
||||||
|
- Laravel
|
||||||
- Rust
|
- Rust
|
||||||
- Docker
|
- Docker
|
||||||
|
|
||||||
@ -85,6 +86,8 @@ You can host cool open-source services as well:
|
|||||||
- [Uptime Kuma](https://github.com/louislam/uptime-kuma)
|
- [Uptime Kuma](https://github.com/louislam/uptime-kuma)
|
||||||
- [MeiliSearch](https://github.com/meilisearch/meilisearch)
|
- [MeiliSearch](https://github.com/meilisearch/meilisearch)
|
||||||
- [Umami](https://github.com/mikecao/umami)
|
- [Umami](https://github.com/mikecao/umami)
|
||||||
|
- [Fider](https://fider.io)
|
||||||
|
- [Hasura](https://hasura.io)
|
||||||
|
|
||||||
## Migration from v1
|
## Migration from v1
|
||||||
|
|
||||||
|
@ -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.6.0",
|
"version": "2.6.1",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev --host 0.0.0.0",
|
"dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev --host 0.0.0.0",
|
||||||
|
@ -290,3 +290,28 @@ export async function generateSSLCerts(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function renewSSLCerts(): Promise<void> {
|
||||||
|
const host = 'unix:///var/run/docker.sock';
|
||||||
|
await asyncExecShell(`docker pull alpine:latest`);
|
||||||
|
const certbotImage =
|
||||||
|
process.arch === 'x64' ? 'certbot/certbot' : 'certbot/certbot:arm64v8-latest';
|
||||||
|
|
||||||
|
const { stdout: certificates } = await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "ls -1 /etc/letsencrypt/live/ | grep -v README"`
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const certificate of certificates.trim().split('\n')) {
|
||||||
|
try {
|
||||||
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker run --rm --name certbot-renewal -p 9080:9080 -v "coolify-letsencrypt:/etc/letsencrypt" ${certbotImage} --cert-name ${certificate} --logs-dir /etc/letsencrypt/logs renew --standalone --preferred-challenges http --http-01-address 0.0.0.0 --http-01-port 9080`
|
||||||
|
);
|
||||||
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "test -d /etc/letsencrypt/live/${certificate}/ && cat /etc/letsencrypt/live/${certificate}/fullchain.pem /etc/letsencrypt/live/${certificate}/privkey.pem > /app/ssl/${certificate}.pem"`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await reloadHaproxy('unix:///var/run/docker.sock');
|
||||||
|
}
|
||||||
|
@ -116,7 +116,7 @@ const cron = async (): Promise<void> => {
|
|||||||
await queue.proxyTcpHttp.add('proxyTcpHttp', {}, { repeat: { every: 10000 } });
|
await queue.proxyTcpHttp.add('proxyTcpHttp', {}, { repeat: { every: 10000 } });
|
||||||
await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } });
|
await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } });
|
||||||
if (!dev) await queue.cleanup.add('cleanup', {}, { repeat: { every: 300000 } });
|
if (!dev) await queue.cleanup.add('cleanup', {}, { repeat: { every: 300000 } });
|
||||||
await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } });
|
if (!dev) await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } });
|
||||||
await queue.autoUpdater.add('autoUpdater', {}, { repeat: { every: 60000 } });
|
await queue.autoUpdater.add('autoUpdater', {}, { repeat: { every: 60000 } });
|
||||||
};
|
};
|
||||||
cron().catch((error) => {
|
cron().catch((error) => {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { asyncExecShell } from '$lib/common';
|
import { renewSSLCerts } from '$lib/letsencrypt';
|
||||||
import { reloadHaproxy } from '$lib/haproxy';
|
|
||||||
|
|
||||||
export default async function (): Promise<void> {
|
export default async function (): Promise<void> {
|
||||||
await asyncExecShell(
|
try {
|
||||||
`docker run --rm --name certbot-renewal -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs renew`
|
return await renewSSLCerts();
|
||||||
);
|
} catch (error) {
|
||||||
await reloadHaproxy('unix:///var/run/docker.sock');
|
console.log(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,14 @@
|
|||||||
loading.save = false;
|
loading.save = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function renewCerts() {
|
||||||
|
try {
|
||||||
|
toast.push('Renewing certificates...');
|
||||||
|
return await post(`/settings/renew.json`, {});
|
||||||
|
} 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">
|
||||||
@ -219,6 +227,19 @@
|
|||||||
on:click={() => changeSettings('isAutoUpdateEnabled')}
|
on:click={() => changeSettings('isAutoUpdateEnabled')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="pt-2 text-base font-bold text-stone-100">
|
||||||
|
Renew SSL Certificates manually
|
||||||
|
</div>
|
||||||
|
<Explainer text="It will check and renew certificates manually" />
|
||||||
|
</div>
|
||||||
|
<div class="mx-auto ">
|
||||||
|
<button class="w-32 bg-coollabs hover:bg-coollabs-100" on:click={renewCerts}
|
||||||
|
>SSL renew manually</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
26
src/routes/settings/renew.json.ts
Normal file
26
src/routes/settings/renew.json.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { getUserDetails } from '$lib/common';
|
||||||
|
import { ErrorHandler } from '$lib/database';
|
||||||
|
import { renewSSLCerts } from '$lib/letsencrypt';
|
||||||
|
import { t } from '$lib/translations';
|
||||||
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
export const post: RequestHandler = async (event) => {
|
||||||
|
const { teamId, status, body } = await getUserDetails(event);
|
||||||
|
if (teamId !== '0')
|
||||||
|
return {
|
||||||
|
status: 401,
|
||||||
|
body: {
|
||||||
|
message: t.get('setting.permission_denied')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
|
try {
|
||||||
|
renewSSLCerts();
|
||||||
|
return {
|
||||||
|
status: 201
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return ErrorHandler(error);
|
||||||
|
}
|
||||||
|
};
|
@ -2,6 +2,7 @@ import { dev } from '$app/env';
|
|||||||
import { asyncExecShell, version } from '$lib/common';
|
import { asyncExecShell, version } from '$lib/common';
|
||||||
import { asyncSleep } from '$lib/components/common';
|
import { asyncSleep } from '$lib/components/common';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
|
import * as db from '$lib/database';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import compare from 'compare-versions';
|
import compare from 'compare-versions';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
@ -36,8 +37,12 @@ export const post: RequestHandler = async (event) => {
|
|||||||
if (type === 'update') {
|
if (type === 'update') {
|
||||||
try {
|
try {
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
const { isAutoUpdateEnabled } = await db.prisma.setting.findFirst();
|
||||||
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
|
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
|
||||||
await asyncExecShell(`env | grep COOLIFY > .env`);
|
await asyncExecShell(`env | grep COOLIFY > .env`);
|
||||||
|
await asyncExecShell(
|
||||||
|
`sed -i '/COOLIFY_AUTO_UPDATE=/c\COOLIFY_AUTO_UPDATE=${isAutoUpdateEnabled}' .env`
|
||||||
|
);
|
||||||
await asyncExecShell(
|
await asyncExecShell(
|
||||||
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify coolify-redis && docker rm coolify coolify-redis && docker compose up -d --force-recreate"`
|
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify coolify-redis && docker rm coolify coolify-redis && docker compose up -d --force-recreate"`
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user