diff --git a/src/lib/buildPacks/gatsby.ts b/src/lib/buildPacks/gatsby.ts index cdf95f1dd..a10f84c43 100644 --- a/src/lib/buildPacks/gatsby.ts +++ b/src/lib/buildPacks/gatsby.ts @@ -2,7 +2,7 @@ import { buildCacheImageWithNode, buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, imageforBuild): Promise => { - const { applicationId, tag, workdir, publishDirectory, baseImage, buildId } = data; + const { applicationId, tag, workdir, publishDirectory, baseImage, buildId, port } = data; const Dockerfile: Array = []; Dockerfile.push(`FROM ${imageforBuild}`); @@ -12,7 +12,7 @@ const createDockerfile = async (data, imageforBuild): Promise => { if (baseImage.includes('nginx')) { Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); } - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/laravel.ts b/src/lib/buildPacks/laravel.ts index a83363dc0..4912a772f 100644 --- a/src/lib/buildPacks/laravel.ts +++ b/src/lib/buildPacks/laravel.ts @@ -2,7 +2,7 @@ import { buildCacheImageForLaravel, buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, image): Promise => { - const { workdir, applicationId, tag, buildId } = data; + const { workdir, applicationId, tag, buildId, port } = data; const Dockerfile: Array = []; Dockerfile.push(`FROM ${image}`); @@ -24,7 +24,7 @@ const createDockerfile = async (data, image): Promise => { `COPY --chown=application:application --from=${applicationId}:${tag}-cache /app/mix-manifest.json /app/public/mix-manifest.json` ); Dockerfile.push(`COPY --chown=application:application . ./`); - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/php.ts b/src/lib/buildPacks/php.ts index b3c9651ce..d04e86712 100644 --- a/src/lib/buildPacks/php.ts +++ b/src/lib/buildPacks/php.ts @@ -2,7 +2,7 @@ import { buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, image, htaccessFound): Promise => { - const { workdir, baseDirectory, buildId } = data; + const { workdir, baseDirectory, buildId, port } = data; const Dockerfile: Array = []; let composerFound = false; try { @@ -22,7 +22,7 @@ const createDockerfile = async (data, image, htaccessFound): Promise => { } Dockerfile.push(`COPY /entrypoint.sh /opt/docker/provision/entrypoint.d/30-entrypoint.sh`); - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/react.ts b/src/lib/buildPacks/react.ts index 3b55bfa23..5217e8f96 100644 --- a/src/lib/buildPacks/react.ts +++ b/src/lib/buildPacks/react.ts @@ -2,7 +2,7 @@ import { buildCacheImageWithNode, buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, image): Promise => { - const { applicationId, tag, workdir, publishDirectory, baseImage, buildId } = data; + const { applicationId, tag, workdir, publishDirectory, baseImage, buildId, port } = data; const Dockerfile: Array = []; Dockerfile.push(`FROM ${image}`); @@ -12,7 +12,7 @@ const createDockerfile = async (data, image): Promise => { if (baseImage.includes('nginx')) { Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); } - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/static.ts b/src/lib/buildPacks/static.ts index 8f3c2c7d4..79647ae93 100644 --- a/src/lib/buildPacks/static.ts +++ b/src/lib/buildPacks/static.ts @@ -12,7 +12,8 @@ const createDockerfile = async (data, image): Promise => { secrets, pullmergeRequestId, baseImage, - buildId + buildId, + port } = data; const Dockerfile: Array = []; @@ -42,7 +43,7 @@ const createDockerfile = async (data, image): Promise => { if (baseImage.includes('nginx')) { Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); } - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/svelte.ts b/src/lib/buildPacks/svelte.ts index 5604e7ed6..bede0e806 100644 --- a/src/lib/buildPacks/svelte.ts +++ b/src/lib/buildPacks/svelte.ts @@ -2,7 +2,7 @@ import { buildCacheImageWithNode, buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, image): Promise => { - const { applicationId, tag, workdir, publishDirectory, baseImage, buildId } = data; + const { applicationId, tag, workdir, publishDirectory, baseImage, buildId, port } = data; const Dockerfile: Array = []; Dockerfile.push(`FROM ${image}`); @@ -12,7 +12,7 @@ const createDockerfile = async (data, image): Promise => { if (baseImage.includes('nginx')) { Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); } - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/buildPacks/vuejs.ts b/src/lib/buildPacks/vuejs.ts index 5604e7ed6..bede0e806 100644 --- a/src/lib/buildPacks/vuejs.ts +++ b/src/lib/buildPacks/vuejs.ts @@ -2,7 +2,7 @@ import { buildCacheImageWithNode, buildImage } from '$lib/docker'; import { promises as fs } from 'fs'; const createDockerfile = async (data, image): Promise => { - const { applicationId, tag, workdir, publishDirectory, baseImage, buildId } = data; + const { applicationId, tag, workdir, publishDirectory, baseImage, buildId, port } = data; const Dockerfile: Array = []; Dockerfile.push(`FROM ${image}`); @@ -12,7 +12,7 @@ const createDockerfile = async (data, image): Promise => { if (baseImage.includes('nginx')) { Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); } - Dockerfile.push(`EXPOSE 80`); + Dockerfile.push(`EXPOSE ${port}`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/routes/applications/[id]/check.json.ts b/src/routes/applications/[id]/check.json.ts index f432b5dba..8c4b12af1 100644 --- a/src/routes/applications/[id]/check.json.ts +++ b/src/routes/applications/[id]/check.json.ts @@ -50,10 +50,13 @@ export const post: RequestHandler = async (event) => { exposePort = Number(exposePort); if (exposePort < 1024 || exposePort > 65535) { - throw { message: `Expose Port needs to be between 1024 and 65535` }; + throw { message: `Expose Port needs to be between 1024 and 65535.` }; } const publicPort = await getPort({ port: exposePort }); + if (publicPort !== exposePort) { + throw { message: `Port ${exposePort} is already in use.` }; + } } return { diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte index c1afa6b14..71cfa3dc3 100644 --- a/src/routes/applications/[id]/index.svelte +++ b/src/routes/applications/[id]/index.svelte @@ -62,7 +62,6 @@ let previews = application.settings.previews; let dualCerts = application.settings.dualCerts; let autodeploy = application.settings.autodeploy; - let showExposePort = application.exposePort !== null; let wsgis = [ { @@ -455,35 +454,23 @@ /> {/if} - {#if !staticDeployments.includes(application.buildPack)} + {#if application.buildPack !== 'docker'}
- { - showExposePort = !showExposePort; - application.exposePort = undefined; - }} - title={$t('application.expose_a_port')} - description="Expose a port to the host system" + + +
Useful if you would like to use your own reverse proxy or tunnel and also in development mode. Otherwise leave empty.'} />
- - {#if showExposePort} -
- - -
- {/if} {/if} {#if !notNodeDeployments.includes(application.buildPack)} -
+
@@ -521,7 +508,7 @@
{/if} {#if application.buildPack === 'docker'} -
+