Browse Source

Merge pull request #5132 from nocodb/fix/public-files-path

fix: production build wrong public files path
pull/5138/head
Pranav C 2 years ago committed by GitHub
parent
commit
bb73cd8076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/release-executables.yml
  2. 2
      .github/workflows/release-timely-executables.yml
  3. 6
      packages/nocodb/Dockerfile
  4. 5
      packages/nocodb/docker/webpack.config.js
  5. 13
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  6. 4
      packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts
  7. 1
      packages/nocodb/src/lib/meta/api/helpers/index.ts
  8. 7
      packages/nocodb/webpack.config.js

2
.github/workflows/release-executables.yml

@ -87,7 +87,7 @@ jobs:
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl
# clean up code to optimize size # clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,nocodb/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run
# build executables # build executables
npm run build npm run build

2
.github/workflows/release-timely-executables.yml

@ -103,7 +103,7 @@ jobs:
# clean up code to optimize size # clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,nocodb-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run
# build executables # build executables
npm run build npm run build

6
packages/nocodb/Dockerfile

@ -31,9 +31,9 @@ COPY ./package*.json ./
COPY ./docker/main.js ./docker/main.js COPY ./docker/main.js ./docker/main.js
#COPY ./docker/start.sh /usr/src/appEntry/start.sh #COPY ./docker/start.sh /usr/src/appEntry/start.sh
COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh
COPY ./src/lib/public/css/*.css /usr/src/appEntry/public/css/ COPY ./src/lib/public/css/*.css ./docker/public/css/
COPY ./src/lib/public/js/*.js /usr/src/appEntry/public/js/ COPY ./src/lib/public/js/*.js ./docker/public/js/
COPY ./src/lib/public/favicon.ico /usr/src/appEntry/public/ COPY ./src/lib/public/favicon.ico ./docker/public/
# install production dependencies, # install production dependencies,
# reduce node_module size with modclean & removing sqlite deps, # reduce node_module size with modclean & removing sqlite deps,

5
packages/nocodb/docker/webpack.config.js

@ -56,4 +56,7 @@ module.exports = {
// }) // })
], ],
target: 'node', target: 'node',
}; node: {
__dirname: false,
},
};

13
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -10,11 +10,16 @@ import ncMetaAclMw from '../../helpers/ncMetaAclMw';
import { getViewAndModelFromRequestByAliasOrId } from './helpers'; import { getViewAndModelFromRequestByAliasOrId } from './helpers';
import apiMetrics from '../../helpers/apiMetrics'; import apiMetrics from '../../helpers/apiMetrics';
import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst'; import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst';
import { parseHrtimeToSeconds } from '../helpers';
// todo: Handle the error case where view doesnt belong to model // todo: Handle the error case where view doesnt belong to model
async function dataList(req: Request, res: Response) { async function dataList(req: Request, res: Response) {
const startTime = process.hrtime();
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const { model, view } = await getViewAndModelFromRequestByAliasOrId(req);
res.json(await getDataList(model, view, req)); const responseData = await getDataList(model, view, req);
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime));
res.setHeader('xc-db-response', elapsedSeconds);
res.json(responseData);
} }
async function dataFindOne(req: Request, res: Response) { async function dataFindOne(req: Request, res: Response) {
@ -226,8 +231,12 @@ async function dataExist(req: Request, res: Response) {
// todo: Handle the error case where view doesnt belong to model // todo: Handle the error case where view doesnt belong to model
async function groupedDataList(req: Request, res: Response) { async function groupedDataList(req: Request, res: Response) {
const startTime = process.hrtime();
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const { model, view } = await getViewAndModelFromRequestByAliasOrId(req);
res.json(await getGroupedDataList(model, view, req)); const groupedData = await getGroupedDataList(model, view, req);
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime));
res.setHeader('xc-db-response', elapsedSeconds);
res.json(groupedData);
} }
async function getGroupedDataList(model, view: View, req) { async function getGroupedDataList(model, view: View, req) {

4
packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts

@ -0,0 +1,4 @@
export function parseHrtimeToSeconds(hrtime) {
const seconds = (hrtime[0] + hrtime[1] / 1e6).toFixed(3);
return seconds;
}

1
packages/nocodb/src/lib/meta/api/helpers/index.ts

@ -1,4 +1,5 @@
import { populateMeta } from './populateMeta'; import { populateMeta } from './populateMeta';
export * from './columnHelpers'; export * from './columnHelpers';
export * from './apiHelpers';
export { populateMeta }; export { populateMeta };

7
packages/nocodb/webpack.config.js

@ -40,7 +40,8 @@ module.exports = {
globalObject: "typeof self !== 'undefined' ? self : this" globalObject: "typeof self !== 'undefined' ? self : this"
}, },
node: { node: {
fs: 'empty' fs: 'empty',
__dirname: false,
}, },
plugins: [ plugins: [
new webpack.EnvironmentPlugin([ new webpack.EnvironmentPlugin([
@ -58,5 +59,5 @@ module.exports = {
// }, []), // }, []),
], ],
target: 'node', target: 'node'
}; };

Loading…
Cancel
Save