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

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