An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Merged upstream and fixed expose port implementation
Aaron Stylesc98ed5338a7f
diff --cc pnpm-lock.yamlindex b87591e818,9c608add78..c0e8a2bd91--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@@ -608,28 -568,9 +588,28 @@@ packagesintegrity: sha512-iZUcRrGuz/Tbg3loODpW7vrQJkUtpY2fFSf4ELqqkApcS2TkZ1msk7ie8iZPB86lDOP8QOTTmuvWjc5S0R9OjQ==}dependencies:- '@types/node': 17.0.23+ '@types/node': 17.0.25dev: true+ /@types/ssh2-streams/0.1.9:+ resolution:+ {+ integrity: sha512-I2J9jKqfmvXLR5GomDiCoHrEJ58hAOmFrekfFqmCFd+A6gaEStvWnPykoWUwld1PNg4G5ag1LwdA+Lz1doRJqg==+ }+ dependencies:+ '@types/node': 17.0.23+ dev: true++ /@types/ssh2/0.5.52:+ resolution:+ {+ integrity: sha512-lbLLlXxdCZOSJMCInKH2+9V/77ET2J6NPQHpFI0kda61Dd1KglJs+fPQBchizmzYSOJBgdTajhPqBO1xxLywvg==+ }+ dependencies:+ '@types/node': 17.0.23+ '@types/ssh2-streams': 0.1.9+ dev: true+/@typescript-eslint/eslint-plugin/4.31.1_8ede7edd7694646e12d33c52460f622c:resolution:{diff --cc src/lib/database/applications.tsindex 7177d01368,d57e3f3e59..de8a7e75eb--- a/src/lib/database/applications.ts+++ b/src/lib/database/applications.ts@@@ -242,8 -263,28 +264,29 @@@ export async function configureApplicatpublishDirectory,pythonWSGI,pythonModule,- pythonVariable- }) {+ pythonVariable,+ dockerFileLocation,+ denoMainFile,+ denoOptions+ }: {+ id: string;+ buildPack: string;+ name: string;+ fqdn: string;+ port: number;++ exposePort: number;+ installCommand: string;+ buildCommand: string;+ startCommand: string;+ baseDirectory: string;+ publishDirectory: string;+ pythonWSGI: string;+ pythonModule: string;+ pythonVariable: string;+ dockerFileLocation: string;+ denoMainFile: string;+ denoOptions: string;+ }): Promise<Application> {return await prisma.application.update({where: { id },data: {diff --cc src/lib/queues/builder.tsindex 699ed4ed6e,8e1650106c..a6cf0af753--- a/src/lib/queues/builder.ts+++ b/src/lib/queues/builder.ts@@@ -52,7 -46,20 +46,21 @@@ export default async function (job: JobpersistentStorage,pythonWSGI,pythonModule,- pythonVariable+ pythonVariable,- denoOptions++ denoOptions,++ exposePort+ } = job.data;+ let {+ branch,+ buildPack,+ port,+ installCommand,+ buildCommand,+ startCommand,+ baseDirectory,+ publishDirectory,+ dockerFileLocation,+ denoMainFile} = job.data;const { debug } = settings;@@@ -179,6 -187,6 +189,7 @@@}if (!imageFound || deployNeeded) {await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId);++ console.log(exposePort ? `${exposePort}:${port}` : port);if (buildpacks[buildPack])await buildpacks[buildPack]({buildId,@@@ -197,7 -205,7 +208,7 @@@tag,workdir,docker,-- port,++ port: exposePort ? `${exposePort}:${port}` : port,installCommand,buildCommand,startCommand,@@@ -250,7 -259,7 +262,7 @@@repository,branch,projectId,-- port,++ port: exposePort ? `${exposePort}:${port}` : port,commit,installCommand,buildCommand,@@@ -282,10 -291,20 +294,21 @@@volumes,env_file: envFound ? [`${workdir}/.env`] : [],networks: [docker.network],- ports: exposePort ? [`${exposePort}:${port}`] : [],labels,depends_on: [],- restart: 'always'+ restart: 'always',++ ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),+ // logging: {+ // driver: 'fluentd',+ // },+ deploy: {+ restart_policy: {+ condition: 'on-failure',+ delay: '5s',+ max_attempts: 3,+ window: '120s'+ }+ }}},networks: {diff --cc src/lib/types/builderJob.tsindex 0000000000,8b7cc3b9f8..606a57ece5mode 000000,100644..100644--- a/src/lib/types/builderJob.ts+++ b/src/lib/types/builderJob.ts@@@ -1,0 -1,54 +1,55 @@@+ import type { DestinationDocker, GithubApp, GitlabApp, GitSource, Secret } from '@prisma/client';++ export type BuilderJob = {+ build_id: string;+ type: BuildType;+ id: string;+ name: string;+ fqdn: string;+ repository: string;+ configHash: unknown;+ branch: string;+ buildPack: BuildPackName;+ projectId: number;+ port: number;++ exposePort?: number;+ installCommand: string;+ buildCommand?: string;+ startCommand?: string;+ baseDirectory: string;+ publishDirectory: string;+ phpModules: string;+ pythonWSGI: string;+ pythonModule: string;+ pythonVariable: string;+ dockerFileLocation: string;+ denoMainFile: string;+ denoOptions: string;+ createdAt: string;+ updatedAt: string;+ destinationDockerId: string;+ destinationDocker: DestinationDocker;+ gitSource: GitSource & { githubApp?: GithubApp; gitlabApp?: GitlabApp };+ settings: BuilderJobSettings;+ secrets: Secret[];+ persistentStorage: { path: string }[];+ pullmergeRequestId?: unknown;+ sourceBranch?: string;+ };++ // TODO: Add the other build types+ export type BuildType = 'manual';++ // TODO: Add the other buildpack names+ export type BuildPackName = 'node' | 'docker';++ export type BuilderJobSettings = {+ id: string;+ applicationId: string;+ dualCerts: boolean;+ debug: boolean;+ previews: boolean;+ autodeploy: boolean;+ createdAt: string;+ updatedAt: string;+ };diff --cc src/lib/types/composeFile.tsindex 1e2a0723c3,33dfbdd43c..724a53b69a--- a/src/lib/types/composeFile.ts+++ b/src/lib/types/composeFile.ts@@@ -18,6 -18,6 +18,7 @@@ export type ComposeFileService =restart: ComposeFileRestartOption;depends_on?: string[];command?: string;++ ports?: string[];build?: {context: string;dockerfile: string;diff --cc src/routes/applications/[id]/check.json.tsindex 56ea05ee1f,c15fd8bab0..db794e9bd4--- a/src/routes/applications/[id]/check.json.ts+++ b/src/routes/applications/[id]/check.json.ts@@@ -4,7 -4,7 +4,8 @@@ import * as db from '$lib/database'import { ErrorHandler } from '$lib/database';import type { RequestHandler } from '@sveltejs/kit';import { promises as dns } from 'dns';+import getPort from 'get-port';+ import { t } from '$lib/translations';export const post: RequestHandler = async (event) => {const { status, body } = await getUserDetails(event);diff --cc src/routes/applications/[id]/index.json.tsindex 4b9e88d79c,ef9f57dcb9..560ec21e7c--- a/src/routes/applications/[id]/index.json.ts+++ b/src/routes/applications/[id]/index.json.ts@@@ -58,16 -59,13 +61,16 @@@ export const post: RequestHandler = asypublishDirectory,pythonWSGI,pythonModule,- pythonVariable+ pythonVariable,+ dockerFileLocation,+ denoMainFile,+ denoOptions} = await event.request.json();if (port) port = Number(port);+ if (exposePort) {+ exposePort = Number(exposePort);- const publicPort = await getPort({ port: exposePort });- if (exposePort !== publicPort) {- exposePort = -1;- }+ }+ if (denoOptions) denoOptions = denoOptions.trim();try {const defaultConfiguration = await setDefaultConfiguration({diff --cc src/routes/applications/[id]/index.svelteindex c7c0ca125d,359cdc5a36..07bcd4f36e--- a/src/routes/applications/[id]/index.svelte+++ b/src/routes/applications/[id]/index.svelte@@@ -125,15 -122,12 +122,16 @@@async function handleSubmit() {loading = true;try {- await post(`/applications/${id}/check.json`, { fqdn: application.fqdn, forceSave });+ await post(`/applications/${id}/check.json`, {+ fqdn: application.fqdn,+ forceSave,+ exposePort: application.exposePort+ });await post(`/applications/${id}.json`, { ...application });- return window.location.reload();+ $disabledButton = false;+ return toast.push('Configurations saved.');} catch ({ error }) {- if (error?.startsWith('DNS not set')) {+ if (error?.startsWith($t('application.dns_not_set_partial_error'))) {forceSave = true;}return errorNotification(error);@@@ -176,6 -170,6 +174,29 @@@</svg></a>{/if}++++ {#if application.exposePort}++ <a++ href={`${window.location.origin.split(':').slice(0, 2).join(':')}:${application.exposePort}`}++ target="_blank"++ class="icons tooltip-bottom flex items-center bg-transparent text-sm"++ ><svg++ xmlns="http://www.w3.org/2000/svg"++ class="h-6 w-6"++ viewBox="0 0 24 24"++ stroke-width="1.5"++ stroke="currentColor"++ fill="none"++ stroke-linecap="round"++ stroke-linejoin="round"++ >++ <path stroke="none" d="M0 0h24v24H0z" fill="none" />++ <path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />++ <line x1="10" y1="14" x2="20" y2="4" />++ <polyline points="15 4 20 4 20 9" />++ </svg></a++ >++ {/if}<ahref="{application.gitSource.htmlUrl}/{application.repository}/tree/{application.branch}"target="_blank"