fixes
This commit is contained in:
@@ -272,7 +272,7 @@ async function initServer() {
|
||||
} catch (error) { }
|
||||
try {
|
||||
console.log('[003] Cleaning up old build sources under /tmp/build-sources/...');
|
||||
await fs.rm('/tmp/build-sources', { recursive: true, force: true })
|
||||
if (!isDev) await fs.rm('/tmp/build-sources', { recursive: true, force: true })
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
@@ -198,7 +198,7 @@ import * as buildpacks from '../lib/buildPacks';
|
||||
if (configHash !== currentHash) {
|
||||
deployNeeded = true;
|
||||
if (configHash) {
|
||||
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId });
|
||||
await saveBuildLog({ line: 'Configuration changed', buildId, applicationId });
|
||||
}
|
||||
} else {
|
||||
deployNeeded = false;
|
||||
|
@@ -109,7 +109,7 @@ export default async function (data) {
|
||||
dockerComposeYaml['networks'] = Object.assign({ ...networks }, { [network]: { external: true } })
|
||||
await fs.writeFile(fileYaml, yaml.dump(dockerComposeYaml));
|
||||
await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker compose --project-directory ${workdir} pull` })
|
||||
await saveBuildLog({ line: 'Pulling images from Compose file.', buildId, applicationId });
|
||||
await saveBuildLog({ line: 'Pulling images from Compose file', buildId, applicationId });
|
||||
await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker compose --project-directory ${workdir} build --progress plain` })
|
||||
await saveBuildLog({ line: 'Building images from Compose file.', buildId, applicationId });
|
||||
await saveBuildLog({ line: 'Building images from Compose file', buildId, applicationId });
|
||||
}
|
||||
|
@@ -692,30 +692,39 @@ export async function getDockerImages(request) {
|
||||
const { id } = request.params
|
||||
const teamId = request.user?.teamId;
|
||||
const application: any = await getApplicationFromDB(id, teamId);
|
||||
const { stdout } = await executeDockerCmd({ dockerId: application.destinationDocker.id, command: `docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}' | grep -i ${id} | grep -v cache` });
|
||||
const { stdout: runningImage } = await executeDockerCmd({ dockerId: application.destinationDocker.id, command: `docker ps -a --filter 'label=com.docker.compose.service=${id}' --format {{.Image}}` });
|
||||
const images = stdout.trim().split('\n');
|
||||
let imagesAvailables = [];
|
||||
for (const image of images) {
|
||||
const [repository, tag, createdAt] = image.split('#');
|
||||
if (tag.includes('-')) {
|
||||
continue;
|
||||
try {
|
||||
const { stdout } = await executeDockerCmd({ dockerId: application.destinationDocker.id, command: `docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}' | grep -i ${id} | grep -v cache` });
|
||||
const { stdout: runningImage } = await executeDockerCmd({ dockerId: application.destinationDocker.id, command: `docker ps -a --filter 'label=com.docker.compose.service=${id}' --format {{.Image}}` });
|
||||
const images = stdout.trim().split('\n');
|
||||
|
||||
for (const image of images) {
|
||||
const [repository, tag, createdAt] = image.split('#');
|
||||
if (tag.includes('-')) {
|
||||
continue;
|
||||
}
|
||||
const [year, time] = createdAt.split(' ');
|
||||
imagesAvailables.push({
|
||||
repository,
|
||||
tag,
|
||||
createdAt: day(year + time).unix()
|
||||
})
|
||||
}
|
||||
|
||||
imagesAvailables = imagesAvailables.sort((a, b) => b.tag - a.tag);
|
||||
|
||||
return {
|
||||
imagesAvailables,
|
||||
runningImage
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
imagesAvailables,
|
||||
}
|
||||
const [year, time] = createdAt.split(' ');
|
||||
imagesAvailables.push({
|
||||
repository,
|
||||
tag,
|
||||
createdAt: day(year + time).unix()
|
||||
})
|
||||
}
|
||||
|
||||
imagesAvailables = imagesAvailables.sort((a, b) => b.tag - a.tag);
|
||||
|
||||
return {
|
||||
imagesAvailables,
|
||||
runningImage
|
||||
}
|
||||
} catch ({ status, message }) {
|
||||
|
||||
return errorHandler({ status, message })
|
||||
}
|
||||
}
|
||||
|
@@ -45,7 +45,6 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||
fastify.get<RestartPreviewApplication>('/:id/previews/:pullmergeRequestId/status', async (request) => await getPreviewStatus(request));
|
||||
fastify.post<RestartPreviewApplication>('/:id/previews/:pullmergeRequestId/restart', async (request, reply) => await restartPreview(request, reply));
|
||||
|
||||
// fastify.get<GetApplicationLogs>('/:id/logs', async (request) => await getApplicationLogs(request));
|
||||
fastify.get<GetApplicationLogs>('/:id/logs/:containerId', async (request) => await getApplicationLogs(request));
|
||||
fastify.get<GetBuilds>('/:id/logs/build', async (request) => await getBuilds(request));
|
||||
fastify.get<GetBuildIdLogs>('/:id/logs/build/:buildId', async (request) => await getBuildIdLogs(request));
|
||||
|
Reference in New Issue
Block a user