mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-27 12:33:54 +00:00
fixes
This commit is contained in:
@@ -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