Skip to content

Commit d7fd1fc

Browse files
committed
fix: next/nuxt deployment type
1 parent 6760d7e commit d7fd1fc

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

apps/api/src/routes/api/v1/applications/handlers.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function getImages(request: FastifyRequest<GetImages>) {
3434
const { buildPack, deploymentType } = request.body
3535
let publishDirectory = undefined;
3636
let port = undefined
37-
const { baseImage, baseBuildImage, baseBuildImages, baseImages, } = setDefaultBaseImage(
37+
const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage(
3838
buildPack, deploymentType
3939
);
4040
if (buildPack === 'nextjs') {
@@ -56,8 +56,7 @@ export async function getImages(request: FastifyRequest<GetImages>) {
5656
}
5757
}
5858

59-
60-
return { baseBuildImage, baseBuildImages, publishDirectory, port }
59+
return { baseImage, baseImages, baseBuildImage, baseBuildImages, publishDirectory, port }
6160
} catch ({ status, message }) {
6261
return errorHandler({ status, message })
6362
}
@@ -232,7 +231,6 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
232231
baseBuildImage,
233232
deploymentType
234233
} = request.body
235-
236234
if (port) port = Number(port);
237235
if (exposePort) {
238236
exposePort = Number(exposePort);

apps/ui/src/routes/applications/[id]/index.svelte

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,30 @@
114114
buildPack: application.buildPack,
115115
deploymentType: application.deploymentType
116116
});
117-
application = {
118-
...application,
119-
...data
120-
};
117+
const baseImageCorrect = data.baseImages.filter(
118+
(image: any) => image.value === application.baseImage
119+
);
120+
if (baseImageCorrect.length === 0) {
121+
application.baseImage = data.baseImage;
122+
}
123+
application.baseImages = data.baseImages;
124+
125+
const baseBuildImageCorrect = data.baseBuildImages.filter(
126+
(image: any) => image.value === application.baseBuildImage
127+
);
128+
if (baseBuildImageCorrect.length === 0) {
129+
application.baseBuildImage = data.baseBuildImage;
130+
}
131+
application.baseBuildImages = data.baseBuildImages;
132+
if (application.deploymentType === 'static' && application.port !== '80') {
133+
application.port = data.port;
134+
}
135+
if (application.deploymentType === 'node' && application.port === '80') {
136+
application.port = data.port;
137+
}
138+
if (!application.publishDirectory) {
139+
application.publishDirectory = data.publishDirectory;
140+
}
121141
}
122142
async function changeSettings(name: any) {
123143
if (name === 'debug') {
@@ -631,9 +651,7 @@
631651
bind:value={application.port}
632652
placeholder="{$t('forms.default')}: 'python' ? '8000' : '3000'"
633653
/>
634-
<Explainer
635-
text={'The port your application listens on.'}
636-
/>
654+
<Explainer text={'The port your application listens on.'} />
637655
</div>
638656
{/if}
639657
<div class="grid grid-cols-2 items-center">

0 commit comments

Comments
 (0)