Merge pull request #318 from CharcoalStyles/exposePort

Added expose port for applications
This commit is contained in:
Andras Bacsai 2022-05-04 15:45:16 +02:00 committed by GitHub
commit 90fde24b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 249 additions and 39 deletions

39
pnpm-lock.yaml generated
View File

@ -494,6 +494,26 @@ packages:
'@types/responselike': 1.0.0 '@types/responselike': 1.0.0
dev: false dev: false
/@types/docker-modem/3.0.2:
resolution:
{
integrity: sha512-qC7prjoEYR2QEe6SmCVfB1x3rfcQtUr1n4x89+3e0wSTMQ/KYCyf+/RAA9n2tllkkNc6//JMUZePdFRiGIWfaQ==
}
dependencies:
'@types/node': 17.0.23
'@types/ssh2': 0.5.52
dev: true
/@types/dockerode/3.3.8:
resolution:
{
integrity: sha512-/Hip29GzPBWfbSS87lyQDVoB7Ja+kr8oOFWXsySxNFa7jlyj3Yws8LaZRmn1xZl7uJH3Xxsg0oI09GHpT1pIBw==
}
dependencies:
'@types/docker-modem': 3.0.2
'@types/node': 17.0.23
dev: true
/@types/http-cache-semantics/4.0.1: /@types/http-cache-semantics/4.0.1:
resolution: resolution:
{ {
@ -571,6 +591,25 @@ packages:
'@types/node': 17.0.25 '@types/node': 17.0.25
dev: true dev: 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: /@typescript-eslint/eslint-plugin/4.31.1_8ede7edd7694646e12d33c52460f622c:
resolution: resolution:
{ {

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Application" ADD COLUMN "exposePort" INTEGER;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Service" ADD COLUMN "exposePort" INTEGER;

View File

@ -84,6 +84,7 @@ model Application {
buildPack String? buildPack String?
projectId Int? projectId Int?
port Int? port Int?
exposePort Int?
installCommand String? installCommand String?
buildCommand String? buildCommand String?
startCommand String? startCommand String?
@ -289,6 +290,7 @@ model Service {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
fqdn String? fqdn String?
exposePort Int?
dualCerts Boolean @default(false) dualCerts Boolean @default(false)
type String? type String?
version String? version String?

View File

@ -215,3 +215,11 @@ export const supportedServiceTypesAndVersions = [
} }
} }
]; ];
export const getServiceMainPort = (service: string) => {
const serviceType = supportedServiceTypesAndVersions.find((s) => s.name === service);
if (serviceType) {
return serviceType.ports.main;
}
return null;
};

View File

@ -278,6 +278,7 @@ export async function configureApplication({
name, name,
fqdn, fqdn,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
@ -297,6 +298,7 @@ export async function configureApplication({
name: string; name: string;
fqdn: string; fqdn: string;
port: number; port: number;
exposePort: number;
installCommand: string; installCommand: string;
buildCommand: string; buildCommand: string;
startCommand: string; startCommand: string;
@ -318,6 +320,7 @@ export async function configureApplication({
buildPack, buildPack,
fqdn, fqdn,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,

View File

@ -327,35 +327,40 @@ export async function updatePlausibleAnalyticsService({
id, id,
fqdn, fqdn,
email, email,
exposePort,
username, username,
name name
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
exposePort?: number;
name: string; name: string;
email: string; email: string;
username: string; username: string;
}): Promise<void> { }): Promise<void> {
await prisma.plausibleAnalytics.update({ where: { serviceId: id }, data: { email, username } }); await prisma.plausibleAnalytics.update({ where: { serviceId: id }, data: { email, username } });
await prisma.service.update({ where: { id }, data: { name, fqdn } }); await prisma.service.update({ where: { id }, data: { name, fqdn, exposePort } });
} }
export async function updateService({ export async function updateService({
id, id,
fqdn, fqdn,
exposePort,
name name
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
exposePort?: number;
name: string; name: string;
}): Promise<Service> { }): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name } }); return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
} }
export async function updateFiderService({ export async function updateFiderService({
id, id,
fqdn, fqdn,
name, name,
exposePort,
emailNoreply, emailNoreply,
emailMailgunApiKey, emailMailgunApiKey,
emailMailgunDomain, emailMailgunDomain,
@ -368,6 +373,7 @@ export async function updateFiderService({
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
exposePort?: number;
name: string; name: string;
emailNoreply: string; emailNoreply: string;
emailMailgunApiKey: string; emailMailgunApiKey: string;
@ -384,6 +390,7 @@ export async function updateFiderService({
data: { data: {
fqdn, fqdn,
name, name,
exposePort,
fider: { fider: {
update: { update: {
emailNoreply, emailNoreply,
@ -405,18 +412,20 @@ export async function updateWordpress({
id, id,
fqdn, fqdn,
name, name,
exposePort,
mysqlDatabase, mysqlDatabase,
extraConfig extraConfig
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
name: string; name: string;
exposePort?: number;
mysqlDatabase: string; mysqlDatabase: string;
extraConfig: string; extraConfig: string;
}): Promise<Service> { }): Promise<Service> {
return await prisma.service.update({ return await prisma.service.update({
where: { id }, where: { id },
data: { fqdn, name, wordpress: { update: { mysqlDatabase, extraConfig } } } data: { fqdn, name, exposePort, wordpress: { update: { mysqlDatabase, extraConfig } } }
}); });
} }
@ -434,16 +443,18 @@ export async function updateGhostService({
id, id,
fqdn, fqdn,
name, name,
exposePort,
mariadbDatabase mariadbDatabase
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
name: string; name: string;
exposePort?: number;
mariadbDatabase: string; mariadbDatabase: string;
}): Promise<Service> { }): Promise<Service> {
return await prisma.service.update({ return await prisma.service.update({
where: { id }, where: { id },
data: { fqdn, name, ghost: { update: { mariadbDatabase } } } data: { fqdn, name, exposePort, ghost: { update: { mariadbDatabase } } }
}); });
} }

View File

@ -204,6 +204,7 @@
"enable_automatic_deployment": "Enable Automatic Deployment", "enable_automatic_deployment": "Enable Automatic Deployment",
"enable_auto_deploy_webhooks": "Enable automatic deployment through webhooks.", "enable_auto_deploy_webhooks": "Enable automatic deployment through webhooks.",
"enable_mr_pr_previews": "Enable MR/PR Previews", "enable_mr_pr_previews": "Enable MR/PR Previews",
"expose_a_port": "Expose a port",
"enable_preview_deploy_mr_pr_requests": "Enable preview deployments from pull or merge requests.", "enable_preview_deploy_mr_pr_requests": "Enable preview deployments from pull or merge requests.",
"debug_logs": "Debug Logs", "debug_logs": "Debug Logs",
"enable_debug_log_during_build": "Enable debug logs during build phase.<br><span class='text-red-500 font-bold'>Sensitive information</span> could be visible and saved in logs.", "enable_debug_log_during_build": "Enable debug logs during build phase.<br><span class='text-red-500 font-bold'>Sensitive information</span> could be visible and saved in logs.",

View File

@ -61,6 +61,7 @@
"enable_debug_log_during_build": "Activez les journaux de débogage pendant la phase de build.<br><span class='text-red-500 font-bold'>Les informations sensibles</span> peuvent être visibles et enregistrées dans les journaux.", "enable_debug_log_during_build": "Activez les journaux de débogage pendant la phase de build.<br><span class='text-red-500 font-bold'>Les informations sensibles</span> peuvent être visibles et enregistrées dans les journaux.",
"enable_mr_pr_previews": "Activer les aperçus MR/PR", "enable_mr_pr_previews": "Activer les aperçus MR/PR",
"enable_preview_deploy_mr_pr_requests": "Activez les déploiements de prévisualisation à partir de demandes d'extraction ou de fusion.", "enable_preview_deploy_mr_pr_requests": "Activez les déploiements de prévisualisation à partir de demandes d'extraction ou de fusion.",
"expose_a_port": "Exposer un port",
"features": "Caractéristiques", "features": "Caractéristiques",
"git_repository": "Dépôt Git", "git_repository": "Dépôt Git",
"git_source": "Source Git", "git_source": "Source Git",

View File

@ -48,6 +48,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
pythonModule, pythonModule,
pythonVariable, pythonVariable,
denoOptions, denoOptions,
exposePort,
baseImage, baseImage,
baseBuildImage baseBuildImage
} = job.data; } = job.data;
@ -152,6 +153,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
JSON.stringify({ JSON.stringify({
buildPack, buildPack,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
@ -207,7 +209,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
tag, tag,
workdir, workdir,
docker, docker,
port, port: exposePort ? `${exposePort}:${port}` : port,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
@ -263,7 +265,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
repository, repository,
branch, branch,
projectId, projectId,
port, port: exposePort ? `${exposePort}:${port}` : port,
commit, commit,
installCommand, installCommand,
buildCommand, buildCommand,
@ -298,6 +300,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
labels, labels,
depends_on: [], depends_on: [],
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
// logging: { // logging: {
// driver: 'fluentd', // driver: 'fluentd',
// }, // },

View File

@ -12,6 +12,7 @@ export type BuilderJob = {
buildPack: BuildPackName; buildPack: BuildPackName;
projectId: number; projectId: number;
port: number; port: number;
exposePort?: number;
installCommand: string; installCommand: string;
buildCommand?: string; buildCommand?: string;
startCommand?: string; startCommand?: string;

View File

@ -18,6 +18,7 @@ export type ComposeFileService = {
restart: ComposeFileRestartOption; restart: ComposeFileRestartOption;
depends_on?: string[]; depends_on?: string[];
command?: string; command?: string;
ports?: string[];
build?: { build?: {
context: string; context: string;
dockerfile: string; dockerfile: string;

View File

@ -4,6 +4,7 @@ import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database'; import { ErrorHandler } from '$lib/database';
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
import { promises as dns } from 'dns'; import { promises as dns } from 'dns';
import getPort from 'get-port';
import { t } from '$lib/translations'; import { t } from '$lib/translations';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
@ -11,7 +12,7 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body }; if (status === 401) return { status, body };
const { id } = event.params; const { id } = event.params;
let { fqdn, forceSave } = await event.request.json(); let { exposePort, fqdn, forceSave } = await event.request.json();
fqdn = fqdn.toLowerCase(); fqdn = fqdn.toLowerCase();
try { try {
@ -45,6 +46,16 @@ export const post: RequestHandler = async (event) => {
} }
} }
if (exposePort) {
exposePort = Number(exposePort);
if (exposePort < 1024 || exposePort > 65535) {
throw { message: `Expose Port needs to be between 1024 and 65535` };
}
const publicPort = await getPort({ port: exposePort });
}
return { return {
status: 200 status: 200
}; };

View File

@ -22,6 +22,7 @@ export const post: RequestHandler = async (event) => {
JSON.stringify({ JSON.stringify({
buildPack: applicationFound.buildPack, buildPack: applicationFound.buildPack,
port: applicationFound.port, port: applicationFound.port,
exposePort: applicationFound.exposePort,
installCommand: applicationFound.installCommand, installCommand: applicationFound.installCommand,
buildCommand: applicationFound.buildCommand, buildCommand: applicationFound.buildCommand,
startCommand: applicationFound.startCommand startCommand: applicationFound.startCommand

View File

@ -3,8 +3,6 @@ import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database'; import { ErrorHandler } from '$lib/database';
import { checkContainer, isContainerExited } from '$lib/haproxy'; import { checkContainer, isContainerExited } from '$lib/haproxy';
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
import jsonwebtoken from 'jsonwebtoken';
import { get as getRequest } from '$lib/api';
import { setDefaultConfiguration } from '$lib/buildPacks/common'; import { setDefaultConfiguration } from '$lib/buildPacks/common';
export const get: RequestHandler = async (event) => { export const get: RequestHandler = async (event) => {
@ -52,6 +50,7 @@ export const post: RequestHandler = async (event) => {
buildPack, buildPack,
fqdn, fqdn,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
@ -67,6 +66,9 @@ export const post: RequestHandler = async (event) => {
baseBuildImage baseBuildImage
} = await event.request.json(); } = await event.request.json();
if (port) port = Number(port); if (port) port = Number(port);
if (exposePort) {
exposePort = Number(exposePort);
}
if (denoOptions) denoOptions = denoOptions.trim(); if (denoOptions) denoOptions = denoOptions.trim();
try { try {
@ -87,6 +89,7 @@ export const post: RequestHandler = async (event) => {
name, name,
fqdn, fqdn,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,

View File

@ -62,6 +62,7 @@
let previews = application.settings.previews; let previews = application.settings.previews;
let dualCerts = application.settings.dualCerts; let dualCerts = application.settings.dualCerts;
let autodeploy = application.settings.autodeploy; let autodeploy = application.settings.autodeploy;
let showExposePort = application.exposePort !== null;
let wsgis = [ let wsgis = [
{ {
@ -127,7 +128,11 @@
async function handleSubmit() { async function handleSubmit() {
loading = true; loading = true;
try { 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 }); await post(`/applications/${id}.json`, { ...application });
$disabledButton = false; $disabledButton = false;
return toast.push('Configurations saved.'); return toast.push('Configurations saved.');
@ -392,7 +397,6 @@
bind:value={application.fqdn} bind:value={application.fqdn}
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$" pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
placeholder="eg: https://coollabs.io" placeholder="eg: https://coollabs.io"
required
/> />
</div> </div>
<div class="grid grid-cols-2 items-center pb-8"> <div class="grid grid-cols-2 items-center pb-8">
@ -451,7 +455,33 @@
/> />
</div> </div>
{/if} {/if}
{#if !staticDeployments.includes(application.buildPack)}
<div class="grid grid-cols-2 items-center">
<Setting
isCenter={false}
bind:setting={showExposePort}
on:click={() => {
showExposePort = !showExposePort;
application.exposePort = undefined;
}}
title={$t('application.expose_a_port')}
description="Expose a port to the host system"
/>
</div>
{#if showExposePort}
<div class="grid grid-cols-2 items-center">
<label for="exposePort" class="text-base font-bold text-stone-100">Expose Port</label>
<input
readonly={!$session.isAdmin}
name="exposePort"
id="exposePort"
bind:value={application.exposePort}
placeholder="12345"
/>
</div>
{/if}
{/if}
{#if !notNodeDeployments.includes(application.buildPack)} {#if !notNodeDeployments.includes(application.buildPack)}
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
<label for="installCommand" class="text-base font-bold text-stone-100" <label for="installCommand" class="text-base font-bold text-stone-100"

View File

@ -27,6 +27,7 @@
let loading = false; let loading = false;
let loadingVerification = false; let loadingVerification = false;
let dualCerts = service.dualCerts; let dualCerts = service.dualCerts;
let showExposePort = service.exposePort !== null;
async function handleSubmit() { async function handleSubmit() {
loading = true; loading = true;
@ -160,6 +161,32 @@
on:click={() => !isRunning && changeSettings('dualCerts')} on:click={() => !isRunning && changeSettings('dualCerts')}
/> />
</div> </div>
<div class="grid grid-cols-2 items-center">
<Setting
isCenter={false}
bind:setting={showExposePort}
on:click={() => {
showExposePort = !showExposePort;
service.exposePort = undefined;
}}
title={$t('application.expose_a_port')}
description="Expose a port to the host system"
/>
</div>
{#if showExposePort}
<div class="grid grid-cols-2 items-center">
<label for="exposePort" class="text-base font-bold text-stone-100">Expose Port</label>
<input
readonly={!$session.isAdmin}
name="exposePort"
id="exposePort"
bind:value={service.exposePort}
placeholder="12345"
/>
</div>
{/if}
{#if service.type === 'plausibleanalytics'} {#if service.type === 'plausibleanalytics'}
<PlausibleAnalytics bind:service {readOnly} /> <PlausibleAnalytics bind:service {readOnly} />
{:else if service.type === 'minio'} {:else if service.type === 'minio'}

View File

@ -11,11 +11,12 @@ export const post: RequestHandler = async (event) => {
let { let {
name, name,
fqdn, fqdn,
exposePort,
ghost: { mariadbDatabase } ghost: { mariadbDatabase }
} = await event.request.json(); } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
try { try {
await db.updateGhostService({ id, fqdn, name, mariadbDatabase }); await db.updateGhostService({ id, fqdn, name, exposePort, mariadbDatabase });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -12,6 +12,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -19,6 +20,8 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
const port = getServiceMainPort('ghost');
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { const {
@ -27,6 +30,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId, destinationDockerId,
destinationDocker, destinationDocker,
serviceSecret, serviceSecret,
exposePort,
fqdn, fqdn,
ghost: { ghost: {
defaultEmail, defaultEmail,
@ -89,6 +93,7 @@ export const post: RequestHandler = async (event) => {
volumes: [config.ghost.volume], volumes: [config.ghost.volume],
environment: config.ghost.environmentVariables, environment: config.ghost.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('ghost'), labels: makeLabelForServices('ghost'),
depends_on: [`${id}-mariadb`], depends_on: [`${id}-mariadb`],
deploy: { deploy: {

View File

@ -9,13 +9,15 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
console.log(error);
return ErrorHandler(error); return ErrorHandler(error);
} }
}; };

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -15,9 +16,11 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('languagetool');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -42,6 +45,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
environment: config.environmentVariables, environment: config.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes: [config.volume], volumes: [config.volume],
labels: makeLabelForServices('languagetool'), labels: makeLabelForServices('languagetool'),
deploy: { deploy: {

View File

@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -18,9 +19,11 @@ export const post: RequestHandler = async (event) => {
const { const {
meiliSearch: { masterKey } meiliSearch: { masterKey }
} = service; } = service;
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('meilisearch');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -47,6 +50,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
environment: config.environmentVariables, environment: config.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes: [config.volume], volumes: [config.volume],
labels: makeLabelForServices('meilisearch'), labels: makeLabelForServices('meilisearch'),
deploy: { deploy: {

View File

@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -7,6 +7,7 @@ import { startHttpProxy } from '$lib/haproxy';
import { ErrorHandler, getFreePort, getServiceImage } from '$lib/database'; import { ErrorHandler, getFreePort, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -22,12 +23,14 @@ export const post: RequestHandler = async (event) => {
fqdn, fqdn,
destinationDockerId, destinationDockerId,
destinationDocker, destinationDocker,
exposePort,
minio: { rootUser, rootUserPassword }, minio: { rootUser, rootUserPassword },
serviceSecret serviceSecret
} = service; } = service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('minio');
const publicPort = await getFreePort(); const publicPort = await getFreePort();
@ -62,6 +65,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
volumes: [config.volume], volumes: [config.volume],
restart: 'always', restart: 'always',
...(exposePort && { ports: [`${port}:${port}`] }),
labels: makeLabelForServices('minio'), labels: makeLabelForServices('minio'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body }; if (status === 401) return { status, body };
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -15,9 +16,11 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('n8n');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);

View File

@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body }; if (status === 401) return { status, body };
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -15,9 +16,11 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('nocodb');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -40,6 +43,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
environment: config.environmentVariables, environment: config.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('nocodb'), labels: makeLabelForServices('nocodb'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -11,14 +11,16 @@ export const post: RequestHandler = async (event) => {
let { let {
name, name,
fqdn, fqdn,
exposePort,
plausibleAnalytics: { email, username } plausibleAnalytics: { email, username }
} = await event.request.json(); } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (email) email = email.toLowerCase(); if (email) email = email.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updatePlausibleAnalyticsService({ id, fqdn, name, email, username }); await db.updatePlausibleAnalyticsService({ id, fqdn, name, email, username, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -22,6 +23,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId, destinationDockerId,
destinationDocker, destinationDocker,
serviceSecret, serviceSecret,
exposePort,
plausibleAnalytics: { plausibleAnalytics: {
id: plausibleDbId, id: plausibleDbId,
username, username,
@ -78,6 +80,7 @@ export const post: RequestHandler = async (event) => {
} }
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('plausibleanalytics');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
@ -132,6 +135,7 @@ COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`;
networks: [network], networks: [network],
environment: config.plausibleAnalytics.environmentVariables, environment: config.plausibleAnalytics.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort && { ports: [`${port}:${exposePort}`] }),
depends_on: [`${id}-postgresql`, `${id}-clickhouse`], depends_on: [`${id}-postgresql`, `${id}-clickhouse`],
labels: makeLabelForServices('plausibleAnalytics'), labels: makeLabelForServices('plausibleAnalytics'),
deploy: { deploy: {

View File

@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -8,6 +8,7 @@ import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import type { Service, DestinationDocker, Prisma } from '@prisma/client'; import type { Service, DestinationDocker, Prisma } from '@prisma/client';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -24,6 +25,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId, destinationDockerId,
destinationDocker, destinationDocker,
serviceSecret, serviceSecret,
exposePort,
umami: { umami: {
umamiAdminPassword, umamiAdminPassword,
postgresqlUser, postgresqlUser,
@ -34,6 +36,7 @@ export const post: RequestHandler = async (event) => {
} = service; } = service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('umami');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -156,6 +159,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
volumes: [], volumes: [],
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${port}:${port}`] } : {}),
labels: makeLabelForServices('umami'), labels: makeLabelForServices('umami'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body }; if (status === 401) return { status, body };
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -15,9 +16,11 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('uptimekuma');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -42,6 +45,7 @@ export const post: RequestHandler = async (event) => {
volumes: [config.volume], volumes: [config.volume],
environment: config.environmentVariables, environment: config.environmentVariables,
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('uptimekuma'), labels: makeLabelForServices('uptimekuma'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body }; if (status === 401) return { status, body };
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { getServiceImage, ErrorHandler } from '$lib/database'; import { getServiceImage, ErrorHandler } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -15,10 +16,12 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort } =
service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('vaultwarden');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -43,6 +46,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
volumes: [config.volume], volumes: [config.volume],
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('vaultWarden'), labels: makeLabelForServices('vaultWarden'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
const { id } = event.params; const { id } = event.params;
let { name, fqdn } = await event.request.json(); let { name, fqdn, exposePort } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateService({ id, fqdn, name }); await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -22,11 +23,13 @@ export const post: RequestHandler = async (event) => {
destinationDocker, destinationDocker,
serviceSecret, serviceSecret,
persistentStorage, persistentStorage,
exposePort,
vscodeserver: { password } vscodeserver: { password }
} = service; } = service;
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('vscodeserver');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
@ -75,6 +78,7 @@ export const post: RequestHandler = async (event) => {
networks: [network], networks: [network],
volumes: [config.volume, ...volumes], volumes: [config.volume, ...volumes],
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${port}:${exposePort}`] } : {}),
labels: makeLabelForServices('vscodeServer'), labels: makeLabelForServices('vscodeServer'),
deploy: { deploy: {
restart_policy: { restart_policy: {

View File

@ -11,12 +11,14 @@ export const post: RequestHandler = async (event) => {
let { let {
name, name,
fqdn, fqdn,
exposePort,
wordpress: { extraConfig, mysqlDatabase } wordpress: { extraConfig, mysqlDatabase }
} = await event.request.json(); } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase(); if (fqdn) fqdn = fqdn.toLowerCase();
if (exposePort) exposePort = Number(exposePort);
try { try {
await db.updateWordpress({ id, fqdn, name, extraConfig, mysqlDatabase }); await db.updateWordpress({ id, fqdn, name, extraConfig, mysqlDatabase, exposePort });
return { status: 201 }; return { status: 201 };
} catch (error) { } catch (error) {
return ErrorHandler(error); return ErrorHandler(error);

View File

@ -8,7 +8,6 @@ import type { ComposeFile } from '$lib/types/composeFile';
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
import cuid from 'cuid'; import cuid from 'cuid';
import fs from 'fs/promises'; import fs from 'fs/promises';
import getPort, { portNumbers } from 'get-port';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {

View File

@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database'; import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common'; import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile'; import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event); const { teamId, status, body } = await getUserDetails(event);
@ -22,6 +23,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId, destinationDockerId,
serviceSecret, serviceSecret,
destinationDocker, destinationDocker,
exposePort,
wordpress: { wordpress: {
mysqlDatabase, mysqlDatabase,
mysqlUser, mysqlUser,
@ -35,6 +37,7 @@ export const post: RequestHandler = async (event) => {
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine); const host = getEngine(destinationDocker.engine);
const image = getServiceImage(type); const image = getServiceImage(type);
const port = getServiceMainPort('wordpress');
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const config = { const config = {
@ -76,6 +79,7 @@ export const post: RequestHandler = async (event) => {
volumes: [config.wordpress.volume], volumes: [config.wordpress.volume],
networks: [network], networks: [network],
restart: 'always', restart: 'always',
...(exposePort ? { ports: [`${port}:${port}`] } : {}),
depends_on: [`${id}-mysql`], depends_on: [`${id}-mysql`],
labels: makeLabelForServices('wordpress'), labels: makeLabelForServices('wordpress'),
deploy: { deploy: {

View File

@ -73,6 +73,7 @@ export const post: RequestHandler = async (event) => {
JSON.stringify({ JSON.stringify({
buildPack: applicationFound.buildPack, buildPack: applicationFound.buildPack,
port: applicationFound.port, port: applicationFound.port,
exposePort: applicationFound.exposePort,
installCommand: applicationFound.installCommand, installCommand: applicationFound.installCommand,
buildCommand: applicationFound.buildCommand, buildCommand: applicationFound.buildCommand,
startCommand: applicationFound.startCommand startCommand: applicationFound.startCommand

View File

@ -46,6 +46,7 @@ export const post: RequestHandler = async (event) => {
JSON.stringify({ JSON.stringify({
buildPack: applicationFound.buildPack, buildPack: applicationFound.buildPack,
port: applicationFound.port, port: applicationFound.port,
exposePort: applicationFound.exposePort,
installCommand: applicationFound.installCommand, installCommand: applicationFound.installCommand,
buildCommand: applicationFound.buildCommand, buildCommand: applicationFound.buildCommand,
startCommand: applicationFound.startCommand startCommand: applicationFound.startCommand