From 0922fd66a4807cd5d9688cdfcce207ad3f850469 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Aug 2022 16:33:32 +0200 Subject: [PATCH] feat: force rebuild + env.PORT for port + public repo build --- apps/api/src/jobs/deployApplication.ts | 8 +- apps/api/src/lib/common.ts | 2 - apps/api/src/lib/docker.ts | 1 - .../routes/api/v1/applications/handlers.ts | 8 +- .../src/routes/api/v1/applications/types.ts | 5 +- .../routes/applications/[id]/__layout.svelte | 11 +- .../[id]/configuration/_BuildPack.svelte | 2 +- .../configuration/_PublicRepository.svelte | 209 +++++++++++----- .../[id]/configuration/buildpack.svelte | 1 - .../[id]/configuration/source.svelte | 231 +++++++++--------- .../src/routes/applications/[id]/index.svelte | 5 +- 11 files changed, 286 insertions(+), 197 deletions(-) diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts index 4db0d5e26..9259e3976 100644 --- a/apps/api/src/jobs/deployApplication.ts +++ b/apps/api/src/jobs/deployApplication.ts @@ -56,6 +56,7 @@ import * as buildpacks from '../lib/buildPacks'; baseImage, baseBuildImage, deploymentType, + forceRebuild } = message let { branch, @@ -174,7 +175,6 @@ import * as buildpacks from '../lib/buildPacks'; if (!pullmergeRequestId) { - if (configHash !== currentHash) { deployNeeded = true; if (configHash) { @@ -198,6 +198,8 @@ import * as buildpacks from '../lib/buildPacks'; // } await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage); + + if (forceRebuild) deployNeeded = true if (!imageFound || deployNeeded) { // if (true) { if (buildpacks[buildPack]) @@ -248,7 +250,9 @@ import * as buildpacks from '../lib/buildPacks'; } catch (error) { // } - const envs = []; + const envs = [ + `PORT=${port}` + ]; if (secrets.length > 0) { secrets.forEach((secret) => { if (pullmergeRequestId) { diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 78a23eb2b..9533b9473 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -1189,9 +1189,7 @@ export async function checkExposedPort({ id, configuredPort, exposePort, dockerI } } } else { - const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress); -console.log(availablePort, exposePort) if (availablePort.toString() !== exposePort.toString()) { throw { status: 500, message: `Port ${exposePort} is already in use.` } } diff --git a/apps/api/src/lib/docker.ts b/apps/api/src/lib/docker.ts index aa6a29cfd..c1ae977e5 100644 --- a/apps/api/src/lib/docker.ts +++ b/apps/api/src/lib/docker.ts @@ -71,7 +71,6 @@ export async function removeContainer({ }): Promise { try { const { stdout } = await executeDockerCmd({ dockerId, command: `docker inspect --format '{{json .State}}' ${id}` }) - console.log(id) if (JSON.parse(stdout).Running) { await executeDockerCmd({ dockerId, command: `docker stop -t 0 ${id}` }) await executeDockerCmd({ dockerId, command: `docker rm ${id}` }) diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index 7ddeb6b1c..57da91478 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -428,7 +428,7 @@ export async function deployApplication(request: FastifyRequest { @@ -256,7 +255,7 @@ -
+ handleDeploySubmit(true)}> - {#if branchSelectOptions.length > 0} -
- + {#if branchSelectOptions.length > 0} +
+ +
{/if}