New features:
- Automatic error reporting (enabled by default)
- Increase build times by leveraging docker build caches
- 
Fixes:
- Fix error handling
- Fix vue autodetect
- Custom dockerfile is not the default

Others:
- Cleanup `logs-servers` collection, because old errors are not standardized
- New Traefik proxy version
- Standardized directory configurations
This commit is contained in:
Andras Bacsai
2021-04-19 09:46:05 +02:00
committed by GitHub
parent bad84289c4
commit 142b83cc13
51 changed files with 1300 additions and 837 deletions

View File

@@ -1,21 +1,26 @@
require('dotenv').config()
const fs = require('fs')
const util = require('util')
const axios = require('axios')
const mongoose = require('mongoose')
const path = require('path')
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' }
trustProxy: true,
logger: {
level: 'error'
}
})
const mongoose = require('mongoose')
const path = require('path')
fastify.register(require('../api/libs/http-error'))
const { schema } = require('./schema')
process.on('unhandledRejection', (reason, p) => {
console.log(reason)
console.log(p)
process.on('unhandledRejection', async (reason, p) => {
await saveServerLog({ message: reason.message, type: 'unhandledRejection' })
})
fastify.register(require('fastify-env'), {
schema,
dotenv: true
@@ -36,18 +41,6 @@ if (process.env.NODE_ENV === 'production') {
}
fastify.register(require('./app'), { prefix: '/api/v1' })
fastify.setErrorHandler(async (error, request, reply) => {
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?' })
}
try {
await saveServerLog({ event: error })
} catch (error) {
//
}
})
if (process.env.NODE_ENV === 'production') {
mongoose.connect(
@@ -91,6 +84,14 @@ mongoose.connection.once('open', async function () {
fastify.listen(3001)
console.log('Coolify API is up and running in development.')
}
try {
const { main } = (await axios.get('https://get.coollabs.io/version.json')).data.coolify
if (main.clearServerLogs) {
await mongoose.connection.db.dropCollection('logs-servers')
}
} catch (error) {
// Could not cleanup logs-servers collection
}
// On start cleanup inprogress/queued deployments.
try {
await cleanupStuckedDeploymentsInDB()
@@ -98,8 +99,8 @@ mongoose.connection.once('open', async function () {
// 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']
// Doing because I do not want to prune these images. Prune skips coolify-reserve labeled images.
const basicImages = ['nginx:stable-alpine', 'node:lts', 'ubuntu:20.04', 'php:apache', 'rust:latest']
for (const image of basicImages) {
await execShellAsync(`echo "FROM ${image}" | docker build --label coolify-reserve=true -t ${image} -`)
}