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
44 changed files with 249 additions and 39 deletions

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

View File

@@ -327,35 +327,40 @@ export async function updatePlausibleAnalyticsService({
id,
fqdn,
email,
exposePort,
username,
name
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
email: string;
username: string;
}): Promise<void> {
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({
id,
fqdn,
exposePort,
name
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
}): 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({
id,
fqdn,
name,
exposePort,
emailNoreply,
emailMailgunApiKey,
emailMailgunDomain,
@@ -368,6 +373,7 @@ export async function updateFiderService({
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
emailNoreply: string;
emailMailgunApiKey: string;
@@ -384,6 +390,7 @@ export async function updateFiderService({
data: {
fqdn,
name,
exposePort,
fider: {
update: {
emailNoreply,
@@ -405,18 +412,20 @@ export async function updateWordpress({
id,
fqdn,
name,
exposePort,
mysqlDatabase,
extraConfig
}: {
id: string;
fqdn: string;
name: string;
exposePort?: number;
mysqlDatabase: string;
extraConfig: string;
}): Promise<Service> {
return await prisma.service.update({
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,
fqdn,
name,
exposePort,
mariadbDatabase
}: {
id: string;
fqdn: string;
name: string;
exposePort?: number;
mariadbDatabase: string;
}): Promise<Service> {
return await prisma.service.update({
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_auto_deploy_webhooks": "Enable automatic deployment through webhooks.",
"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.",
"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.",

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_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.",
"expose_a_port": "Exposer un port",
"features": "Caractéristiques",
"git_repository": "Dépôt Git",
"git_source": "Source Git",

View File

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

View File

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

View File

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

View File

@@ -4,6 +4,7 @@ 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) => {
@@ -11,7 +12,7 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
const { id } = event.params;
let { fqdn, forceSave } = await event.request.json();
let { exposePort, fqdn, forceSave } = await event.request.json();
fqdn = fqdn.toLowerCase();
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 {
status: 200
};

View File

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

View File

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

View File

@@ -62,6 +62,7 @@
let previews = application.settings.previews;
let dualCerts = application.settings.dualCerts;
let autodeploy = application.settings.autodeploy;
let showExposePort = application.exposePort !== null;
let wsgis = [
{
@@ -127,7 +128,11 @@
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 });
$disabledButton = false;
return toast.push('Configurations saved.');
@@ -392,7 +397,6 @@
bind:value={application.fqdn}
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
placeholder="eg: https://coollabs.io"
required
/>
</div>
<div class="grid grid-cols-2 items-center pb-8">
@@ -451,7 +455,33 @@
/>
</div>
{/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)}
<div class="grid grid-cols-2 items-center">
<label for="installCommand" class="text-base font-bold text-stone-100"

View File

@@ -27,6 +27,7 @@
let loading = false;
let loadingVerification = false;
let dualCerts = service.dualCerts;
let showExposePort = service.exposePort !== null;
async function handleSubmit() {
loading = true;
@@ -160,6 +161,32 @@
on:click={() => !isRunning && changeSettings('dualCerts')}
/>
</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'}
<PlausibleAnalytics bind:service {readOnly} />
{:else if service.type === 'minio'}

View File

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

View File

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

View File

@@ -9,13 +9,15 @@ export const post: RequestHandler = async (event) => {
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
console.log(error);
return ErrorHandler(error);
}
};

View File

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

View File

@@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

@@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

@@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

@@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

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

View File

@@ -6,6 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
import { ErrorHandler, getServiceImage } from '$lib/database';
import { makeLabelForServices } from '$lib/buildPacks/common';
import type { ComposeFile } from '$lib/types/composeFile';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
@@ -22,6 +23,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId,
destinationDocker,
serviceSecret,
exposePort,
plausibleAnalytics: {
id: plausibleDbId,
username,
@@ -78,6 +80,7 @@ export const post: RequestHandler = async (event) => {
}
const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('plausibleanalytics');
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],
environment: config.plausibleAnalytics.environmentVariables,
restart: 'always',
...(exposePort && { ports: [`${port}:${exposePort}`] }),
depends_on: [`${id}-postgresql`, `${id}-clickhouse`],
labels: makeLabelForServices('plausibleAnalytics'),
deploy: {

View File

@@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (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 { Service, DestinationDocker, Prisma } from '@prisma/client';
import bcrypt from 'bcryptjs';
import { getServiceMainPort } from '$lib/components/common';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
@@ -24,6 +25,7 @@ export const post: RequestHandler = async (event) => {
destinationDockerId,
destinationDocker,
serviceSecret,
exposePort,
umami: {
umamiAdminPassword,
postgresqlUser,
@@ -34,6 +36,7 @@ export const post: RequestHandler = async (event) => {
} = service;
const network = destinationDockerId && destinationDocker.network;
const host = getEngine(destinationDocker.engine);
const port = getServiceMainPort('umami');
const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type);
@@ -156,6 +159,7 @@ export const post: RequestHandler = async (event) => {
networks: [network],
volumes: [],
restart: 'always',
...(exposePort ? { ports: [`${port}:${port}`] } : {}),
labels: makeLabelForServices('umami'),
deploy: {
restart_policy: {

View File

@@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

@@ -8,11 +8,12 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

@@ -9,11 +9,12 @@ export const post: RequestHandler = async (event) => {
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 (exposePort) exposePort = Number(exposePort);
try {
await db.updateService({ id, fqdn, name });
await db.updateService({ id, fqdn, name, exposePort });
return { status: 201 };
} catch (error) {
return ErrorHandler(error);

View File

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

View File

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

View File

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

View File

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

View File

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