Browse Source

Merge pull request #5721 from nocodb/fix/static-public

fix(nocodb): incorrect public path for docker
pull/5727/head
աɨռɢӄաօռɢ 1 year ago committed by GitHub
parent
commit
99bce0bee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/nocodb/Dockerfile
  2. 4
      packages/nocodb/Dockerfile.local
  3. 2
      packages/nocodb/src/Noco.ts
  4. 3
      packages/nocodb/src/app.module.ts
  5. 7
      packages/nocodb/src/middlewares/public/public.middleware.spec.ts
  6. 23
      packages/nocodb/src/middlewares/public/public.middleware.ts
  7. 0
      packages/nocodb/src/public/css/fonts.montserrat.css
  8. 0
      packages/nocodb/src/public/css/fonts.roboto.css
  9. 0
      packages/nocodb/src/public/css/materialdesignicons.5.x.min.css
  10. 0
      packages/nocodb/src/public/css/swagger-ui-bundle.4.5.2.min.css
  11. 0
      packages/nocodb/src/public/css/vuetify.2.x.min.css
  12. 0
      packages/nocodb/src/public/favicon.ico
  13. 0
      packages/nocodb/src/public/icon.png
  14. 0
      packages/nocodb/src/public/js/axios.0.19.2.min.js
  15. 0
      packages/nocodb/src/public/js/redoc.standalone.min.js
  16. 0
      packages/nocodb/src/public/js/swagger-ui-bundle.4.5.2.min.js
  17. 0
      packages/nocodb/src/public/js/vue.2.6.14.min.js
  18. 0
      packages/nocodb/src/public/js/vue.global.js
  19. 0
      packages/nocodb/src/public/js/vuetify.2.x.min.js
  20. 2
      packages/nocodb/webpack.config.js

4
packages/nocodb/Dockerfile

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

4
packages/nocodb/Dockerfile.local

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

2
packages/nocodb/src/Noco.ts

@ -1,5 +1,6 @@
import Sentry, { Handlers } from '@sentry/node';
import { Logger } from '@nestjs/common';
import path from 'path';
import { NestFactory } from '@nestjs/core';
import clear from 'clear';
import * as express from 'express';
@ -122,6 +123,7 @@ export default class Noco {
const dashboardPath = process.env.NC_DASHBOARD_URL || '/dashboard';
server.use(NcToolGui.expressMiddleware(dashboardPath));
server.use(express.static(path.join(__dirname, 'public')));
server.get('/', (_req, res) => res.redirect(dashboardPath));
this.initSentryErrorHandler(server);

3
packages/nocodb/src/app.module.ts

@ -5,7 +5,6 @@ import { EventEmitterModule as NestJsEventEmitter } from '@nestjs/event-emitter'
import { GlobalExceptionFilter } from './filters/global-exception/global-exception.filter';
import { GlobalMiddleware } from './middlewares/global/global.middleware';
import { GuiMiddleware } from './middlewares/gui/gui.middleware';
import { PublicMiddleware } from './middlewares/public/public.middleware';
import { DatasModule } from './modules/datas/datas.module';
import { EventEmitterModule } from './modules/event-emitter/event-emitter.module';
import { AuthService } from './services/auth.service';
@ -59,8 +58,6 @@ export class AppModule {
consumer
.apply(GuiMiddleware)
.forRoutes({ path: '*', method: RequestMethod.GET })
.apply(PublicMiddleware)
.forRoutes({ path: '*', method: RequestMethod.GET })
.apply(GlobalMiddleware)
.forRoutes({ path: '*', method: RequestMethod.ALL });
}

7
packages/nocodb/src/middlewares/public/public.middleware.spec.ts

@ -1,7 +0,0 @@
import { PublicMiddleware } from './public.middleware';
describe('PublicMiddleware', () => {
it('should be defined', () => {
expect(new PublicMiddleware()).toBeDefined();
});
});

23
packages/nocodb/src/middlewares/public/public.middleware.ts

@ -1,23 +0,0 @@
import path, { join } from 'path';
import { Injectable } from '@nestjs/common';
import express from 'express';
import isDocker from 'is-docker';
import type { NestMiddleware } from '@nestjs/common';
@Injectable()
export class PublicMiddleware implements NestMiddleware {
use(req: any, res: any, next: () => void) {
// redirect root to dashboard
if (req.path === '/') {
const dashboardPath = process.env.NC_DASHBOARD_URL || '/dashboard';
return res.redirect(dashboardPath);
}
// serve static files from public folder
if (isDocker()) {
express.static(join(process.cwd(), 'docker', 'public'))(req, res, next);
} else {
express.static(join(process.cwd(), 'public'))(req, res, next);
}
}
}

0
packages/nocodb/public/css/fonts.montserrat.css → packages/nocodb/src/public/css/fonts.montserrat.css

0
packages/nocodb/public/css/fonts.roboto.css → packages/nocodb/src/public/css/fonts.roboto.css

0
packages/nocodb/public/css/materialdesignicons.5.x.min.css → packages/nocodb/src/public/css/materialdesignicons.5.x.min.css vendored

0
packages/nocodb/public/css/swagger-ui-bundle.4.5.2.min.css → packages/nocodb/src/public/css/swagger-ui-bundle.4.5.2.min.css vendored

0
packages/nocodb/public/css/vuetify.2.x.min.css → packages/nocodb/src/public/css/vuetify.2.x.min.css vendored

0
packages/nocodb/public/favicon.ico → packages/nocodb/src/public/favicon.ico

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
packages/nocodb/public/icon.png → packages/nocodb/src/public/icon.png

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

0
packages/nocodb/public/js/axios.0.19.2.min.js → packages/nocodb/src/public/js/axios.0.19.2.min.js vendored

0
packages/nocodb/public/js/redoc.standalone.min.js → packages/nocodb/src/public/js/redoc.standalone.min.js vendored

0
packages/nocodb/public/js/swagger-ui-bundle.4.5.2.min.js → packages/nocodb/src/public/js/swagger-ui-bundle.4.5.2.min.js vendored

0
packages/nocodb/public/js/vue.2.6.14.min.js → packages/nocodb/src/public/js/vue.2.6.14.min.js vendored

0
packages/nocodb/public/js/vue.global.js → packages/nocodb/src/public/js/vue.global.js

0
packages/nocodb/public/js/vuetify.2.x.min.js → packages/nocodb/src/public/js/vuetify.2.x.min.js vendored

2
packages/nocodb/webpack.config.js

@ -44,7 +44,7 @@ module.exports = {
plugins: [
new webpack.EnvironmentPlugin(['EE']),
new CopyPlugin({
patterns: [{ from: 'public', to: 'public' }],
patterns: [{ from: 'src/public', to: 'public' }],
}),
],

Loading…
Cancel
Save