Compare commits

...

5 Commits

Author SHA1 Message Date
Andras Bacsai
e622294b87 feat: New update process (#115) 2022-02-11 11:46:47 +01:00
Andras Bacsai
cf9d32b556 Merge pull request #114 from coollabsio/next
fix: Docker Engine bugs
2022-02-11 09:22:28 +01:00
Andras Bacsai
e2d6b5bf64 fix: version 2022-02-11 09:13:51 +01:00
Andras Bacsai
dec58fd6d1 feat: Use tags in update 2022-02-11 09:00:45 +01:00
Andras Bacsai
dbb2241213 fix: Docker Engine bug related to live-restore and IPs 2022-02-11 08:42:47 +01:00
6 changed files with 67 additions and 52 deletions

View File

@@ -2,7 +2,7 @@ version: '3.8'
services:
coolify:
image: coollabsio/coolify:latest
image: coollabsio/coolify:${TAG:-latest}
restart: always
container_name: coolify
ports:

View File

@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "2.0.3",
"version": "2.0.4",
"license": "AGPL-3.0",
"scripts": {
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
@@ -16,6 +16,7 @@
"db:generate": "prisma generate",
"db:push": "prisma db push && prisma generate",
"db:seed": "prisma db seed",
"stagrelease": "cross-var docker build -t coollabsio/coolify:$npm_package_version . && docker push coollabsio/coolify:$npm_package_version",
"prerelease": "cross-var docker build -t coollabsio/coolify:$npm_package_version -t coollabsio/coolify:latest .",
"release:coolify": "cross-var yarn prerelease && docker push coollabsio/coolify:$npm_package_version && docker image push coollabsio/coolify:$npm_package_version && docker push coollabsio/coolify:latest",
"release:haproxy": "docker build -f haproxy.Dockerfile -t coollabsio/coolify-haproxy-alpine:1.0.0 -t coollabsio/coolify-haproxy-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-alpine",

View File

@@ -481,8 +481,12 @@ export async function startTcpProxy(destinationDocker, id, publicPort, privatePo
try {
if (foundDB && !found) {
const { stdout: Config } = await asyncExecShell(
`DOCKER_HOST="${host}" docker network inspect bridge --format '{{json .IPAM.Config }}'`
);
const ip = JSON.parse(Config)[0].Gateway;
return await asyncExecShell(
`DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} -d coollabsio/${defaultProxyImageTcp}`
`DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} -d coollabsio/${defaultProxyImageTcp}`
);
}
} catch (error) {
@@ -499,8 +503,12 @@ export async function startHttpProxy(destinationDocker, id, publicPort, privateP
try {
if (foundDB && !found) {
const { stdout: Config } = await asyncExecShell(
`DOCKER_HOST="${host}" docker network inspect bridge --format '{{json .IPAM.Config }}'`
);
const ip = JSON.parse(Config)[0].Gateway;
return await asyncExecShell(
`DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} -d coollabsio/${defaultProxyImageHttp}`
`DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} -d coollabsio/${defaultProxyImageHttp}`
);
}
} catch (error) {
@@ -512,8 +520,12 @@ export async function startCoolifyProxy(engine) {
const found = await checkContainer(engine, 'coolify-haproxy');
const { proxyPassword, proxyUser } = await db.listSettings();
if (!found) {
const { stdout: Config } = await asyncExecShell(
`DOCKER_HOST="${host}" docker network inspect bridge --format '{{json .IPAM.Config }}'`
);
const ip = JSON.parse(Config)[0].Gateway;
await asyncExecShell(
`DOCKER_HOST="${host}" docker run -e HAPROXY_USERNAME=${proxyUser} -e HAPROXY_PASSWORD=${proxyPassword} --restart always --add-host 'host.docker.internal:host-gateway' -v coolify-ssl-certs:/usr/local/etc/haproxy/ssl --network coolify-infra -p "80:80" -p "443:443" -p "8404:8404" -p "5555:5555" -p "5000:5000" --name coolify-haproxy -d coollabsio/${defaultProxyImage}`
`DOCKER_HOST="${host}" docker run -e HAPROXY_USERNAME=${proxyUser} -e HAPROXY_PASSWORD=${proxyPassword} --restart always --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' -v coolify-ssl-certs:/usr/local/etc/haproxy/ssl --network coolify-infra -p "80:80" -p "443:443" -p "8404:8404" -p "5555:5555" -p "5000:5000" --name coolify-haproxy -d coollabsio/${defaultProxyImage}`
);
}
await configureNetworkCoolifyProxy(engine);

View File

@@ -8,13 +8,13 @@ export default async function () {
for (const destinationDocker of destinationDockers) {
const host = getEngine(destinationDocker.engine);
try {
await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
// await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
} catch (error) {
//
console.log(error);
}
try {
await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`);
// await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`);
} catch (error) {
//
console.log(error);

View File

@@ -39,8 +39,7 @@
import { errorNotification } from '$lib/form';
import { asyncSleep } from '$lib/components/common';
import { del, get, post } from '$lib/api';
import { dev } from '$app/env';
import Loading from '$lib/components/Loading.svelte';
import { browser } from '$app/env';
let isUpdateAvailable = false;
let updateStatus = {
@@ -48,9 +47,10 @@
checking: false,
success: null
};
let latestVersion = 'latest';
onMount(async () => {
if ($session.uid) {
const overrideVersion = browser && window.localStorage.getItem('latestVersion');
try {
await get(`/login.json`);
} catch ({ error }) {
@@ -62,10 +62,11 @@
updateStatus.checking = true;
try {
const data = await get(`/update.json`);
if (data?.isUpdateAvailable) {
await post(`/update.json`, { type: 'pull' });
if (overrideVersion || data?.isUpdateAvailable) {
latestVersion = overrideVersion || data.latestVersion;
isUpdateAvailable = overrideVersion ? true : data?.isUpdateAvailable;
await post(`/update.json`, { type: 'pull', latestVersion });
}
isUpdateAvailable = data?.isUpdateAvailable;
} catch (error) {
} finally {
updateStatus.checking = false;
@@ -95,54 +96,53 @@
async function update() {
updateStatus.loading = true;
if (!dev) {
try {
await post(`/update.json`, { type: 'update' });
toast.push('Update completed. Waiting for the new version to start...');
let reachable = false;
let tries = 0;
do {
await asyncSleep(4000);
try {
await get(`/undead.json`);
reachable = true;
} catch (error) {
reachable = false;
}
if (reachable) break;
tries++;
} while (!reachable || tries < 120);
toast.push('New version reachable. Reloading...');
updateStatus.loading = false;
updateStatus.success = true;
await asyncSleep(3000);
return window.location.reload();
} catch ({ error }) {
return errorNotification(error);
} finally {
updateStatus.success = false;
updateStatus.loading = false;
}
} else {
// if (!dev) {
try {
await post(`/update.json`, { type: 'update', latestVersion });
toast.push('Update completed. Waiting for the new version to start...');
let reachable = false;
let tries = 0;
do {
await asyncSleep(1000);
await asyncSleep(4000);
try {
await get(`/undead.json`);
reachable = true;
} catch (error) {
console.log(error);
reachable = false;
}
console.log(reachable);
if (reachable) break;
tries++;
} while (!reachable || tries < 120);
toast.push('New version reachable. Reloading...');
await asyncSleep(2000);
window.location.reload();
updateStatus.loading = false;
updateStatus.success = true;
await asyncSleep(3000);
return window.location.reload();
} catch ({ error }) {
return errorNotification(error);
} finally {
updateStatus.success = false;
updateStatus.loading = false;
}
// } else {
// let reachable = false;
// let tries = 0;
// do {
// await asyncSleep(1000);
// try {
// await get(`/undead.json`);
// reachable = true;
// } catch (error) {
// console.log(error);
// reachable = false;
// }
// if (reachable) break;
// tries++;
// } while (!reachable || tries < 120);
// toast.push('New version reachable. Reloading...');
// await asyncSleep(2000);
// window.location.reload();
// }
}
</script>

View File

@@ -12,7 +12,7 @@ export const get: RequestHandler = async () => {
const versions = await got
.get(`https://get.coollabs.io/versions.json?appId=${process.env['COOLIFY_APP_ID']}`)
.json();
const latestVersion = versions['coolify'].main.version;
const latestVersion = dev ? '10.0.0' : versions['coolify'].main.version;
const isUpdateAvailable = compare(latestVersion, currentVersion);
return {
body: {
@@ -26,17 +26,17 @@ export const get: RequestHandler = async () => {
};
export const post: RequestHandler = async (event) => {
const { type } = await event.request.json();
const { type, latestVersion } = await event.request.json();
if (type === 'pull') {
try {
if (!dev) {
await asyncExecShell(`env | grep COOLIFY > .env`);
await asyncExecShell(`docker compose pull`);
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
return {
status: 200,
body: {}
};
} else {
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
await asyncSleep(2000);
return {
status: 200,
@@ -49,14 +49,16 @@ export const post: RequestHandler = async (event) => {
} else if (type === 'update') {
try {
if (!dev) {
await asyncExecShell(`env | grep COOLIFY > .env`);
await asyncExecShell(
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:latest /bin/sh -c "env | grep COOLIFY > .env && docker stop -t 0 coolify && docker stop -t 0 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"`
);
return {
status: 200,
body: {}
};
} else {
console.log(latestVersion);
await asyncSleep(2000);
return {
status: 200,