@lomray/vite-ssr-boost 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/run-docker-build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"node:child_process";import e from"node:path";import{cwd as r}from"node:process";import{resolveConfig as i}from"vite";import t from"../helpers/plugin-config.js";async function n({imageName:n,dockerFile:d,isOnlyClient:l=!1,dockerOptions:p="",mode:s=""}){const c="production"===s?"production":"development",a=await i({},"build",s),m=t(a),{root:u,build:{outDir:f}}=a,$=r(),g=`.${e.resolve(u,f).replace($,"")}`,b=l?"spa":"ssr",h=d||`${m.pluginPath}/workflow/Dockerfile`;o.execSync(`docker build -f ${h} --build-arg BUILD_PATH=${g} --build-arg RUN_TYPE=${b} --build-arg ENV_MODE=${c}${p} -t ${n} ${$}`,{stdio:"inherit",env:{...process.env}})}export{n as default};
|
|
1
|
+
import o from"node:child_process";import e from"node:path";import{cwd as r}from"node:process";import{resolveConfig as i}from"vite";import t from"../helpers/plugin-config.js";async function n({imageName:n,dockerFile:d,isOnlyClient:l=!1,dockerOptions:p="",mode:s=""}){const c="production"===s?"production":"development",a=await i({},"build",s),m=t(a),{root:u,build:{outDir:f}}=a,$=r(),g=`.${e.resolve(u,f).replace($,"")}`,b=l?"spa":"ssr",h=d||`${m.pluginPath}/workflow/Dockerfile`;o.execSync(`docker build -f ${h} --build-arg BUILD_PATH=${g} --build-arg RUN_TYPE=${b} --build-arg ENV_MODE=${c} ${p} -t ${n} ${$}`,{stdio:"inherit",env:{...process.env}})}export{n as default};
|
|
2
2
|
//# sourceMappingURL=run-docker-build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n isOnlyClient?: boolean;\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n isOnlyClient = false,\n dockerOptions = '',\n mode = '',\n}: IRunDockerBuildParams): Promise<void> {\n const nodeEnv = mode === 'production' ? 'production' : 'development';\n const config = await resolveConfig({}, 'build', mode);\n const pluginConfig = getPluginConfig(config);\n const {\n root,\n build: { outDir },\n } = config;\n const projectRoot = cwd();\n const buildDir = `.${path.resolve(root, outDir).replace(projectRoot, '')}`; // relative path\n const runType = isOnlyClient ? 'spa' : 'ssr';\n const docFile = dockerFile || `${pluginConfig.pluginPath}/workflow/Dockerfile`;\n\n childProcess.execSync(\n `docker build -f ${docFile}` +\n ` --build-arg BUILD_PATH=${buildDir}` +\n ` --build-arg RUN_TYPE=${runType} --build-arg ENV_MODE=${nodeEnv}` +\n
|
|
1
|
+
{"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n isOnlyClient?: boolean;\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n isOnlyClient = false,\n dockerOptions = '',\n mode = '',\n}: IRunDockerBuildParams): Promise<void> {\n const nodeEnv = mode === 'production' ? 'production' : 'development';\n const config = await resolveConfig({}, 'build', mode);\n const pluginConfig = getPluginConfig(config);\n const {\n root,\n build: { outDir },\n } = config;\n const projectRoot = cwd();\n const buildDir = `.${path.resolve(root, outDir).replace(projectRoot, '')}`; // relative path\n const runType = isOnlyClient ? 'spa' : 'ssr';\n const docFile = dockerFile || `${pluginConfig.pluginPath}/workflow/Dockerfile`;\n\n childProcess.execSync(\n `docker build -f ${docFile}` +\n ` --build-arg BUILD_PATH=${buildDir}` +\n ` --build-arg RUN_TYPE=${runType} --build-arg ENV_MODE=${nodeEnv}` +\n ` ${dockerOptions} -t ${imageName} ${projectRoot}`,\n {\n stdio: 'inherit',\n env: {\n ...process.env,\n },\n },\n );\n}\n\nexport default runDockerBuild;\n"],"names":["async","runDockerBuild","imageName","dockerFile","isOnlyClient","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"8KAiBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,aACVA,GAAe,EAAKC,cACpBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAmB,eAATD,EAAwB,aAAe,cACjDE,QAAeC,EAAc,CAAE,EAAE,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUjB,EAAe,MAAQ,MACjCkB,EAAUnB,GAAc,GAAGO,EAAaa,iCAE9CC,EAAaC,SACX,mBAAmBH,4BACUL,0BACFI,0BAAgCd,KACrDF,QAAoBH,KAAaa,IACvC,CACEW,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
|
package/package.json
CHANGED
package/workflow/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:20.10.0-alpine
|
|
2
2
|
|
|
3
3
|
MAINTAINER Yarmaliuk Mikhail <mikhail.yarmaliuk@lomray.com>
|
|
4
4
|
|
|
@@ -6,6 +6,7 @@ ARG BUILD_PATH
|
|
|
6
6
|
ARG RUN_TYPE=ssr
|
|
7
7
|
ARG ENV_MODE=production
|
|
8
8
|
ARG WEB_PATH=/var/www
|
|
9
|
+
ARG INSTALL_COMMAND="npm ci"
|
|
9
10
|
|
|
10
11
|
ENV NODE_ENV=${ENV_MODE}
|
|
11
12
|
ENV TYPE=${RUN_TYPE}
|
|
@@ -16,8 +17,8 @@ WORKDIR $WEB_PATH
|
|
|
16
17
|
|
|
17
18
|
COPY ${BUILD_PATH} $WEB_PATH/build
|
|
18
19
|
COPY ./package.json $WEB_PATH/package.json
|
|
19
|
-
COPY
|
|
20
|
+
COPY package-lock.json* yarn.lock* pnpm-lock.yaml* $WEB_PATH
|
|
20
21
|
|
|
21
|
-
RUN
|
|
22
|
+
RUN ${INSTALL_COMMAND}
|
|
22
23
|
|
|
23
24
|
CMD npm run start:${TYPE} -- --host
|