fixes
This commit is contained in:
parent
12c0760cb3
commit
a129be0dbd
@ -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));
|
||||
|
@ -179,24 +179,40 @@
|
||||
if ($status.application.statuses.length === 0) {
|
||||
$status.application.overallStatus = 'stopped';
|
||||
} else {
|
||||
if ($status.application.statuses.length !== numberOfApplications) {
|
||||
$status.application.overallStatus = 'degraded';
|
||||
} else {
|
||||
for (const oneStatus of $status.application.statuses) {
|
||||
if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
|
||||
$status.application.overallStatus = 'degraded';
|
||||
break;
|
||||
}
|
||||
if (oneStatus.status.isRunning) {
|
||||
$status.application.overallStatus = 'healthy';
|
||||
}
|
||||
if (
|
||||
!oneStatus.status.isExited &&
|
||||
!oneStatus.status.isRestarting &&
|
||||
!oneStatus.status.isRunning
|
||||
) {
|
||||
$status.application.overallStatus = 'stopped';
|
||||
}
|
||||
// if ($status.application.statuses.length !== numberOfApplications) {
|
||||
// $status.application.overallStatus = 'degraded';
|
||||
// } else {
|
||||
// for (const oneStatus of $status.application.statuses) {
|
||||
// if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
|
||||
// $status.application.overallStatus = 'degraded';
|
||||
// break;
|
||||
// }
|
||||
// if (oneStatus.status.isRunning) {
|
||||
// $status.application.overallStatus = 'healthy';
|
||||
// }
|
||||
// if (
|
||||
// !oneStatus.status.isExited &&
|
||||
// !oneStatus.status.isRestarting &&
|
||||
// !oneStatus.status.isRunning
|
||||
// ) {
|
||||
// $status.application.overallStatus = 'stopped';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (const oneStatus of $status.application.statuses) {
|
||||
if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
|
||||
$status.application.overallStatus = 'degraded';
|
||||
break;
|
||||
}
|
||||
if (oneStatus.status.isRunning) {
|
||||
$status.application.overallStatus = 'healthy';
|
||||
}
|
||||
if (
|
||||
!oneStatus.status.isExited &&
|
||||
!oneStatus.status.isRestarting &&
|
||||
!oneStatus.status.isRunning
|
||||
) {
|
||||
$status.application.overallStatus = 'stopped';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,30 +312,6 @@
|
||||
await getGitlabToken();
|
||||
}
|
||||
scanRepository(isPublicRepository);
|
||||
// let htmlUrl = application.gitSource.htmlUrl;
|
||||
// const left = screen.width / 2 - 1020 / 2;
|
||||
// const top = screen.height / 2 - 618 / 2;
|
||||
// const newWindow = open(
|
||||
// `${htmlUrl}/oauth/authorize?client_id=${
|
||||
// application.gitSource.gitlabApp.appId
|
||||
// }&redirect_uri=${getAPIUrl()}/webhooks/gitlab&response_type=code&scope=api+email+read_repository&state=${
|
||||
// $page.params.id
|
||||
// }`,
|
||||
// 'GitLab',
|
||||
// 'resizable=1, scrollbars=1, fullscreen=0, height=618, width=1020,top=' +
|
||||
// top +
|
||||
// ', left=' +
|
||||
// left +
|
||||
// ', toolbar=0, menubar=0, status=0'
|
||||
// );
|
||||
// const timer = setInterval(() => {
|
||||
// if (newWindow?.closed) {
|
||||
// clearInterval(timer);
|
||||
// $appSession.tokens.gitlab = localStorage.getItem('gitLabToken');
|
||||
// // localStorage.removeItem('gitLabToken' );
|
||||
|
||||
// }
|
||||
// }, 100);
|
||||
}
|
||||
} else if (error.message === 'Bad credentials') {
|
||||
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
||||
|
@ -54,7 +54,7 @@
|
||||
<div class="w-full">
|
||||
<div class="mx-auto w-full">
|
||||
<div class="flex flex-row border-b border-coolgray-500 mb-6 space-x-2">
|
||||
<div class="title font-bold pb-3">Revert Application</div>
|
||||
<div class="title font-bold pb-3">Revert</div>
|
||||
</div>
|
||||
<div>
|
||||
You can revert application to a previously built image. Currently only locally stored images
|
||||
@ -67,53 +67,60 @@
|
||||
>
|
||||
feature <a href={`/applications/${id}/features`}>here</a>.
|
||||
</div>
|
||||
<div
|
||||
class="px-4 lg:pb-10 pb-6 flex flex-wrap items-center justify-center lg:justify-start gap-8"
|
||||
>
|
||||
{#each imagesAvailables as image}
|
||||
<div class="gap-2 py-4 m-2">
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<div class="text-xl font-bold">
|
||||
{image.tag}
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
class="flex no-underline text-xs my-4"
|
||||
href="{application.gitSource.htmlUrl}/{application.repository}/commit/{image.tag}"
|
||||
target="_blank noreferrer"
|
||||
>
|
||||
<button class="btn btn-sm">
|
||||
Check Commit
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="3"
|
||||
stroke="currentColor"
|
||||
class="w-3 h-3 text-white ml-2"
|
||||
{#if imagesAvailables.length > 0}
|
||||
<div
|
||||
class="px-4 lg:pb-10 pb-6 flex flex-wrap items-center justify-center lg:justify-start gap-8"
|
||||
>
|
||||
{#each imagesAvailables as image}
|
||||
<div class="gap-2 py-4 m-2">
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<div class="text-xl font-bold">
|
||||
{image.tag}
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
class="flex no-underline text-xs my-4"
|
||||
href="{application.gitSource.htmlUrl}/{application.repository}/commit/{image.tag}"
|
||||
target="_blank noreferrer"
|
||||
>
|
||||
<button class="btn btn-sm">
|
||||
Check Commit
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="3"
|
||||
stroke="currentColor"
|
||||
class="w-3 h-3 text-white ml-2"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M4.5 19.5l15-15m0 0H8.25m11.25 0v11.25"
|
||||
/>
|
||||
</svg>
|
||||
</button></a
|
||||
>
|
||||
{#if image.repository + ':' + image.tag !== runningImage}
|
||||
<button
|
||||
class="btn btn-sm btn-primary w-full"
|
||||
on:click={() => revertApplication(image)}>Revert Now</button
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M4.5 19.5l15-15m0 0H8.25m11.25 0v11.25"
|
||||
/>
|
||||
</svg>
|
||||
</button></a
|
||||
>
|
||||
{#if image.repository + ':' + image.tag !== runningImage}
|
||||
<button
|
||||
class="btn btn-sm btn-primary w-full"
|
||||
on:click={() => revertApplication(image)}>Revert Now</button
|
||||
>
|
||||
{:else}
|
||||
<button class="btn btn-sm btn-primary w-full btn-disabled bg-transparent underline"
|
||||
>Currently Used</button
|
||||
>
|
||||
{/if}
|
||||
{:else}
|
||||
<button
|
||||
class="btn btn-sm btn-primary w-full btn-disabled bg-transparent underline"
|
||||
>Currently Used</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<div class="text-xl font-bold">No images available</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -35,6 +35,9 @@
|
||||
if (service?.volumes) {
|
||||
for (const [_, volumeName] of Object.entries(service.volumes)) {
|
||||
let [volume, target] = volumeName.split(':');
|
||||
if (volume === '.') {
|
||||
volume = target;
|
||||
}
|
||||
if (!target) {
|
||||
target = volume;
|
||||
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`;
|
||||
|
Loading…
Reference in New Issue
Block a user