Andras Bacsai b416e3ab3e
v1.0.10 (#39)
Fixes: 
- Default Nuxt port changed to 3000 (thanks to @yurgeman).
- Cleanup old images effectively.
- More attempts on container startups (3->6).
- Always clean up server logs on restart/redeploy.
2021-04-26 11:45:04 +02:00

28 lines
1.1 KiB
JavaScript

const dayjs = require('dayjs')
const { saveAppLog } = require('../logging')
const copyFiles = require('./deploy/copyFiles')
const buildContainer = require('./build/container')
const deploy = require('./deploy/deploy')
const Deployment = require('../../models/Deployment')
const { updateServiceLabels } = require('./configuration')
async function queueAndBuild (configuration, imageChanged) {
const { id, organization, name, branch } = configuration.repository
const { domain } = configuration.publish
const { deployId, nickname } = configuration.general
await new Deployment({
repoId: id, branch, deployId, domain, organization, name, nickname
}).save()
await saveAppLog(`${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} Queued.`, configuration)
await copyFiles(configuration)
await buildContainer(configuration)
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)
}
module.exports = { queueAndBuild }