Added expose port for Services

This commit is contained in:
Aaron Styles
2022-04-30 22:47:00 +10:00
parent 40cbee0d75
commit f94e17134e
30 changed files with 153 additions and 36 deletions

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: {