🌳
pt0/deployF/servicesF/minecraftF/doSyncMcF.mts
4import * as mcActions from "./actionsF.mts";
5import * as _ from 'lodash-es'
16const image = 'itzg/minecraft-server'
17const name = 'minecraft'
18const portNo = 30411
20export const eptMinecraftSync = async ({importMetaUrl, hostname}: {importMetaUrl?: string, hostname?: string}={}) => {
21 if (importMetaUrl && !isDirectlyRun(importMetaUrl)) return {importMetaUrl, epName: 'minecraft'}
22 const {volumeMounts, volumes} = pvcVolumeMounts({name, mountPath: '/data'})
24 const resources = [
26 volumes, name,
27 strategy: {
28 type: 'Recreate'
29 },
30 initContainers: [{
31 name: 'fix-permissions',
32 image: 'busybox',
33 command: ['sh', '-c', 'chown -R 1000:1000 /data/world || true'],
34 volumeMounts
35 }],
36 containers: [{
37 name, image,
38 volumeMounts,
39 env: envHToA({
40 EULA: 'TRUE',
41 VERSION: '1.21.11',
42 })
43 }],
44 }),
45 genericNodePortTmpl({name, nodePort: portNo, svcPort: 25565})
46 ]
47 appCfgCtx.enterWith({...getAppCfg(), name})
49 await kubeActionPvc({name, sizeGb: 500})
50 const action = getAction()
52 // Handle mcActions without epscope commands from ptDeployActionsF
53 const resActionsH = resourcesActionsH() as Record<string, unknown>
54 if (!resActionsH[action]) {
55 const matchedAction = (mcActions as Record<string, (() => Promise<void>) | undefined>)[action]
56 if (matchedAction) {
57 await matchedAction()
58 return
59 }
60 cliHelp({action, actionsH: {...mcActions, ...resActionsH}})
61 return
62 }
64 const resA = await resourcesActionLite({resources, noDelPvcs: true})
65 if (_.includes(['apply', 'info'], action) && !_.includes(resA, undefined)) {
66 console.log(`should be hosted @ ${hostname}:${portNo}`)
67 }