Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

v1.0.6 (#30)

Andras Bacsaibad84289c4cb
diff --git a/.dockerignore b/.dockerignore
index d61686b7e0..907d0f818a 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,3 +1,4 @@
node_modules
dist
-.routify
\ No newline at end of file
+.routify
+.pnpm-store
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index cb3de10263..7b5ba795e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,5 @@ dist-ssr
yarn-error.log
api/development/console.log
.pnpm-debug.log
-yarn.lock
\ No newline at end of file
+yarn.lock
+.pnpm-store
\ No newline at end of file
diff --git a/api/app.js b/api/app.js
index 9e094ae887..eac63297c9 100644
--- a/api/app.js
+++ b/api/app.js
@@ -12,6 +12,7 @@ module.exports = async function (fastify, opts) {
server.register(require('./routes/v1/application/deploy'), { prefix: '/application/deploy' })
server.register(require('./routes/v1/application/deploy/logs'), { prefix: '/application/deploy/logs' })
server.register(require('./routes/v1/databases'), { prefix: '/databases' })
+ server.register(require('./routes/v1/server'), { prefix: '/server' })
})
// Public routes
fastify.register(require('./routes/v1/verify'), { prefix: '/verify' })
diff --git a/api/buildPacks/custom/index.js b/api/buildPacks/custom/index.js
new file mode 100644
index 0000000000..79524da2ed
--- /dev/null
+++ b/api/buildPacks/custom/index.js
@@ -0,0 +1,19 @@
+const fs = require('fs').promises
+const { streamEvents, docker } = require('../../libs/docker')
+
+module.exports = async function (configuration) {
+ try {
+ const path = `${configuration.general.workdir}/${configuration.build.directory ? configuration.build.directory : ''}`
+ if (fs.stat(`${path}/Dockerfile`)) {
+ const stream = await docker.engine.buildImage(
+ { src: ['.'], context: path },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } else {
+ throw { error: 'No custom dockerfile found.', type: 'app' }
+ }
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
+}
diff --git a/api/packs/helpers.js b/api/buildPacks/helpers.js
similarity index 53%
rename from api/packs/helpers.js
rename to api/buildPacks/helpers.js
index b46ed64780..1d90af8573 100644
--- a/api/packs/helpers.js
+++ b/api/buildPacks/helpers.js
@@ -10,12 +10,16 @@ const buildImageNodeDocker = (configuration) => {
].join('\n')
}
async function buildImage (configuration) {
- await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, buildImageNodeDocker(configuration))
- const stream = await docker.engine.buildImage(
- { src: ['.'], context: configuration.general.workdir },
- { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
- )
- await streamEvents(stream, configuration)
+ try {
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, buildImageNodeDocker(configuration))
+ const stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
}
module.exports = {
diff --git a/api/packs/index.js b/api/buildPacks/index.js
similarity index 61%
rename from api/packs/index.js
rename to api/buildPacks/index.js
index 23fb82e347..a4a8876e20 100644
--- a/api/packs/index.js
+++ b/api/buildPacks/index.js
@@ -2,5 +2,6 @@ const static = require('./static')
const nodejs = require('./nodejs')
const php = require('./php')
const custom = require('./custom')
+const rust = require('./rust')
-module.exports = { static, nodejs, php, custom }
+module.exports = { static, nodejs, php, custom, rust }
diff --git a/api/packs/nodejs/index.js b/api/buildPacks/nodejs/index.js
similarity index 52%
rename from api/packs/nodejs/index.js
rename to api/buildPacks/nodejs/index.js
index 97a24e9710..7b199d3303 100644
--- a/api/packs/nodejs/index.js
+++ b/api/buildPacks/nodejs/index.js
@@ -1,7 +1,7 @@
const fs = require('fs').promises
const { buildImage } = require('../helpers')
const { streamEvents, docker } = require('../../libs/docker')
-
+// `HEALTHCHECK --timeout=10s --start-period=10s --interval=5s CMD curl -I -s -f http://localhost:${configuration.publish.port}${configuration.publish.path} || exit 1`,
const publishNodejsDocker = (configuration) => {
return [
'FROM node:lts',
@@ -16,11 +16,15 @@ const publishNodejsDocker = (configuration) => {
}
module.exports = async function (configuration) {
- if (configuration.build.command.build) await buildImage(configuration)
- await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishNodejsDocker(configuration))
- const stream = await docker.engine.buildImage(
- { src: ['.'], context: configuration.general.workdir },
- { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
- )
- await streamEvents(stream, configuration)
+ try {
+ if (configuration.build.command.build) await buildImage(configuration)
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishNodejsDocker(configuration))
+ const stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
}
diff --git a/api/buildPacks/php/index.js b/api/buildPacks/php/index.js
new file mode 100644
index 0000000000..b96700ee2e
--- /dev/null
+++ b/api/buildPacks/php/index.js
@@ -0,0 +1,26 @@
+const fs = require('fs').promises
+const { streamEvents, docker } = require('../../libs/docker')
+// 'HEALTHCHECK --timeout=10s --start-period=10s --interval=5s CMD curl -I -s -f http://localhost/ || exit 1',
+const publishPHPDocker = (configuration) => {
+ return [
+ 'FROM php:apache',
+ 'RUN a2enmod rewrite',
+ 'WORKDIR /usr/src/app',
+ `COPY .${configuration.build.directory} /var/www/html`,
+ 'EXPOSE 80',
+ ' CMD ["apache2-foreground"]'
+ ].join('\n')
+}
+
+module.exports = async function (configuration) {
+ try {
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishPHPDocker(configuration))
+ const stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
+}
diff --git a/api/buildPacks/rust/index.js b/api/buildPacks/rust/index.js
new file mode 100644
index 0000000000..6cbed387ac
--- /dev/null
+++ b/api/buildPacks/rust/index.js
@@ -0,0 +1,64 @@
+const fs = require('fs').promises
+const { streamEvents, docker } = require('../../libs/docker')
+const { execShellAsync } = require('../../libs/common')
+const TOML = require('@iarna/toml')
+
+const publishRustDocker = (configuration, custom) => {
+ return [
+ 'FROM rust:latest',
+ 'WORKDIR /app',
+ `COPY --from=${configuration.build.container.name}:cache /app/target target`,
+ `COPY --from=${configuration.build.container.name}:cache /usr/local/cargo /usr/local/cargo`,
+ 'COPY . .',
+ `RUN cargo build --release --bin ${custom.name}`,
+ 'FROM debian:buster-slim',
+ 'WORKDIR /app',
+ '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 update-ca-certificates',
+ `COPY --from=${configuration.build.container.name}:cache /app/target/release/${custom.name} ${custom.name}`,
+ `EXPOSE ${configuration.publish.port}`,
+ `CMD ["/app/${custom.name}"]`
+ ].join('\n')
+}
+
+const cacheRustDocker = (configuration, custom) => {
+ return [
+ `FROM rust:latest AS planner-${configuration.build.container.name}`,
+ 'WORKDIR /app',
+ 'RUN cargo install cargo-chef',
+ 'COPY . .',
+ 'RUN cargo chef prepare --recipe-path recipe.json',
+ 'FROM rust:latest',
+ 'WORKDIR /app',
+ 'RUN cargo install cargo-chef',
+ `COPY --from=planner-${configuration.build.container.name} /app/recipe.json recipe.json`,
+ 'RUN cargo chef cook --release --recipe-path recipe.json'
+ ].join('\n')
+}
+
+module.exports = async function (configuration) {
+ try {
+ const cargoToml = await execShellAsync(`cat ${configuration.general.workdir}/Cargo.toml`)
+ const parsedToml = TOML.parse(cargoToml)
+ const custom = {
+ name: parsedToml.package.name
+ }
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, cacheRustDocker(configuration, custom))
+
+ let stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:cache` }
+ )
+ await streamEvents(stream, configuration)
+
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishRustDocker(configuration, custom))
+
+ stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
+}
diff --git a/api/packs/static/index.js b/api/buildPacks/static/index.js
similarity index 52%
rename from api/packs/static/index.js
rename to api/buildPacks/static/index.js
index a2dc497a67..e6c4d56104 100644
--- a/api/packs/static/index.js
+++ b/api/buildPacks/static/index.js
@@ -2,6 +2,7 @@ const fs = require('fs').promises
const { buildImage } = require('../helpers')
const { streamEvents, docker } = require('../../libs/docker')
+// 'HEALTHCHECK --timeout=10s --start-period=10s --interval=5s CMD curl -I -s -f http://localhost/ || exit 1',
const publishStaticDocker = (configuration) => {
return [
'FROM nginx:stable-alpine',
@@ -16,12 +17,16 @@ const publishStaticDocker = (configuration) => {
}
module.exports = async function (configuration) {
- if (configuration.build.command.build) await buildImage(configuration)
- await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishStaticDocker(configuration))
+ try {
+ if (configuration.build.command.build) await buildImage(configuration)
+ await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishStaticDocker(configuration))
- const stream = await docker.engine.buildImage(
- { src: ['.'], context: configuration.general.workdir },
- { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
- )
- await streamEvents(stream, configuration)
+ const stream = await docker.engine.buildImage(
+ { src: ['.'], context: configuration.general.workdir },
+ { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
+ )
+ await streamEvents(stream, configuration)
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
}
diff --git a/api/libs/applications/build/container.js b/api/libs/applications/build/container.js
index 54b50f0bb8..a8209ec618 100644
--- a/api/libs/applications/build/container.js
+++ b/api/libs/applications/build/container.js
@@ -1,4 +1,4 @@
-const packs = require('../../../packs')
+const packs = require('../../../buildPacks')
const { saveAppLog } = require('../../logging')
const Deployment = require('../../../models/Deployment')
@@ -26,9 +26,14 @@ module.exports = async function (configuration) {
throw { error, type: 'app' }
}
} else {
- await Deployment.findOneAndUpdate(
- { repoId: id, branch, deployId, organization, name, domain },
- { repoId: id, branch, deployId, organization, name, domain, progress: 'failed' })
+ try {
+ await Deployment.findOneAndUpdate(
+ { repoId: id, branch, deployId, organization, name, domain },
+ { repoId: id, branch, deployId, organization, name, domain, progress: 'failed' })
+ } catch (error) {
+ // Hmm.
+ }
+
throw { error: 'No buildpack found.', type: 'app' }
}
}
diff --git a/api/libs/applications/cleanup/index.js b/api/libs/applications/cleanup/index.js
index 8987eeb5b1..c5c3b9f663 100644
--- a/api/libs/applications/cleanup/index.js
+++ b/api/libs/applications/cleanup/index.js
@@ -2,17 +2,16 @@ const { docker } = require('../../docker')
const { execShellAsync } = require('../../common')
const Deployment = require('../../../models/Deployment')
-async function purgeOldThings () {
+async function purgeImagesContainers () {
try {
- // TODO: Tweak this, because it deletes coolify-base, so the upgrade will be slow
- await docker.engine.pruneImages()
- await docker.engine.pruneContainers()
+ await execShellAsync('docker container prune -f')
+ await execShellAsync('docker image prune -f --filter=label!=coolify-reserve=true')
} catch (error) {
throw { error, type: 'server' }
}
}
-async function cleanup (configuration) {
+async function cleanupStuckedDeploymentsInDB (configuration) {
const { id } = configuration.repository
const deployId = configuration.general.deployId
try {
@@ -39,4 +38,4 @@ async function deleteSameDeployments (configuration) {
}
}
-module.exports = { cleanup, deleteSameDeployments, purgeOldThings }
+module.exports = { cleanupStuckedDeploymentsInDB, deleteSameDeployments, purgeImagesContainers }
diff --git a/api/libs/applications/configuration.js b/api/libs/applications/configuration.js
index 5ed8e73f39..d8fce5c277 100644
--- a/api/libs/applications/configuration.js
+++ b/api/libs/applications/configuration.js
@@ -1,7 +1,7 @@
const { uniqueNamesGenerator, adjectives, colors, animals } = require('unique-names-generator')
const cuid = require('cuid')
const crypto = require('crypto')
-
+const { docker } = require('../docker')
const { execShellAsync } = require('../common')
function getUniq () {
@@ -30,7 +30,8 @@ function setDefaultConfiguration (configuration) {
rollback_config: {
parallelism: 1,
delay: '10s',
- order: 'start-first'
+ order: 'start-first',
+ failure_action: 'rollback'
}
}
@@ -48,11 +49,18 @@ function setDefaultConfiguration (configuration) {
configuration.publish.port = 80
} else if (configuration.build.pack === 'nodejs') {
configuration.publish.port = 3000
+ } else if (configuration.build.pack === 'rust') {
+ configuration.publish.port = 3000
}
}
+
if (!configuration.build.directory) {
configuration.build.directory = '/'
}
+ if (!configuration.publish.directory) {
+ configuration.publish.directory = '/'
+ }
+
if (configuration.build.pack === 'static' || configuration.build.pack === 'nodejs') {
if (!configuration.build.command.installation) configuration.build.command.installation = 'yarn install'
}
@@ -66,8 +74,9 @@ function setDefaultConfiguration (configuration) {
}
}
-async function updateServiceLabels (configuration, services) {
+async function updateServiceLabels (configuration) {
// In case of any failure during deployment, still update the current configuration.
+ const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
const found = services.find(s => {
const config = JSON.parse(s.Spec.Labels.configuration)
if (config.repository.id === configuration.repository.id && config.repository.branch === configuration.repository.branch) {
@@ -79,10 +88,58 @@ async function updateServiceLabels (configuration, services) {
const { ID } = found
try {
const Labels = { ...JSON.parse(found.Spec.Labels.configuration), ...configuration }
- execShellAsync(`docker service update --label-add configuration='${JSON.stringify(Labels)}' --label-add com.docker.stack.image='${configuration.build.container.name}:${configuration.build.container.tag}' ${ID}`)
+ await execShellAsync(`docker service update --label-add configuration='${JSON.stringify(Labels)}' --label-add com.docker.stack.image='${configuration.build.container.name}:${configuration.build.container.tag}' ${ID}`)
} catch (error) {
console.log(error)
}
}
}
-module.exports = { setDefaultConfiguration, updateServiceLabels }
+
+async function precheckDeployment ({ services, configuration }) {
+ let foundService = false
+ let configChanged = false
+ let imageChanged = false
+
+ let forceUpdate = false
+
+ for (const service of services) {
+ const running = JSON.parse(service.Spec.Labels.configuration)
+ if (running) {
+ if (running.repository.id === configuration.repository.id && running.repository.branch === configuration.repository.branch) {
+ // Base service configuration changed
+ if (!running.build.container.baseSHA || running.build.container.baseSHA !== configuration.build.container.baseSHA) {
+ forceUpdate = true
+ }
+ // If the deployment is in error state, forceUpdate
+ const state = await execShellAsync(`docker stack ps ${running.build.container.name} --format '{{ json . }}'`)
+ const isError = state.split('\n').filter(n => n).map(s => JSON.parse(s)).filter(n => n.DesiredState !== 'Running' && n.Image.split(':')[1] === running.build.container.tag)
+ if (isError.length > 0) forceUpdate = true
+ foundService = true
+
+ const runningWithoutContainer = JSON.parse(JSON.stringify(running))
+ delete runningWithoutContainer.build.container
+
+ const configurationWithoutContainer = JSON.parse(JSON.stringify(configuration))
+ delete configurationWithoutContainer.build.container
+
+ // If only the configuration changed
+ if (JSON.stringify(runningWithoutContainer.build) !== JSON.stringify(configurationWithoutContainer.build) || JSON.stringify(runningWithoutContainer.publish) !== JSON.stringify(configurationWithoutContainer.publish)) configChanged = true
+ // If only the image changed
+ if (running.build.container.tag !== configuration.build.container.tag) imageChanged = true
+ // If build pack changed, forceUpdate the service
+ if (running.build.pack !== configuration.build.pack) forceUpdate = true
+ }
+ }
+ }
+ if (forceUpdate) {
+ imageChanged = false
+ configChanged = false
+ }
+ return {
+ foundService,
+ imageChanged,
+ configChanged,
+ forceUpdate
+ }
+}
+module.exports = { setDefaultConfiguration, updateServiceLabels, precheckDeployment }
diff --git a/api/libs/applications/deploy/copyFiles.js b/api/libs/applications/deploy/copyFiles.js
index b6e71eb326..bb6defeaa3 100644
--- a/api/libs/applications/deploy/copyFiles.js
+++ b/api/libs/applications/deploy/copyFiles.js
@@ -1,52 +1,63 @@
const fs = require('fs').promises
module.exports = async function (configuration) {
try {
- // TODO: Do it better.
- await fs.writeFile(`${configuration.general.workdir}/.dockerignore`, 'node_modules')
- await fs.writeFile(
- `${configuration.general.workdir}/nginx.conf`,
- `user nginx;
- worker_processes auto;
-
- error_log /var/log/nginx/error.log warn;
- pid /var/run/nginx.pid;
-
- events {
- worker_connections 1024;
- }
-
- http {
- include /etc/nginx/mime.types;
-
- access_log off;
- sendfile on;
- #tcp_nopush on;
- keepalive_timeout 65;
-
- server {
- listen 80;
- server_name localhost;
-
- location / {
- root /usr/share/nginx/html;
- index index.html;
- try_files $uri $uri/index.html $uri/ /index.html =404;
- }
-
- error_page 404 /50x.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
-
- }
-
- }
- `
- )
+ // TODO: Write full .dockerignore for all deployments!!
+ if (configuration.build.pack === 'php') {
+ await fs.writeFile(`${configuration.general.workdir}/.htaccess`, `
+ RewriteEngine On
+ RewriteBase /
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.+)$ index.php [QSA,L]
+ `)
+ }
+ // await fs.writeFile(`${configuration.general.workdir}/.dockerignore`, 'node_modules')
+ if (configuration.build.pack === 'static') {
+ await fs.writeFile(
+ `${configuration.general.workdir}/nginx.conf`,
+ `user nginx;
+ worker_processes auto;
+
+ error_log /var/log/nginx/error.log warn;
+ pid /var/run/nginx.pid;
+
+ events {
+ worker_connections 1024;
+ }
+
+ http {
+ include /etc/nginx/mime.types;
+
+ access_log off;
+ sendfile on;
+ #tcp_nopush on;
+ keepalive_timeout 65;
+
+ server {
+ listen 80;
+ server_name localhost;
+
+ location / {
+ root /usr/share/nginx/html;
+ index index.html;
+ try_files $uri $uri/index.html $uri/ /index.html =404;
+ }
+
+ error_page 404 /50x.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root /usr/share/nginx/html;
+ }
+
+ }
+
+ }
+ `
+ )
+ }
} catch (error) {
throw { error, type: 'server' }
}
diff --git a/api/libs/applications/deploy/deploy.js b/api/libs/applications/deploy/deploy.js
index 1f9619a062..0528320867 100644
--- a/api/libs/applications/deploy/deploy.js
+++ b/api/libs/applications/deploy/deploy.js
@@ -5,7 +5,7 @@ const { docker } = require('../../docker')
const { saveAppLog } = require('../../logging')
const { deleteSameDeployments } = require('../cleanup')
-module.exports = async function (configuration, configChanged, imageChanged) {
+module.exports = async function (configuration, imageChanged) {
try {
const generateEnvs = {}
for (const secret of configuration.publish.secrets) {
@@ -62,7 +62,6 @@ module.exports = async function (configuration, configChanged, imageChanged) {
}
await saveAppLog('### Publishing.', configuration)
await fs.writeFile(`${configuration.general.workdir}/stack.yml`, yaml.dump(stack))
- // TODO: Compare stack.yml with the currently running one to upgrade if something changes, like restart_policy
if (imageChanged) {
// console.log('image changed')
await execShellAsync(`docker service update --image ${configuration.build.container.name}:${configuration.build.container.tag} ${configuration.build.container.name}_${configuration.build.container.name}`)
diff --git a/api/libs/applications/index.js b/api/libs/applications/index.js
index 24f7e07f11..38c1b8498f 100644
--- a/api/libs/applications/index.js
+++ b/api/libs/applications/index.js
@@ -8,10 +8,10 @@ const copyFiles = require('./deploy/copyFiles')
const buildContainer = require('./build/container')
const deploy = require('./deploy/deploy')
const Deployment = require('../../models/Deployment')
-const { cleanup, purgeOldThings } = require('./cleanup')
+const { cleanupStuckedDeploymentsInDB, purgeImagesContainers } = require('./cleanup')
const { updateServiceLabels } = require('./configuration')
-async function queueAndBuild (configuration, services, configChanged, imageChanged) {
+async function queueAndBuild (configuration, imageChanged) {
const { id, organization, name, branch } = configuration.repository
const { domain } = configuration.publish
const { deployId, nickname, workdir } = configuration.general
@@ -22,15 +22,15 @@ async function queueAndBuild (configuration, services, configChanged, imageChang
await saveAppLog(`${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} Queued.`, configuration)
await copyFiles(configuration)
await buildContainer(configuration)
- await deploy(configuration, configChanged, imageChanged)
+ await deploy(configuration, imageChanged)
await Deployment.findOneAndUpdate(
{ repoId: id, branch, deployId, organization, name, domain },
{ repoId: id, branch, deployId, organization, name, domain, progress: 'done' })
- await updateServiceLabels(configuration, services)
+ await updateServiceLabels(configuration)
cleanupTmp(workdir)
- await purgeOldThings()
+ await purgeImagesContainers()
} catch (error) {
- await cleanup(configuration)
+ await cleanupStuckedDeploymentsInDB(configuration)
cleanupTmp(workdir)
const { type } = error.error
if (type === 'app') {
diff --git a/api/libs/common.js b/api/libs/common.js
index b26416ef6d..6026af14b5 100644
--- a/api/libs/common.js
+++ b/api/libs/common.js
@@ -15,12 +15,16 @@ function delay (t) {
}
async function verifyUserId (authorization) {
- const token = authorization.split(' ')[1]
- const verify = jsonwebtoken.verify(token, process.env.JWT_SIGN_KEY)
- const found = await User.findOne({ uid: verify.jti })
- if (found) {
- return true
- } else {
+ try {
+ const token = authorization.split(' ')[1]
+ const verify = jsonwebtoken.verify(token, process.env.JWT_SIGN_KEY)
+ const found = await User.findOne({ uid: verify.jti })
+ if (found) {
+ return true
+ } else {
+ return false
+ }
+ } catch (error) {
return false
}
}
diff --git a/api/libs/logging.js b/api/libs/logging.js
index 6af682b998..9d94780929 100644
--- a/api/libs/logging.js
+++ b/api/libs/logging.js
@@ -40,13 +40,17 @@ async function saveAppLog (event, configuration, isError) {
}
async function saveServerLog ({ event, configuration, type }) {
- if (configuration) {
- const deployId = configuration.general.deployId
- const repoId = configuration.repository.id
- const branch = configuration.repository.branch
- await new ApplicationLog({ repoId, branch, deployId, event: `[SERVER ERROR 😖]: ${event}` }).save()
+ try {
+ if (configuration) {
+ const deployId = configuration.general.deployId
+ const repoId = configuration.repository.id
+ const branch = configuration.repository.branch
+ await new ApplicationLog({ repoId, branch, deployId, event: `[SERVER ERROR 😖]: ${event}` }).save()
+ }
+ await new ServerLog({ event, type }).save()
+ } catch (error) {
+ // Hmm.
}
- await new ServerLog({ event, type }).save()
}
module.exports = {
diff --git a/api/packs/custom/index.js b/api/packs/custom/index.js
deleted file mode 100644
index 7c6f60065e..0000000000
--- a/api/packs/custom/index.js
+++ /dev/null
@@ -1,15 +0,0 @@
-const fs = require('fs').promises
-const { streamEvents, docker } = require('../../libs/docker')
-
-module.exports = async function (configuration) {
- const path = `${configuration.general.workdir}/${configuration.build.directory ? configuration.build.directory : ''}`
- if (fs.stat(`${path}/Dockerfile`)) {
- const stream = await docker.engine.buildImage(
- { src: ['.'], context: path },
- { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
- )
- await streamEvents(stream, configuration)
- } else {
- throw { error: 'No custom dockerfile found.', type: 'app' }
- }
-}
diff --git a/api/packs/php/index.js b/api/packs/php/index.js
deleted file mode 100644
index 0361b89f7d..0000000000
--- a/api/packs/php/index.js
+++ /dev/null
@@ -1,21 +0,0 @@
-const fs = require('fs').promises
-const { streamEvents, docker } = require('../../libs/docker')
-
-const publishPHPDocker = (configuration) => {
- return [
- 'FROM php:apache',
- 'WORKDIR /usr/src/app',
- `COPY .${configuration.build.directory} /var/www/html`,
- 'EXPOSE 80',
- ' CMD ["apache2-foreground"]'
- ].join('\n')
-}
-
-module.exports = async function (configuration) {
- await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishPHPDocker(configuration))
- const stream = await docker.engine.buildImage(
- { src: ['.'], context: configuration.general.workdir },
- { t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
- )
- await streamEvents(stream, configuration)
-}
diff --git a/api/routes/v1/application/check.js b/api/routes/v1/application/check.js
index 4cab18915e..f53a91df9d 100644
--- a/api/routes/v1/application/check.js
+++ b/api/routes/v1/application/check.js
@@ -5,31 +5,36 @@ const { docker } = require('../../../libs/docker')
module.exports = async function (fastify) {
fastify.post('/', async (request, reply) => {
- if (!await verifyUserId(request.headers.authorization)) {
- reply.code(500).send({ error: 'Invalid request' })
- return
- }
- const configuration = setDefaultConfiguration(request.body)
+ try {
+ if (!await verifyUserId(request.headers.authorization)) {
+ reply.code(500).send({ error: 'Invalid request' })
+ return
+ }
+ const configuration = setDefaultConfiguration(request.body)
- const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
- let foundDomain = false
+ const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
+ let foundDomain = false
- for (const service of services) {
- const running = JSON.parse(service.Spec.Labels.configuration)
- if (running) {
- if (
- running.publish.domain === configuration.publish.domain &&
- running.repository.id !== configuration.repository.id
- ) {
- foundDomain = true
+ for (const service of services) {
+ const running = JSON.parse(service.Spec.Labels.configuration)
+ if (running) {
+ if (
+ running.publish.domain === configuration.publish.domain &&
+ running.repository.id !== configuration.repository.id &&
+ running.publish.path === configuration.publish.path
+ ) {
+ foundDomain = true
+ }
}
}
+ if (fastify.config.DOMAIN === configuration.publish.domain) foundDomain = true
+ if (foundDomain) {
+ reply.code(500).send({ message: 'Domain already in use.' })
+ return
+ }
+ return { message: 'OK' }
+ } catch (error) {
+ throw { error, type: 'server' }
}
- if (fastify.config.DOMAIN === configuration.publish.domain) foundDomain = true
- if (foundDomain) {
- reply.code(500).send({ message: 'Domain already in use.' })
- return
- }
- return { message: 'OK' }
})
}
diff --git a/api/routes/v1/application/deploy/index.js b/api/routes/v1/application/deploy/index.js
index 1322f3d6c4..2204aeb670 100644
--- a/api/routes/v1/application/deploy/index.js
+++ b/api/routes/v1/application/deploy/index.js
@@ -1,8 +1,8 @@
-const { verifyUserId, cleanupTmp, execShellAsync } = require('../../../../libs/common')
+const { verifyUserId, cleanupTmp } = require('../../../../libs/common')
const Deployment = require('../../../../models/Deployment')
const { queueAndBuild } = require('../../../../libs/applications')
-const { setDefaultConfiguration } = require('../../../../libs/applications/configuration')
+const { setDefaultConfiguration, precheckDeployment } = require('../../../../libs/applications/configuration')
const { docker } = require('../../../../libs/docker')
const cloneRepository = require('../../../../libs/applications/github/cloneRepository')
@@ -32,90 +32,43 @@ module.exports = async function (fastify) {
// },
// };
fastify.post('/', async (request, reply) => {
- if (!await verifyUserId(request.headers.authorization)) {
+ try {
+ await verifyUserId(request.headers.authorization)
+ } catch (error) {
reply.code(500).send({ error: 'Invalid request' })
return
}
+ try {
+ const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
+ const configuration = setDefaultConfiguration(request.body)
+ await cloneRepository(configuration)
+ const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment({ services, configuration })
- const configuration = setDefaultConfiguration(request.body)
-
- const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
-
- await cloneRepository(configuration)
-
- let foundService = false
- let foundDomain = false
- let configChanged = false
- let imageChanged = false
-
- let forceUpdate = false
-
- for (const service of services) {
- const running = JSON.parse(service.Spec.Labels.configuration)
- if (running) {
- if (
- running.publish.domain === configuration.publish.domain &&
- running.repository.id !== configuration.repository.id
- ) {
- foundDomain = true
- }
- if (running.repository.id === configuration.repository.id && running.repository.branch === configuration.repository.branch) {
- // Base service configuration changed
- if (!running.build.container.baseSHA || running.build.container.baseSHA !== configuration.build.container.baseSHA) {
- configChanged = true
- }
- const state = await execShellAsync(`docker stack ps ${running.build.container.name} --format '{{ json . }}'`)
- const isError = state.split('\n').filter(n => n).map(s => JSON.parse(s)).filter(n => n.DesiredState !== 'Running')
- if (isError.length > 0) forceUpdate = true
-
- foundService = true
- const runningWithoutContainer = JSON.parse(JSON.stringify(running))
- delete runningWithoutContainer.build.container
-
- const configurationWithoutContainer = JSON.parse(JSON.stringify(configuration))
- delete configurationWithoutContainer.build.container
-
- // If only the configuration changed
- if (JSON.stringify(runningWithoutContainer.build) !== JSON.stringify(configurationWithoutContainer.build) || JSON.stringify(runningWithoutContainer.publish) !== JSON.stringify(configurationWithoutContainer.publish)) configChanged = true
- // If only the image changed
- if (running.build.container.tag !== configuration.build.container.tag) imageChanged = true
- // If build pack changed, forceUpdate the service
- if (running.build.pack !== configuration.build.pack) forceUpdate = true
- }
- }
- }
- if (foundDomain) {
- cleanupTmp(configuration.general.workdir)
- reply.code(500).send({ message: 'Domain already in use.' })
- return
- }
- if (forceUpdate) {
- imageChanged = false
- configChanged = false
- } else {
- if (foundService && !imageChanged && !configChanged) {
+ if (foundService && !forceUpdate && !imageChanged && !configChanged) {
cleanupTmp(configuration.general.workdir)
reply.code(500).send({ message: 'Nothing changed, no need to redeploy.' })
return
}
- }
- const alreadyQueued = await Deployment.find({
- repoId: configuration.repository.id,
- branch: configuration.repository.branch,
- organization: configuration.repository.organization,
- name: configuration.repository.name,
- domain: configuration.publish.domain,
- progress: { $in: ['queued', 'inprogress'] }
- })
+ const alreadyQueued = await Deployment.find({
+ repoId: configuration.repository.id,
+ branch: configuration.repository.branch,
+ organization: configuration.repository.organization,
+ name: configuration.repository.name,
+ domain: configuration.publish.domain,
+ progress: { $in: ['queued', 'inprogress'] }
+ })
- if (alreadyQueued.length > 0) {
- reply.code(200).send({ message: 'Already in the queue.' })
- return
- }
+ if (alreadyQueued.length > 0) {
+ reply.code(200).send({ message: 'Already in the queue.' })
+ return
+ }
- queueAndBuild(configuration, services, configChanged, imageChanged)
+ queueAndBuild(configuration, imageChanged)
- reply.code(201).send({ message: 'Deployment queued.', nickname: configuration.general.nickname, name: configuration.build.container.name })
+ reply.code(201).send({ message: 'Deployment queued.', nickname: configuration.general.nickname, name: configuration.build.container.name })
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
})
}
diff --git a/api/routes/v1/application/deploy/logs.js b/api/routes/v1/application/deploy/logs.js
index 322165f797..234015f6d5 100644
--- a/api/routes/v1/application/deploy/logs.js
+++ b/api/routes/v1/application/deploy/logs.js
@@ -18,25 +18,29 @@ module.exports = async function (fastify) {
}
}
fastify.get('/', { schema: getLogSchema }, async (request, reply) => {
- const { repoId, branch, page } = request.query
- const onePage = 5
- const show = Number(page) * onePage || 5
- const deploy = await Deployment.find({ repoId, branch })
- .select('-_id -__v -repoId')
- .sort({ createdAt: 'desc' })
- .limit(show)
+ try {
+ const { repoId, branch, page } = request.query
+ const onePage = 5
+ const show = Number(page) * onePage || 5
+ const deploy = await Deployment.find({ repoId, branch })
+ .select('-_id -__v -repoId')
+ .sort({ createdAt: 'desc' })
+ .limit(show)
- const finalLogs = deploy.map(d => {
- const finalLogs = { ...d._doc }
+ const finalLogs = deploy.map(d => {
+ const finalLogs = { ...d._doc }
- const updatedAt = dayjs(d.updatedAt).utc()
+ const updatedAt = dayjs(d.updatedAt).utc()
- finalLogs.took = updatedAt.diff(dayjs(d.createdAt)) / 1000
- finalLogs.since = updatedAt.fromNow()
+ finalLogs.took = updatedAt.diff(dayjs(d.createdAt)) / 1000
+ finalLogs.since = updatedAt.fromNow()
+ return finalLogs
+ })
return finalLogs
- })
- return finalLogs
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
})
fastify.get('/:deployId', async (request, reply) => {
diff --git a/api/routes/v1/application/logs.js b/api/routes/v1/application/logs.js
index e8221abac9..0396a22b32 100644
--- a/api/routes/v1/application/logs.js
+++ b/api/routes/v1/application/logs.js
@@ -2,9 +2,13 @@ const { docker } = require('../../../libs/docker')
module.exports = async function (fastify) {
fastify.get('/', async (request, reply) => {
- const { name } = request.query
- const service = await docker.engine.getService(`${name}_${name}`)
- const logs = (await service.logs({ stdout: true, stderr: true, timestamps: true })).toString().split('\n').map(l => l.slice(8)).filter((a) => a)
- return { logs }
+ try {
+ const { name } = request.query
+ const service = await docker.engine.getService(`${name}_${name}`)
+ const logs = (await service.logs({ stdout: true, stderr: true, timestamps: true })).toString().split('\n').map(l => l.slice(8)).filter((a) => a)
+ return { logs }
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
})
}
diff --git a/api/routes/v1/config.js b/api/routes/v1/config.js
index a8c66453c0..8a9543c062 100644
--- a/api/routes/v1/config.js
+++ b/api/routes/v1/config.js
@@ -1,60 +1,6 @@
const { docker } = require('../../libs/docker')
module.exports = async function (fastify) {
- // const getConfig = {
- // querystring: {
- // type: 'object',
- // properties: {
- // repoId: { type: 'number' },
- // branch: { type: 'string' }
- // },
- // required: ['repoId', 'branch']
- // }
- // }
-
- // const saveConfig = {
- // body: {
- // type: 'object',
- // properties: {
- // build: {
- // type: 'object',
- // properties: {
- // baseDir: { type: 'string' },
- // installCmd: { type: 'string' },
- // buildCmd: { type: 'string' }
- // },
- // required: ['baseDir', 'installCmd', 'buildCmd']
- // },
- // publish: {
- // type: 'object',
- // properties: {
- // publishDir: { type: 'string' },
- // domain: { type: 'string' },
- // pathPrefix: { type: 'string' },
- // port: { type: 'number' }
- // },
- // required: ['publishDir', 'domain', 'pathPrefix', 'port']
- // },
- // previewDeploy: { type: 'boolean' },
- // branch: { type: 'string' },
- // repoId: { type: 'number' },
- // buildPack: { type: 'string' },
- // fullName: { type: 'string' },
- // installationId: { type: 'number' }
- // },
- // required: ['build', 'publish', 'previewDeploy', 'branch', 'repoId', 'buildPack', 'fullName', 'installationId']
- // }
- // }
-
- // fastify.get("/all", async (request, reply) => {
- // return await Config.find().select("-_id -__v");
- // });
-
- // fastify.get("/", { schema: getConfig }, async (request, reply) => {
- // const { repoId, branch } = request.query;
- // return await Config.findOne({ repoId, branch }).select("-_id -__v");
- // });
-
fastify.post('/', async (request, reply) => {
const { name, organization, branch } = request.body
const services = await docker.engine.listServices()
@@ -79,25 +25,4 @@ module.exports = async function (fastify) {
reply.code(500).send({ message: 'No configuration found.' })
}
})
-
- // fastify.delete("/", async (request, reply) => {
- // const { repoId, branch } = request.body;
-
- // const deploys = await Deployment.find({ repoId, branch })
- // const found = deploys.filter(d => d.progress !== 'done' && d.progress !== 'failed')
- // if (found.length > 0) {
- // throw new Error('Deployment inprogress, cannot delete now.');
- // }
-
- // const config = await Config.findOneAndDelete({ repoId, branch })
- // for (const deploy of deploys) {
- // await ApplicationLog.findOneAndRemove({ deployId: deploy.deployId });
- // }
- // const secrets = await Secret.find({ repoId, branch });
- // for (const secret of secrets) {
- // await Secret.findByIdAndRemove(secret._id);
- // }
- // await execShellAsync(`docker stack rm ${config.containerName}`);
- // return { message: 'Deleted application and related configurations.' };
- // });
}
diff --git a/api/routes/v1/dashboard/index.js b/api/routes/v1/dashboard/index.js
index caec3441e3..f5e7c6c5ae 100644
--- a/api/routes/v1/dashboard/index.js
+++ b/api/routes/v1/dashboard/index.js
@@ -42,7 +42,7 @@ module.exports = async function (fastify) {
r.Spec.Labels.configuration = configuration
return r
})
- applications = [...new Map(applications.map(item => [item.Spec.Labels.configuration.publish.domain, item])).values()]
+ applications = [...new Map(applications.map(item => [item.Spec.Labels.configuration.publish.domain + item.Spec.Labels.configuration.publish.path, item])).values()]
return {
serverLogs,
applications: {
@@ -55,6 +55,8 @@ module.exports = async function (fastify) {
} catch (error) {
if (error.code === 'ENOENT' && error.errno === -2) {
throw new Error(`Docker service unavailable at ${error.address}.`)
+ } else {
+ throw { error, type: 'server' }
}
}
})
diff --git a/api/routes/v1/databases/index.js b/api/routes/v1/databases/index.js
index 17871aa038..7ca554c13a 100644
--- a/api/routes/v1/databases/index.js
+++ b/api/routes/v1/databases/index.js
@@ -45,124 +45,128 @@ module.exports = async function (fastify) {
}
fastify.post('/deploy', { schema: postSchema }, async (request, reply) => {
- let { type, defaultDatabaseName } = request.body
- const passwords = generator.generateMultiple(2, {
- length: 24,
- numbers: true,
- strict: true
- })
- const usernames = generator.generateMultiple(2, {
- length: 10,
- numbers: true,
- strict: true
- })
- // TODO: Query for existing db with the same name
- const nickname = getUniq()
+ try {
+ let { type, defaultDatabaseName } = request.body
+ const passwords = generator.generateMultiple(2, {
+ length: 24,
+ numbers: true,
+ strict: true
+ })
+ const usernames = generator.generateMultiple(2, {
+ length: 10,
+ numbers: true,
+ strict: true
+ })
+ // TODO: Query for existing db with the same name
+ const nickname = getUniq()
- if (!defaultDatabaseName) defaultDatabaseName = nickname
+ if (!defaultDatabaseName) defaultDatabaseName = nickname
- reply.code(201).send({ message: 'Deploying.' })
- // TODO: Persistent volume, custom inputs
- const deployId = cuid()
- const configuration = {
- general: {
- workdir: `/tmp/${deployId}`,
- deployId,
- nickname,
- type
- },
- database: {
- usernames,
- passwords,
- defaultDatabaseName
- },
- deploy: {
- name: nickname
- }
- }
- let generateEnvs = {}
- let image = null
- let volume = null
- if (type === 'mongodb') {
- generateEnvs = {
- MONGODB_ROOT_PASSWORD: passwords[0],
- MONGODB_USERNAME: usernames[0],
- MONGODB_PASSWORD: passwords[1],
- MONGODB_DATABASE: defaultDatabaseName
- }
- image = 'bitnami/mongodb:4.4'
- volume = `${configuration.general.deployId}-${type}-data:/bitnami/mongodb`
- } else if (type === 'postgresql') {
- generateEnvs = {
- POSTGRESQL_PASSWORD: passwords[0],
- POSTGRESQL_USERNAME: usernames[0],
- POSTGRESQL_DATABASE: defaultDatabaseName
- }
- image = 'bitnami/postgresql:13.2.0'
- volume = `${configuration.general.deployId}-${type}-data:/bitnami/postgresql`
- } else if (type === 'couchdb') {
- generateEnvs = {
- COUCHDB_PASSWORD: passwords[0],
- COUCHDB_USER: usernames[0]
+ reply.code(201).send({ message: 'Deploying.' })
+ // TODO: Persistent volume, custom inputs
+ const deployId = cuid()
+ const configuration = {
+ general: {
+ workdir: `/tmp/${deployId}`,
+ deployId,
+ nickname,
+ type
+ },
+ database: {
+ usernames,
+ passwords,
+ defaultDatabaseName
+ },
+ deploy: {
+ name: nickname
+ }
}
- image = 'bitnami/couchdb:3'
- volume = `${configuration.general.deployId}-${type}-data:/bitnami/couchdb`
- } else if (type === 'mysql') {
- generateEnvs = {
- MYSQL_ROOT_PASSWORD: passwords[0],
- MYSQL_ROOT_USER: usernames[0],
- MYSQL_USER: usernames[1],
- MYSQL_PASSWORD: passwords[1],
- MYSQL_DATABASE: defaultDatabaseName
+ let generateEnvs = {}
+ let image = null
+ let volume = null
+ if (type === 'mongodb') {
+ generateEnvs = {
+ MONGODB_ROOT_PASSWORD: passwords[0],
+ MONGODB_USERNAME: usernames[0],
+ MONGODB_PASSWORD: passwords[1],
+ MONGODB_DATABASE: defaultDatabaseName
+ }
+ image = 'bitnami/mongodb:4.4'
+ volume = `${configuration.general.deployId}-${type}-data:/bitnami/mongodb`
+ } else if (type === 'postgresql') {
+ generateEnvs = {
+ POSTGRESQL_PASSWORD: passwords[0],
+ POSTGRESQL_USERNAME: usernames[0],
+ POSTGRESQL_DATABASE: defaultDatabaseName
+ }
+ image = 'bitnami/postgresql:13.2.0'
+ volume = `${configuration.general.deployId}-${type}-data:/bitnami/postgresql`
+ } else if (type === 'couchdb') {
+ generateEnvs = {
+ COUCHDB_PASSWORD: passwords[0],
+ COUCHDB_USER: usernames[0]
+ }
+ image = 'bitnami/couchdb:3'
+ volume = `${configuration.general.deployId}-${type}-data:/bitnami/couchdb`
+ } else if (type === 'mysql') {
+ generateEnvs = {
+ MYSQL_ROOT_PASSWORD: passwords[0],
+ MYSQL_ROOT_USER: usernames[0],
+ MYSQL_USER: usernames[1],
+ MYSQL_PASSWORD: passwords[1],
+ MYSQL_DATABASE: defaultDatabaseName
+ }
+ image = 'bitnami/mysql:8.0'
+ volume = `${configuration.general.deployId}-${type}-data:/bitnami/mysql/data`
}
- image = 'bitnami/mysql:8.0'
- volume = `${configuration.general.deployId}-${type}-data:/bitnami/mysql/data`
- }
- const stack = {
- version: '3.8',
- services: {
- [configuration.general.deployId]: {
- image,
- networks: [`${docker.network}`],
- environment: generateEnvs,
- volumes: [volume],
- deploy: {
- replicas: 1,
- update_config: {
- parallelism: 0,
- delay: '10s',
- order: 'start-first'
- },
- rollback_config: {
- parallelism: 0,
- delay: '10s',
- order: 'start-first'
- },
- labels: [
- 'managedBy=coolify',
- 'type=database',
- 'configuration=' + JSON.stringify(configuration)
- ]
+ const stack = {
+ version: '3.8',
+ services: {
+ [configuration.general.deployId]: {
+ image,
+ networks: [`${docker.network}`],
+ environment: generateEnvs,
+ volumes: [volume],
+ deploy: {
+ replicas: 1,
+ update_config: {
+ parallelism: 0,
+ delay: '10s',
+ order: 'start-first'
+ },
+ rollback_config: {
+ parallelism: 0,
+ delay: '10s',
+ order: 'start-first'
+ },
+ labels: [
+ 'managedBy=coolify',
+ 'type=database',
+ 'configuration=' + JSON.stringify(configuration)
+ ]
+ }
+ }
+ },
+ networks: {
+ [`${docker.network}`]: {
+ external: true
+ }
+ },
+ volumes: {
+ [`${configuration.general.deployId}-${type}-data`]: {
+ external: true
}
- }
- },
- networks: {
- [`${docker.network}`]: {
- external: true
- }
- },
- volumes: {
- [`${configuration.general.deployId}-${type}-data`]: {
- external: true
}
}
+ await execShellAsync(`mkdir -p ${configuration.general.workdir}`)
+ await fs.writeFile(`${configuration.general.workdir}/stack.yml`, yaml.dump(stack))
+ await execShellAsync(
+ `cat ${configuration.general.workdir}/stack.yml | docker stack deploy -c - ${configuration.general.deployId}`
+ )
+ } catch (error) {
+ throw { error, type: 'server' }
}
- await execShellAsync(`mkdir -p ${configuration.general.workdir}`)
- await fs.writeFile(`${configuration.general.workdir}/stack.yml`, yaml.dump(stack))
- await execShellAsync(
- `cat ${configuration.general.workdir}/stack.yml | docker stack deploy -c - ${configuration.general.deployId}`
- )
})
fastify.delete('/:dbName', async (request, reply) => {
diff --git a/api/routes/v1/server/index.js b/api/routes/v1/server/index.js
new file mode 100644
index 0000000000..a43a6b9d49
--- /dev/null
+++ b/api/routes/v1/server/index.js
@@ -0,0 +1,14 @@
+const Server = require('../../../models/Logs/Server')
+module.exports = async function (fastify) {
+ fastify.get('/', async (request, reply) => {
+ try {
+ const serverLogs = await Server.find().select('-_id -__v')
+ // TODO: Should do better
+ return {
+ serverLogs
+ }
+ } catch (error) {
+ throw { error, type: 'server' }
+ }
+ })
+}
diff --git a/api/routes/v1/settings/index.js b/api/routes/v1/settings/index.js
index 8ce3a35442..ac502e9d78 100644
--- a/api/routes/v1/settings/index.js
+++ b/api/routes/v1/settings/index.js
@@ -25,7 +25,7 @@ module.exports = async function (fastify) {
settings
}
} catch (error) {
- throw new Error(error)
+ throw { error, type: 'server' }
}
})
@@ -38,7 +38,7 @@ module.exports = async function (fastify) {
).select('-_id -__v')
reply.code(201).send({ settings })
} catch (error) {
- throw new Error(error)
+ throw { error, type: 'server' }
}
})
}
diff --git a/api/routes/v1/upgrade/index.js b/api/routes/v1/upgrade/index.js
index 7adfae051f..6ed1566804 100644
--- a/api/routes/v1/upgrade/index.js
+++ b/api/routes/v1/upgrade/index.js
@@ -3,10 +3,10 @@ const { saveServerLog } = require('../../../libs/logging')
module.exports = async function (fastify) {
fastify.get('/', async (request, reply) => {
- const upgradeP1 = await execShellAsync('bash ./install.sh upgrade-phase-1')
+ const upgradeP1 = await execShellAsync('bash -c "$(curl -fsSL https://get.coollabs.io/coolify/upgrade-p1.sh)"')
await saveServerLog({ event: upgradeP1, type: 'UPGRADE-P-1' })
reply.code(200).send('I\'m trying, okay?')
- const upgradeP2 = await execShellAsync('bash ./install.sh upgrade-phase-2')
+ const upgradeP2 = await execShellAsync('docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -u root coolify bash -c "$(curl -fsSL https://get.coollabs.io/coolify/upgrade-p2.sh)"')
await saveServerLog({ event: upgradeP2, type: 'UPGRADE-P-2' })
})
}
diff --git a/api/routes/v1/verify.js b/api/routes/v1/verify.js
index 82e9331c07..1122d43ab2 100644
--- a/api/routes/v1/verify.js
+++ b/api/routes/v1/verify.js
@@ -3,14 +3,18 @@ const jwt = require('jsonwebtoken')
module.exports = async function (fastify) {
fastify.get('/', async (request, reply) => {
- const { authorization } = request.headers
- if (!authorization) {
+ try {
+ const { authorization } = request.headers
+ if (!authorization) {
+ reply.code(401).send({})
+ return
+ }
+ const token = authorization.split(' ')[1]
+ const verify = jwt.verify(token, fastify.config.JWT_SIGN_KEY)
+ const found = await User.findOne({ uid: verify.jti })
+ found ? reply.code(200).send({}) : reply.code(401).send({})
+ } catch (error) {
reply.code(401).send({})
- return
}
- const token = authorization.split(' ')[1]
- const verify = jwt.verify(token, fastify.config.JWT_SIGN_KEY)
- const found = await User.findOne({ uid: verify.jti })
- found ? reply.code(200).send({}) : reply.code(401).send({})
})
}
diff --git a/api/routes/v1/webhooks/deploy.js b/api/routes/v1/webhooks/deploy.js
index 51df9d8cbf..540bf17099 100644
--- a/api/routes/v1/webhooks/deploy.js
+++ b/api/routes/v1/webhooks/deploy.js
@@ -1,8 +1,8 @@
const crypto = require('crypto')
-const { cleanupTmp, execShellAsync } = require('../../../libs/common')
+const { cleanupTmp } = require('../../../libs/common')
const Deployment = require('../../../models/Deployment')
const { queueAndBuild } = require('../../../libs/applications')
-const { setDefaultConfiguration } = require('../../../libs/applications/configuration')
+const { setDefaultConfiguration, precheckDeployment } = require('../../../libs/applications/configuration')
const { docker } = require('../../../libs/docker')
const cloneRepository = require('../../../libs/applications/github/cloneRepository')
@@ -45,98 +45,55 @@ module.exports = async function (fastify) {
reply.code(500).send({ error: 'Not a push event.' })
return
}
-
- const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
-
- let configuration = services.find(r => {
- if (request.body.ref.startsWith('refs')) {
- const branch = request.body.ref.split('/')[2]
- if (
- JSON.parse(r.Spec.Labels.configuration).repository.id === request.body.repository.id &&
- JSON.parse(r.Spec.Labels.configuration).repository.branch === branch
- ) {
- return r
- }
- }
-
- return null
- })
-
- if (!configuration) {
- reply.code(500).send({ error: 'No configuration found.' })
- return
- }
-
- configuration = setDefaultConfiguration(JSON.parse(configuration.Spec.Labels.configuration))
-
- await cloneRepository(configuration)
-
- let foundService = false
- let foundDomain = false
- let configChanged = false
- let imageChanged = false
-
- let forceUpdate = false
-
- for (const service of services) {
- const running = JSON.parse(service.Spec.Labels.configuration)
- if (running) {
- if (
- running.publish.domain === configuration.publish.domain &&
- running.repository.id !== configuration.repository.id &&
- running.repository.branch !== configuration.repository.branch
- ) {
- foundDomain = true
+ try {
+ const services = (await docker.engine.listServices()).filter(r => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application')
+
+ let configuration = services.find(r => {
+ if (request.body.ref.startsWith('refs')) {
+ const branch = request.body.ref.split('/')[2]
+ if (
+ JSON.parse(r.Spec.Labels.configuration).repository.id === request.body.repository.id &&
+ JSON.parse(r.Spec.Labels.configuration).repository.branch === branch
+ ) {
+ return r
+ }
}
- if (running.repository.id === configuration.repository.id && running.repository.branch === configuration.repository.branch) {
- const state = await execShellAsync(`docker stack ps ${running.build.container.name} --format '{{ json . }}'`)
- const isError = state.split('\n').filter(n => n).map(s => JSON.parse(s)).filter(n => n.DesiredState !== 'Running')
- if (isError.length > 0) forceUpdate = true
- foundService = true
- const runningWithoutContainer = JSON.parse(JSON.stringify(running))
- delete runningWithoutContainer.build.container
+ return null
+ })
+ if (!configuration) {
+ reply.code(500).send({ error: 'No configuration found.' })
+ return
+ }
- const configurationWithoutContainer = JSON.parse(JSON.stringify(configuration))
- delete configurationWithoutContainer.build.container
+ configuration = setDefaultConfiguration(JSON.parse(configuration.Spec.Labels.configuration))
+ await cloneRepository(configuration)
+ const { foundService, imageChanged, configChanged, forceUpdate } = await precheckDeployment({ services, configuration })
- if (JSON.stringify(runningWithoutContainer.build) !== JSON.stringify(configurationWithoutContainer.build) || JSON.stringify(runningWithoutContainer.publish) !== JSON.stringify(configurationWithoutContainer.publish)) configChanged = true
- if (running.build.container.tag !== configuration.build.container.tag) imageChanged = true
- }
- }
- }
- if (foundDomain) {
- cleanupTmp(configuration.general.workdir)
- reply.code(500).send({ message: 'Domain already used.' })
- return
- }
- if (forceUpdate) {
- imageChanged = false
- configChanged = false
- } else {
- if (foundService && !imageChanged && !configChanged) {
+ if (foundService && !forceUpdate && !imageChanged && !configChanged) {
cleanupTmp(configuration.general.workdir)
reply.code(500).send({ message: 'Nothing changed, no need to redeploy.' })
return
}
- }
+ const alreadyQueued = await Deployment.find({
+ repoId: configuration.repository.id,
+ branch: configuration.repository.branch,
+ organization: configuration.repository.organization,
+ name: configuration.repository.name,
+ domain: configuration.publish.domain,
+ progress: { $in: ['queued', 'inprogress'] }
+ })
+
+ if (alreadyQueued.length > 0) {
+ reply.code(200).send({ message: 'Already in the queue.' })
+ return
+ }
- const alreadyQueued = await Deployment.find({
- repoId: configuration.repository.id,
- branch: configuration.repository.branch,
- organization: configuration.repository.organization,
- name: configuration.repository.name,
- domain: configuration.publish.domain,
- progress: { $in: ['queued', 'inprogress'] }
- })
+ queueAndBuild(configuration, imageChanged)
- if (alreadyQueued.length > 0) {
- reply.code(200).send({ message: 'Already in the queue.' })
- return
+ reply.code(201).send({ message: 'Deployment queued.', nickname: configuration.general.nickname, name: configuration.build.container.name })
+ } catch (error) {
+ throw { error, type: 'server' }
}
-
- queueAndBuild(configuration, services, configChanged, imageChanged)
-
- reply.code(201).send({ message: 'Deployment queued.' })
})
}
diff --git a/api/server.js b/api/server.js
index a84c45b40c..628cceb8c1 100644
--- a/api/server.js
+++ b/api/server.js
@@ -2,6 +2,8 @@ require('dotenv').config()
const fs = require('fs')
const util = require('util')
const { saveServerLog } = require('./libs/logging')
+const { execShellAsync } = require('./libs/common')
+const { purgeImagesContainers, cleanupStuckedDeploymentsInDB } = require('./libs/applications/cleanup')
const Deployment = require('./models/Deployment')
const fastify = require('fastify')({
logger: { level: 'error' }
@@ -10,6 +12,10 @@ const mongoose = require('mongoose')
const path = require('path')
const { schema } = require('./schema')
+process.on('unhandledRejection', (reason, p) => {
+ console.log(reason)
+ console.log(p)
+})
fastify.register(require('fastify-env'), {
schema,
dotenv: true
@@ -31,13 +37,16 @@ if (process.env.NODE_ENV === 'production') {
fastify.register(require('./app'), { prefix: '/api/v1' })
fastify.setErrorHandler(async (error, request, reply) => {
- console.log({ error })
if (error.statusCode) {
reply.status(error.statusCode).send({ message: error.message } || { message: 'Something is NOT okay. Are you okay?' })
} else {
reply.status(500).send({ message: error.message } || { message: 'Something is NOT okay. Are you okay?' })
}
- await saveServerLog({ event: error })
+ try {
+ await saveServerLog({ event: error })
+ } catch (error) {
+ //
+ }
})
if (process.env.NODE_ENV === 'production') {
@@ -83,8 +92,25 @@ mongoose.connection.once('open', async function () {
console.log('Coolify API is up and running in development.')
}
// On start cleanup inprogress/queued deployments.
- const deployments = await Deployment.find({ progress: { $in: ['queued', 'inprogress'] } })
- for (const deployment of deployments) {
- await Deployment.findByIdAndUpdate(deployment._id, { $set: { progress: 'failed' } })
+ try {
+ await cleanupStuckedDeploymentsInDB()
+ } catch (error) {
+ // Could not cleanup DB 🤔
+ }
+ try {
+ // Doing because I do not want to prune these images. Prune skip coolify-reserve labeled images.
+ const basicImages = ['nginx:stable-alpine', 'node:lts', 'ubuntu:20.04']
+ for (const image of basicImages) {
+ await execShellAsync(`echo "FROM ${image}" | docker build --label coolify-reserve=true -t ${image} -`)
+ }
+ } catch (error) {
+ console.log('Could not pull some basic images from Docker Hub.')
+ console.log(error)
+ }
+ try {
+ await purgeImagesContainers()
+ } catch (error) {
+ console.log('Could not purge containers/images.')
+ console.log(error)
}
})
diff --git a/install.sh b/install.sh
index ce60f578a0..33889e7145 100644
--- a/install.sh
+++ b/install.sh
@@ -85,4 +85,4 @@ case "$1" in
*)
exit 1
;;
-esac
+esac
\ No newline at end of file
diff --git a/install/Dockerfile-new b/install/Dockerfile-new
new file mode 100644
index 0000000000..947123030f
--- /dev/null
+++ b/install/Dockerfile-new
@@ -0,0 +1,24 @@
+FROM ubuntu:20.04 as binaries
+LABEL coolify-preserve=true
+RUN apt update && apt install -y curl gnupg2 ca-certificates
+RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
+RUN echo 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable' >> /etc/apt/sources.list
+RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o /usr/bin/envsubst
+RUN curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /usr/bin/jq
+RUN chmod +x /usr/bin/envsubst /usr/bin/jq
+RUN apt update && apt install -y docker-ce-cli && apt clean all
+
+FROM node:lts
+WORKDIR /usr/src/app
+LABEL coolify-preserve=true
+COPY --from=binaries /usr/bin/docker /usr/bin/docker
+COPY --from=binaries /usr/bin/envsubst /usr/bin/envsubst
+COPY --from=binaries /usr/bin/jq /usr/bin/jq
+COPY . .
+RUN curl -f https://get.pnpm.io/v6.js | node - add --global pnpm@6
+RUN pnpm install
+RUN pnpm build
+RUN rm -fr node_modules .pnpm-store
+RUN pnpm install -P
+CMD ["pnpm", "start"]
+EXPOSE 3000
\ No newline at end of file
diff --git a/install/README.md b/install/README.md
new file mode 100644
index 0000000000..d5f9c46a95
--- /dev/null
+++ b/install/README.md
@@ -0,0 +1,10 @@
+Some of the files are here for backwards compatibility.
+
+I will do things after 2 months:
+
+- rm ./install.js and ./update.js
+- rm ../install.sh
+- rm ./Dockerfile-base
+- rm ./obs
+- rm ./check.js "No need to check env file. During installation, it is checked by the installer. If you change it between to upgrades: 🤷‍♂️"
+- Rename Dockerfile-new to Dockerfile
diff --git a/install/check.js b/install/check.js
new file mode 100644
index 0000000000..d21f8585e1
--- /dev/null
+++ b/install/check.js
@@ -0,0 +1,24 @@
+require('dotenv').config()
+const fastify = require('fastify')()
+const { schema } = require('../api/schema')
+
+checkConfig().then(() => {
+ console.log('Config: OK')
+}).catch((err) => {
+ console.log('Config: NOT OK')
+ console.error(err)
+ process.exit(1)
+})
+
+function checkConfig () {
+ return new Promise((resolve, reject) => {
+ fastify.register(require('fastify-env'), {
+ schema,
+ dotenv: true
+ })
+ .ready((err) => {
+ if (err) reject(err)
+ resolve()
+ })
+ })
+}
diff --git a/install/coolify-template.yml b/install/coolify-template.yml
index 37e578adc6..574ade0e02 100644
--- a/install/coolify-template.yml
+++ b/install/coolify-template.yml
@@ -22,6 +22,7 @@ services:
- --providers.docker.swarmMode=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=${DOCKER_NETWORK}
+ - --providers.docker.swarmModeRefreshSeconds=1s
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.letsencrypt.acme.httpchallenge=true
diff --git a/install/obs/Dockerfile-base-new b/install/obs/Dockerfile-base-new
new file mode 100644
index 0000000000..8c1ac91890
--- /dev/null
+++ b/install/obs/Dockerfile-base-new
@@ -0,0 +1,4 @@
+FROM coolify-base-nodejs
+WORKDIR /usr/src/app
+COPY . .
+RUN pnpm install
\ No newline at end of file
diff --git a/install/obs/Dockerfile-base-nodejs b/install/obs/Dockerfile-base-nodejs
new file mode 100644
index 0000000000..f35dbc7aea
--- /dev/null
+++ b/install/obs/Dockerfile-base-nodejs
@@ -0,0 +1,6 @@
+FROM node:lts
+LABEL coolify-preserve=true
+COPY --from=coolify-binaries /usr/bin/docker /usr/bin/docker
+COPY --from=coolify-binaries /usr/bin/envsubst /usr/bin/envsubst
+COPY --from=coolify-binaries /usr/bin/jq /usr/bin/jq
+RUN curl -f https://get.pnpm.io/v6.js | node - add --global pnpm@6
\ No newline at end of file
diff --git a/install/obs/Dockerfile-binaries b/install/obs/Dockerfile-binaries
new file mode 100644
index 0000000000..5dca5c2862
--- /dev/null
+++ b/install/obs/Dockerfile-binaries
@@ -0,0 +1,9 @@
+FROM ubuntu:20.04
+LABEL coolify-preserve=true
+RUN apt update && apt install -y curl gnupg2 ca-certificates
+RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
+RUN echo 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable' >> /etc/apt/sources.list
+RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o /usr/bin/envsubst
+RUN curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /usr/bin/jq
+RUN chmod +x /usr/bin/envsubst /usr/bin/jq
+RUN apt update && apt install -y docker-ce-cli && apt clean all
diff --git a/install/update.js b/install/update.js
index 30f4cd4407..fb36d8a8ea 100644
--- a/install/update.js
+++ b/install/update.js
@@ -2,7 +2,6 @@ require('dotenv').config()
const { program } = require('commander')
const shell = require('shelljs')
const user = shell.exec('whoami', { silent: true }).stdout.replace('\n', '')
-
program.version('0.0.1')
program
.option('-d, --debug', 'Debug outputs.')
diff --git a/package.json b/package.json
index a21497ca9e..7c7a802ee2 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source, hassle-free, self-hostable Heroku & Netlify alternative.",
- "version": "1.0.5",
+ "version": "1.0.6",
"license": "AGPL-3.0",
"scripts": {
"lint": "standard",
@@ -16,8 +16,9 @@
"build:svite": "svite build"
},
"dependencies": {
+ "@iarna/toml": "^2.2.5",
"@roxi/routify": "^2.15.1",
- "@zerodevx/svelte-toast": "^0.2.0",
+ "@zerodevx/svelte-toast": "^0.2.1",
"axios": "^0.21.1",
"commander": "^7.2.0",
"compare-versions": "^3.6.0",
@@ -26,7 +27,7 @@
"deepmerge": "^4.2.2",
"dockerode": "^3.2.1",
"dotenv": "^8.2.0",
- "fastify": "^3.14.1",
+ "fastify": "^3.14.2",
"fastify-env": "^2.1.0",
"fastify-jwt": "^2.4.0",
"fastify-plugin": "^3.0.0",
@@ -52,7 +53,7 @@
"standard": "^16.0.3",
"svelte": "^3.37.0",
"svelte-hmr": "^0.14.0",
- "svelte-preprocess": "^4.6.1",
+ "svelte-preprocess": "^4.7.0",
"svite": "0.8.1",
"tailwindcss": "2.1.1"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b6e57e9703..f09c6c74f6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,17 +1,18 @@
lockfileVersion: 5.3
specifiers:
+ '@iarna/toml': ^2.2.5
'@roxi/routify': ^2.15.1
- '@zerodevx/svelte-toast': ^0.2.0
+ '@zerodevx/svelte-toast': ^0.2.1
axios: ^0.21.1
- commander: ^6.2.1
+ commander: ^7.2.0
compare-versions: ^3.6.0
cuid: ^2.1.8
dayjs: ^1.10.4
deepmerge: ^4.2.2
dockerode: ^3.2.1
dotenv: ^8.2.0
- fastify: ^3.14.1
+ fastify: ^3.14.2
fastify-env: ^2.1.0
fastify-jwt: ^2.4.0
fastify-plugin: ^3.0.0
@@ -33,24 +34,25 @@ specifiers:
standard: ^16.0.3
svelte: ^3.37.0
svelte-hmr: ^0.14.0
- svelte-preprocess: ^4.6.1
+ svelte-preprocess: ^4.7.0
svelte-select: ^3.17.0
svite: 0.8.1
tailwindcss: 2.1.1
unique-names-generator: ^4.4.0
dependencies:
+ '@iarna/toml': 2.2.5
'@roxi/routify': 2.15.1
- '@zerodevx/svelte-toast': 0.2.0
+ '@zerodevx/svelte-toast': 0.2.1
axios: 0.21.1
- commander: 6.2.1
+ commander: 7.2.0
compare-versions: 3.6.0
cuid: 2.1.8
dayjs: 1.10.4
deepmerge: 4.2.2
dockerode: 3.2.1
dotenv: 8.2.0
- fastify: 3.14.1
+ fastify: 3.14.2
fastify-env: 2.1.0
fastify-jwt: 2.4.0
fastify-plugin: 3.0.0
@@ -76,7 +78,7 @@ devDependencies:
standard: 16.0.3
svelte: 3.37.0
svelte-hmr: [email protected]
- svelte-preprocess: 4.6.9_fa8d64e4f515eee295d8f0f45fceadd2
+ svelte-preprocess: 4.7.0_fa8d64e4f515eee295d8f0f45fceadd2
svite: 0.8.1_d334b093211aa94b4e678204453b11ae
tailwindcss: [email protected]
@@ -155,6 +157,10 @@ packages:
purgecss: 3.1.3
dev: true
+ /@iarna/toml/2.2.5:
+ resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
+ dev: false
+
/@koa/cors/3.1.0:
resolution: {integrity: sha512-7ulRC1da/rBa6kj6P4g2aJfnET3z8Uf3SWu60cjbtxTA5g8lxRdX/Bd2P92EagGwwAhANeNw8T8if99rJliR6Q==}
engines: {node: '>= 8.0.0'}
@@ -553,8 +559,8 @@ packages:
resolution: {integrity: sha512-dn5FyfSc4ky424jH4FntiHno7Ss5yLkqKNmM/NXwANRnlkmqu74pnGetexDFVG5phMk9/FhwovUZCWGxsotVKg==}
dev: true
- /@zerodevx/svelte-toast/0.2.0:
- resolution: {integrity: sha512-zfnu02ZwAxpXfiqvAIZY97+Bv2hsBJ2fJlK/CVxliVu/+1I/R/z5Deo2BUtaLWmKAZX29FtFN9IBjF9hmPHQTA==}
+ /@zerodevx/svelte-toast/0.2.1:
+ resolution: {integrity: sha512-3yOusE+/xDaVNxkBJwbxDZea5ePQ77B15tbHv6ZlSYtlJu0u0PDhGMu8eoI+SmcCt4j+2sf0A1uS9+LcBIqUgg==}
dev: false
/abab/2.0.5:
@@ -1167,6 +1173,7 @@ packages:
/commander/6.2.1:
resolution: {integrity: sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==}
engines: {node: '>= 6'}
+ dev: true
/commander/7.2.0:
resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==}
@@ -2163,8 +2170,8 @@ packages:
resolution: {integrity: sha512-s1EQguBw/9qtc1p/WTY4eq9WMRIACkj+HTcOIK1in4MV5aFaQC9ZCIt0dJ7pr5bIf4lPpHvAtP2ywpTNgs7hqw==}
dev: false
- /fastify/3.14.1:
- resolution: {integrity: sha512-9hoK1vvopsUJnUJpge90t8PZIqNQhGM54yDrd2veCZLkxh8eipnaHrXe2+f7tIt6UScUZ92JZQavxFGB4HX7xA==}
+ /fastify/3.14.2:
+ resolution: {integrity: sha512-/PY//7gJnGxLQORaRHCEW148vpFKFpBIQNz1Yo/DxbHuk5EQqK2comzyE2ug8FSEldDX8nleapTshl0m78Px2w==}
engines: {node: '>=10.16.0'}
dependencies:
'@fastify/proxy-addr': 3.0.0
@@ -5770,6 +5777,57 @@ packages:
strip-indent: 3.0.0
svelte: 3.37.0
dev: true
+ optional: true
+
+ /svelte-preprocess/4.7.0_fa8d64e4f515eee295d8f0f45fceadd2:
+ resolution: {integrity: sha512-iNrY4YGqi0LD2e6oT9YbdSzOKntxk8gmzfqso1z/lUJOZh4o6fyIqkirmiZ8/dDJFqtIE1spVgDFWgkfhLEYlw==}
+ engines: {node: '>= 9.11.2'}
+ requiresBuild: true
+ peerDependencies:
+ '@babel/core': ^7.10.2
+ coffeescript: ^2.5.1
+ less: ^3.11.3
+ node-sass: '*'
+ postcss: ^7 || ^8
+ postcss-load-config: ^2.1.0 || ^3.0.0
+ pug: ^3.0.0
+ sass: ^1.26.8
+ stylus: ^0.54.7
+ sugarss: ^2.0.0
+ svelte: ^3.23.0
+ typescript: ^3.9.5 || ^4.0.0
+ peerDependenciesMeta:
+ '@babel/core':
+ optional: true
+ coffeescript:
+ optional: true
+ less:
+ optional: true
+ node-sass:
+ optional: true
+ postcss:
+ optional: true
+ postcss-load-config:
+ optional: true
+ pug:
+ optional: true
+ sass:
+ optional: true
+ stylus:
+ optional: true
+ sugarss:
+ optional: true
+ typescript:
+ optional: true
+ dependencies:
+ '@types/pug': 2.0.4
+ '@types/sass': 1.16.0
+ detect-indent: 6.0.0
+ postcss: 8.2.9
+ postcss-load-config: 3.0.1
+ strip-indent: 3.0.0
+ svelte: 3.37.0
+ dev: true
/svelte-select/3.17.0:
resolution: {integrity: sha512-ITmX/XUiSdkaILmsTviKRkZPaXckM5/FA7Y8BhiUPoamaZG/ZDyOo6ydjFu9fDVFTbwoAUGUi6HBjs+ZdK2AwA==}
diff --git a/src/App.svelte b/src/App.svelte
index 3ce30e887d..8fe87ef357 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -3,8 +3,7 @@
import { Router } from "@roxi/routify";
import { routes } from "../.routify/routes";
const options = {
- duration: 5000,
- dismissable: true
+ duration: 2000
};
</script>
diff --git a/src/components/Application/Configuration/ActiveTab/General.svelte b/src/components/Application/Configuration/ActiveTab/General.svelte
index e26c38bad4..915dc8b391 100644
--- a/src/components/Application/Configuration/ActiveTab/General.svelte
+++ b/src/components/Application/Configuration/ActiveTab/General.svelte
@@ -1,6 +1,7 @@
<script>
import { application} from "@store";
import TooltipInfo from "../../../Tooltip/TooltipInfo.svelte";
+ const showPorts = ['nodejs','custom','rust']
</script>
<div>
@@ -8,7 +9,7 @@
class="grid grid-cols-1 text-sm max-w-2xl md:mx-auto mx-6 pb-6 auto-cols-max "
>
<label for="buildPack"
- >Build Pack
+ >Build Pack
{#if $application.build.pack === 'custom'}
<TooltipInfo
label="Your custom Dockerfile will be used from the root directory (or from 'Base Directory' specified below) of your repository. "
@@ -26,8 +27,13 @@
size="large"
label="Published as a PHP application."
/>
+ {:else if $application.build.pack === 'rust'}
+ <TooltipInfo
+ size="large"
+ label="Published as a Rust application."
+ />
{/if}
-
+
</label
>
<select id="buildPack" bind:value="{$application.build.pack}">
@@ -35,6 +41,7 @@
<option class="font-bold">nodejs</option>
<option class="font-bold">php</option>
<option class="font-bold">custom</option>
+ <option class="font-bold">rust</option>
</select>
</div>
<div
@@ -66,7 +73,7 @@
/>
</div>
</div>
- {#if $application.build.pack === "nodejs" || $application.build.pack === "custom"}
+ {#if showPorts.includes($application.build.pack)}
<label for="Port" >Port</label>
<input
id="Port"
diff --git a/src/components/Application/Configuration/Configuration.svelte b/src/components/Application/Configuration/Configuration.svelte
index f494e88458..56e8acfa34 100644
--- a/src/components/Application/Configuration/Configuration.svelte
+++ b/src/components/Application/Configuration/Configuration.svelte
@@ -29,7 +29,7 @@
async function loadBranches() {
loading.branches = true;
- if ($isActive("/application/new")) $application.repository.branch = null
+ if ($isActive("/application/new")) $application.repository.branch = null;
const selectedRepository = repositories.find(
r => r.id === $application.repository.id,
);
@@ -54,6 +54,7 @@
}
async function loadGithub() {
+ loading.github = true;
try {
const { installations } = await $fetch(
"https://api.github.com/user/installations",
@@ -100,7 +101,6 @@
} finally {
loading.github = false;
}
-
}
function modifyGithubAppConfig() {
const left = screen.width / 2 - 1020 / 2;
@@ -144,6 +144,52 @@
}
</script>
+{#if !$isActive("/application/new")}
+ <div class="min-h-full text-white">
+ <div
+ class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center"
+ >
+ <a
+ target="_blank"
+ class="text-green-500 hover:underline cursor-pointer px-2"
+ href="{'https://' +
+ $application.publish.domain +
+ $application.publish.path}"
+ >{$application.publish.domain
+ ? `${$application.publish.domain}${$application.publish.path !== '/' ? $application.publish.path : ''}`
+ : "Loading..."}</a
+ >
+ <a
+ target="_blank"
+ class="icon"
+ href="{`https://github.com/${$application.repository.organization}/${$application.repository.name}`}"
+ >
+ <svg
+ class="w-6"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ ><path
+ d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
+ ></path></svg
+ ></a
+ >
+ </div>
+ </div>
+{:else if $isActive("/application/new")}
+ <div class="min-h-full text-white">
+ <div
+ class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center"
+ >
+ New Application
+ </div>
+ </div>
+{/if}
+
<div in:fade="{{ duration: 100 }}">
{#if !$session.githubAppToken}
<Login />
diff --git a/src/components/Application/Configuration/Tabs.svelte b/src/components/Application/Configuration/Tabs.svelte
index f6cc014da7..69323e0a46 100644
--- a/src/components/Application/Configuration/Tabs.svelte
+++ b/src/components/Application/Configuration/Tabs.svelte
@@ -8,7 +8,7 @@
import BuildStep from "./ActiveTab/BuildStep.svelte";
import Secrets from "./ActiveTab/Secrets.svelte";
import Loading from "../../Loading.svelte";
-
+ const buildPhaseActive = ["nodejs", "static"];
let loading = false;
onMount(async () => {
if (!$isActive("/application/new")) {
@@ -27,8 +27,8 @@
});
} else {
loading = true;
- $deployments?.applications?.deployed.filter(d => {
- const conf = d?.Spec?.Labels.application;
+ $deployments?.applications?.deployed.find(d => {
+ const conf = d?.Spec?.Labels.configuration;
if (
conf?.repository?.organization ===
$application.repository.organization &&
@@ -40,6 +40,7 @@
organization: $application.repository.organization,
branch: $application.repository.branch,
});
+ toast.push("This repository & branch is already defined. Redirecting...");
}
});
try {
@@ -52,6 +53,9 @@
const Dockerfile = dir.find(
f => f.type === "file" && f.name === "Dockerfile",
);
+ const CargoToml = dir.find(
+ f => f.type === "file" && f.name === "Cargo.toml",
+ );
if (Dockerfile) {
$application.build.pack = "custom";
@@ -60,7 +64,7 @@
const { content } = await $fetch(packageJson.git_url);
const packageJsonContent = JSON.parse(atob(content));
const checkPackageJSONContents = dep => {
- return(
+ return (
packageJsonContent?.dependencies?.hasOwnProperty(dep) ||
packageJsonContent?.devDependencies?.hasOwnProperty(dep)
);
@@ -87,13 +91,12 @@
) {
$application.build.command.build = config.build;
}
- toast.push(
- `${config.name} App detected. Default values set.`,
- );
- }
-
+ toast.push(`${config.name} App detected. Default values set.`);
+ }
});
-
+ } else if (CargoToml) {
+ $application.build.pack = "rust";
+ toast.push(`Rust language detected. Default values set.`);
}
} catch (error) {
// Nothing detected
@@ -133,7 +136,7 @@
>
General
</div>
- {#if $application.build.pack === "php"}
+ {#if !buildPhaseActive.includes($application.build.pack)}
<div disabled class="px-3 py-2 text-warmGray-700 cursor-not-allowed">
Build Step
</div>
@@ -146,14 +149,19 @@
Build Step
</div>
{/if}
-
- <div
- on:click="{() => activateTab('secrets')}"
- class:text-green-500="{activeTab.secrets}"
- class="px-3 py-2 cursor-pointer hover:text-green-500"
- >
- Secrets
- </div>
+ {#if $application.build.pack === "custom"}
+ <div disabled class="px-3 py-2 text-warmGray-700 cursor-not-allowed">
+ Secrets
+ </div>
+ {:else}
+ <div
+ on:click="{() => activateTab('secrets')}"
+ class:text-green-500="{activeTab.secrets}"
+ class="px-3 py-2 cursor-pointer hover:text-green-500"
+ >
+ Secrets
+ </div>
+ {/if}
</nav>
</div>
<div class="max-w-4xl mx-auto">
diff --git a/src/pages/_layout.svelte b/src/pages/_layout.svelte
index 942c57fd30..628224ac10 100644
--- a/src/pages/_layout.svelte
+++ b/src/pages/_layout.svelte
@@ -64,18 +64,21 @@
}
}
async function checkUpgrade() {
+ latest = await window
+ .fetch(`https://get.coollabs.io/version.json`, {
+ cache: "no-cache",
+ })
+ .then(r => r.json());
const branch =
process.env.NODE_ENV === "production" &&
window.location.hostname !== "test.andrasbacsai.dev"
? "main"
: "next";
- latest = await window
- .fetch(
- `https://raw.githubusercontent.com/coollabsio/coolify/${branch}/package.json`,
- { cache: "no-cache" },
- )
- .then(r => r.json());
- return compareVersions(latest.version, packageJson.version) === 1
+
+ return compareVersions(
+ latest.coolify[branch].version,
+ packageJson.version,
+ ) === 1
? true
: false;
}
diff --git a/src/pages/application/[organization]/[name]/[branch]/configuration.svelte b/src/pages/application/[organization]/[name]/[branch]/configuration.svelte
index 2afae4bdee..48bcc3ca6c 100644
--- a/src/pages/application/[organization]/[name]/[branch]/configuration.svelte
+++ b/src/pages/application/[organization]/[name]/[branch]/configuration.svelte
@@ -1,38 +1,5 @@
<script>
- import { application } from "@store";
import Configuration from "../../../../../components/Application/Configuration/Configuration.svelte";
</script>
-<div class="min-h-full text-white">
- <div
- class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center"
- >
- <a
- target="_blank"
- class="text-green-500 hover:underline cursor-pointer px-2"
- href="{'https://' +
- $application.publish.domain +
- $application.publish.path}">{$application.publish.domain}</a
- >
- <a
- target="_blank"
- class="icon"
- href="{`https://github.com/${$application.repository.organization}/${$application.repository.name}`}"
- >
- <svg
- class="w-6"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- ><path
- d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
- ></path></svg
- ></a
- >
- </div>
-</div>
<Configuration />
diff --git a/src/pages/application/[organization]/[name]/[branch]/logs/[deployId].svelte b/src/pages/application/[organization]/[name]/[branch]/logs/[deployId].svelte
index f7ecc7fcdd..54e74bb0f9 100644
--- a/src/pages/application/[organization]/[name]/[branch]/logs/[deployId].svelte
+++ b/src/pages/application/[organization]/[name]/[branch]/logs/[deployId].svelte
@@ -38,12 +38,12 @@
<Loading />
{:then}
<div
- class="text-center space-y-2 max-w-7xl mx-auto px-6"
+ class="text-center px-6"
in:fade="{{ duration: 100 }}"
>
- <div class="max-w-4xl mx-auto" in:fade="{{ duration: 100 }}">
+ <div in:fade="{{ duration: 100 }}">
<pre
- class="text-left font-mono text-xs font-medium tracking-tighter rounded-lg bg-warmGray-800 p-4 whitespace-pre-wrap">
+ class="leading-4 text-left text-sm font-semibold tracking-tighter rounded-lg bg-black p-6 whitespace-pre-wrap">
{#if logs.length > 0}
{#each logs as log}
{log + '\n'}
diff --git a/src/pages/application/[organization]/[name]/[branch]/logs/index.svelte b/src/pages/application/[organization]/[name]/[branch]/logs/index.svelte
index c398c31044..42a91340e4 100644
--- a/src/pages/application/[organization]/[name]/[branch]/logs/index.svelte
+++ b/src/pages/application/[organization]/[name]/[branch]/logs/index.svelte
@@ -59,17 +59,17 @@
<Loading />
{:then}
<div
- class="text-center space-y-2 max-w-7xl mx-auto px-6"
+ class="text-center px-6"
in:fade="{{ duration: 100 }}"
>
<div class="flex pt-2 space-x-4 w-full">
<div class="w-full">
<div class="font-bold text-left pb-2 text-xl">Application logs</div>
{#if logs.length === 0}
- <div class="text-xs">Waiting for the logs...</div>
+ <div class="text-xs font-semibold tracking-tighter">Waiting for the logs...</div>
{:else}
- <pre
- class="text-left font-mono text-xs font-medium rounded bg-warmGray-800 text-white p-4 whitespace-pre-wrap w-full">
+ <pre
+ class="leading-4 text-left text-sm font-semibold tracking-tighter rounded-lg bg-black p-6 whitespace-pre-wrap w-full">
{#each logs as log}
{log + '\n'}
{/each}
diff --git a/src/pages/application/new.svelte b/src/pages/application/new.svelte
index 4c3dc3619d..9517ccadb0 100644
--- a/src/pages/application/new.svelte
+++ b/src/pages/application/new.svelte
@@ -2,12 +2,4 @@
import Configuration from "../../components/Application/Configuration/Configuration.svelte";
</script>
-<div class="min-h-full text-white">
- <div
- class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center"
- >
- New Application
- </div>
-</div>
-
<Configuration />
diff --git a/src/pages/dashboard/applications.svelte b/src/pages/dashboard/applications.svelte
index 8f2baa18d7..d19557f5cb 100644
--- a/src/pages/dashboard/applications.svelte
+++ b/src/pages/dashboard/applications.svelte
@@ -185,25 +185,37 @@
></path></g
>
</svg>
+ {:else if application.Spec.Labels.configuration.build.pack === "rust"}
+ <svg
+ class="w-14 h-14 absolute top-0 left-0 -m-6"
+ viewBox="0 0 128 128"
+ >
+ <path
+ d="M62.271 10.880 C 62.082 10.990,61.289 12.128,60.508 13.409 C 58.548 16.626,58.526 16.628,55.893 13.857 C 54.180 12.055,53.766 11.725,53.214 11.729 C 52.855 11.731,52.402 11.853,52.206 12.000 C 52.011 12.147,51.458 13.317,50.978 14.600 C 49.879 17.539,49.826 17.634,49.217 17.751 C 48.842 17.822,48.120 17.420,46.389 16.177 C 45.111 15.258,43.857 14.507,43.603 14.507 C 42.549 14.507,42.252 15.083,41.750 18.100 C 41.112 21.936,41.134 21.923,37.676 20.352 C 36.280 19.719,34.956 19.200,34.733 19.200 C 34.510 19.200,34.087 19.440,33.794 19.733 C 33.262 20.266,33.261 20.268,33.406 23.201 L 33.552 26.137 32.997 26.434 C 32.505 26.697,32.166 26.665,29.988 26.150 C 27.145 25.479,26.545 25.497,25.969 26.272 L 25.548 26.838 26.113 29.259 C 26.423 30.590,26.722 31.872,26.778 32.107 C 26.833 32.341,26.738 32.716,26.566 32.939 C 26.282 33.306,25.980 33.339,23.349 33.299 C 18.896 33.229,18.643 33.611,20.483 37.627 C 21.068 38.902,21.547 40.060,21.547 40.199 C 21.547 40.933,20.962 41.200,18.449 41.610 C 17.043 41.839,15.821 42.027,15.733 42.027 C 15.645 42.027,15.381 42.219,15.147 42.453 C 14.382 43.218,14.599 43.936,16.334 46.385 C 18.495 49.435,18.491 49.446,14.921 50.812 C 10.861 52.365,10.779 52.748,13.870 55.680 C 16.749 58.410,16.752 58.370,13.493 60.419 C 11.024 61.970,10.986 62.007,10.923 62.848 C 10.847 63.871,10.865 63.889,13.813 65.690 C 16.728 67.470,16.728 67.524,13.867 70.231 C 10.790 73.141,10.885 73.566,14.948 75.099 C 18.498 76.438,18.503 76.454,16.338 79.504 C 15.111 81.233,14.720 81.953,14.720 82.487 C 14.720 83.486,15.240 83.741,18.347 84.263 C 20.964 84.704,21.547 84.963,21.547 85.685 C 21.547 85.833,21.067 87.001,20.480 88.279 C 18.654 92.256,18.862 92.587,23.184 92.587 C 27.209 92.587,27.102 92.464,26.235 96.094 C 25.581 98.830,25.571 99.354,26.163 99.945 C 26.616 100.399,27.470 100.348,30.141 99.709 C 32.181 99.222,32.539 99.188,33.012 99.441 L 33.552 99.730 33.406 102.665 C 33.261 105.599,33.262 105.601,33.794 106.134 C 34.087 106.427,34.516 106.667,34.746 106.667 C 34.976 106.667,36.300 106.151,37.689 105.520 C 41.136 103.955,41.114 103.942,41.750 107.766 C 42.254 110.797,42.548 111.360,43.624 111.360 C 43.891 111.360,45.118 110.640,46.352 109.760 C 48.519 108.214,49.081 107.972,49.658 108.339 C 49.807 108.433,50.385 109.703,50.942 111.161 C 51.761 113.305,52.061 113.863,52.517 114.081 C 53.385 114.497,53.922 114.163,55.962 111.941 C 58.425 109.258,58.526 109.271,60.537 112.530 C 62.758 116.128,63.333 116.120,65.610 112.457 C 67.572 109.301,67.549 109.303,70.201 112.073 C 71.962 113.911,72.337 114.204,72.931 114.204 C 73.310 114.204,73.763 114.062,73.936 113.888 C 74.110 113.714,74.686 112.429,75.216 111.033 C 75.746 109.636,76.295 108.420,76.437 108.330 C 76.998 107.973,77.579 108.224,79.743 109.760 C 81.017 110.665,82.216 111.360,82.501 111.360 C 83.559 111.360,83.941 110.609,84.381 107.657 C 84.757 105.140,84.833 104.899,85.328 104.648 C 85.815 104.401,86.107 104.484,88.391 105.521 C 89.780 106.151,91.104 106.667,91.334 106.667 C 91.564 106.667,92.000 106.420,92.301 106.118 L 92.850 105.570 92.699 102.755 C 92.555 100.067,92.568 99.923,92.997 99.535 C 93.438 99.136,93.483 99.138,95.949 99.701 C 98.935 100.383,99.492 100.401,100.053 99.840 C 100.601 99.292,100.595 99.172,99.845 96.009 C 99.004 92.461,98.891 92.587,102.933 92.587 C 105.688 92.587,105.995 92.548,106.346 92.161 C 106.932 91.513,106.793 90.771,105.614 88.258 C 105.019 86.992,104.536 85.840,104.540 85.698 C 104.560 84.951,105.147 84.696,107.860 84.255 C 109.520 83.986,110.762 83.674,110.987 83.471 C 111.741 82.790,111.464 81.904,109.743 79.491 C 107.586 76.467,107.595 76.438,111.049 75.165 C 115.185 73.641,115.303 73.133,112.208 70.192 C 109.341 67.468,109.340 67.483,112.480 65.555 C 116.276 63.225,116.282 62.700,112.547 60.382 C 109.335 58.389,109.337 58.417,112.216 55.683 C 115.304 52.749,115.220 52.365,111.159 50.812 C 107.575 49.441,107.564 49.407,109.742 46.418 C 111.039 44.638,111.360 44.047,111.360 43.437 C 111.360 42.371,110.882 42.132,107.738 41.624 C 105.111 41.200,104.533 40.942,104.533 40.195 C 104.533 40.053,105.013 38.910,105.600 37.653 C 106.749 35.192,106.910 34.207,106.260 33.618 C 105.911 33.302,105.443 33.257,102.939 33.298 C 100.319 33.342,99.984 33.305,99.621 32.940 C 99.224 32.541,99.228 32.485,99.848 29.898 C 100.608 26.728,100.611 26.651,99.986 26.064 C 99.352 25.468,98.956 25.478,96.045 26.163 C 93.924 26.663,93.573 26.696,93.091 26.438 L 92.544 26.145 92.695 23.219 L 92.847 20.294 92.300 19.747 C 91.999 19.446,91.572 19.200,91.350 19.200 C 91.129 19.200,89.812 19.723,88.424 20.361 C 86.106 21.428,85.857 21.499,85.356 21.237 C 84.856 20.975,84.773 20.717,84.346 18.110 C 83.853 15.094,83.548 14.507,82.477 14.507 C 82.223 14.507,80.964 15.262,79.679 16.185 C 77.569 17.701,77.286 17.844,76.760 17.661 C 76.325 17.509,76.072 17.178,75.763 16.355 C 75.534 15.749,75.096 14.581,74.788 13.760 C 74.166 12.104,73.819 11.733,72.887 11.733 C 72.367 11.733,71.896 12.107,70.208 13.860 C 67.555 16.616,67.545 16.615,65.594 13.415 C 64.814 12.136,63.999 10.994,63.782 10.878 C 63.294 10.616,62.720 10.617,62.271 10.880 M64.689 20.515 C 67.000 22.160,65.771 26.027,62.937 26.027 C 60.187 26.027,58.802 22.714,60.766 20.833 C 61.874 19.771,63.463 19.642,64.689 20.515 M61.783 30.729 C 63.298 31.305,63.920 30.959,67.379 27.625 L 69.978 25.119 71.078 25.265 C 74.528 25.723,81.390 28.737,85.333 31.526 C 88.956 34.090,93.771 39.312,95.823 42.903 L 96.262 43.672 94.318 48.052 C 93.248 50.461,92.373 52.685,92.373 52.996 C 92.373 53.713,92.843 54.847,93.296 55.222 C 93.487 55.381,95.302 56.255,97.329 57.164 L 101.013 58.818 101.158 59.755 C 101.345 60.976,101.370 63.975,101.200 64.827 L 101.067 65.493 98.964 65.493 C 96.525 65.493,96.713 65.275,96.581 68.267 C 96.485 70.436,95.961 71.635,94.769 72.411 C 92.827 73.678,89.620 73.448,88.260 71.945 C 88.051 71.714,87.645 70.553,87.357 69.364 C 86.516 65.891,85.386 63.941,83.116 62.044 C 82.399 61.445,81.813 60.886,81.813 60.801 C 81.813 60.717,82.601 60.053,83.565 59.328 C 87.075 56.682,89.093 53.602,89.315 50.551 C 89.738 44.732,85.102 39.308,78.206 37.550 C 76.571 37.133,75.873 37.120,55.646 37.120 C 44.166 37.120,34.773 37.045,34.773 36.954 C 34.773 36.739,37.324 34.263,38.827 33.021 C 42.954 29.609,48.315 26.924,53.867 25.490 L 55.787 24.993 58.515 27.759 C 60.016 29.280,61.487 30.616,61.783 30.729 M27.432 48.526 C 28.689 49.349,29.204 51.417,28.462 52.660 C 27.314 54.584,24.406 54.665,23.257 52.805 C 21.586 50.103,24.804 46.804,27.432 48.526 M101.482 48.631 C 104.770 50.636,102.222 55.568,98.702 54.011 C 96.352 52.971,96.277 49.759,98.575 48.587 C 99.534 48.098,100.636 48.115,101.482 48.631 M37.120 60.907 L 37.120 73.173 31.698 73.173 L 26.276 73.173 25.846 71.307 C 25.000 67.632,24.644 63.830,24.857 60.716 L 25.006 58.528 28.734 56.856 C 31.073 55.808,32.577 55.009,32.771 54.712 C 33.619 53.419,33.538 52.495,32.348 49.867 L 31.792 48.640 34.456 48.640 L 37.120 48.640 37.120 60.907 M68.340 49.174 C 70.662 49.778,71.889 51.007,71.892 52.730 C 71.894 53.995,71.267 54.789,69.712 55.491 C 68.611 55.989,68.436 56.001,61.493 56.069 L 54.400 56.137 54.400 52.495 L 54.400 48.853 60.755 48.853 C 65.719 48.853,67.380 48.923,68.340 49.174 M65.944 66.776 C 67.095 67.096,68.456 68.096,69.154 69.135 C 69.887 70.227,70.316 71.647,71.332 76.351 C 72.190 80.327,72.742 81.627,74.288 83.319 C 76.203 85.414,75.759 85.333,85.325 85.333 C 89.906 85.333,93.653 85.406,93.653 85.496 C 93.653 85.657,90.498 89.387,90.362 89.387 C 90.323 89.387,88.675 89.042,86.700 88.620 C 81.123 87.429,80.922 87.569,79.642 93.546 L 78.819 97.386 78.076 97.752 C 76.836 98.364,72.806 99.624,70.717 100.054 C 67.265 100.764,63.508 101.004,60.206 100.725 C 54.577 100.248,47.123 98.064,46.832 96.805 C 46.770 96.538,46.395 94.810,46.000 92.964 C 45.604 91.118,45.123 89.367,44.931 89.073 C 44.008 87.665,43.037 87.578,38.767 88.523 C 37.150 88.881,35.739 89.173,35.631 89.173 C 35.428 89.173,32.427 85.703,32.427 85.469 C 32.427 85.396,39.555 85.311,48.267 85.281 L 64.107 85.227 64.164 79.600 C 64.204 75.627,64.149 73.886,63.977 73.680 C 63.785 73.448,62.763 73.387,59.067 73.387 L 54.400 73.387 54.400 69.973 L 54.400 66.560 59.787 66.561 C 62.749 66.562,65.520 66.659,65.944 66.776 M41.536 92.365 C 44.055 93.900,42.847 97.922,39.868 97.919 C 36.813 97.917,35.681 93.932,38.284 92.344 C 39.145 91.819,40.658 91.829,41.536 92.365 M87.662 92.533 C 88.897 93.438,89.308 95.321,88.543 96.575 C 86.534 99.870,81.510 97.251,83.188 93.784 C 84.013 92.081,86.206 91.467,87.662 92.533 "
+ stroke="none"
+ fill="rgb(239, 68, 68)"
+ fill-rule="evenodd"></path>
+ </svg>
{/if}
<div class="flex flex-col justify-center items-center w-full">
- <div
- class="text-xs font-bold text-center w-full text-warmGray-300 group-hover:text-white pb-6"
- >
- {application.Spec.Labels.configuration.publish
- .domain}{application.Spec.Labels.configuration.publish
- .path !== "/"
- ? application.Spec.Labels.configuration.publish.path
- : ""}
- </div>
- <div class="text-xs font-bold text-center w-full text-warmGray-300 group-hover:text-white">
- Last deployment<br>
- {new Intl.DateTimeFormat(
- 'default',
- $dateOptions,
- ).format(new Date(application.UpdatedAt))}
+ <div
+ class="text-xs font-bold text-center w-full text-warmGray-300 group-hover:text-white pb-6"
+ >
+ {application.Spec.Labels.configuration.publish
+ .domain}{application.Spec.Labels.configuration.publish
+ .path !== "/"
+ ? application.Spec.Labels.configuration.publish.path
+ : ""}
</div>
- </div>
+ <div
+ class="text-xs font-bold text-center w-full text-warmGray-300 group-hover:text-white"
+ >
+ Last deployment<br />
+ {new Intl.DateTimeFormat("default", $dateOptions).format(
+ new Date(application.UpdatedAt),
+ )}
+ </div>
+ </div>
</div>
</div>
</div>
diff --git a/tailwind.config.js b/tailwind.config.js
index 33603f8213..ee9a9a72ac 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -16,7 +16,7 @@ module.exports = {
],
preserveHtmlElements: true,
options: {
- safelist: [/svelte-/, 'border-green-500', 'border-yellow-300', 'border-red-500'],
+ safelist: [/svelte-/, 'border-green-500', 'border-yellow-300', 'border-red-500', 'hover:border-green-500', 'hover:border-red-200', 'hover:bg-red-200'],
defaultExtractor: (content) => {
// WARNING: tailwindExtractor is internal tailwind api
// if this breaks after a tailwind update, report to svite repo
diff --git a/vite.config.js b/vite.config.js
index 190b57a073..42e8db2b97 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -26,7 +26,8 @@ module.exports = {
'@zerodevx/svelte-toast',
'mongodb-memory-server-core',
'unique-names-generator',
- 'generate-password'
+ 'generate-password',
+ '@iarna/toml'
]
},
proxy: {