diff --git a/Dockerfile b/Dockerfile index e885af058d..e72caca16b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,7 +78,7 @@ COPY ${PLUGIN_JARS} backend/plugins/ COPY ./app/client/build editor/ # Add RTS - Application Layer -COPY ./app/client/packages/rts/package.json ./app/client/packages/rts/dist rts/ +COPY ./app/client/packages/rts/dist rts/ RUN cd ./utils && npm install --only=prod && npm install --only=prod -g . && cd - \ && chmod 0644 /etc/cron.d/* \ diff --git a/app/client/packages/rts/build.sh b/app/client/packages/rts/build.sh index d75897f57b..12dcf98b59 100755 --- a/app/client/packages/rts/build.sh +++ b/app/client/packages/rts/build.sh @@ -3,18 +3,18 @@ set -o errexit cd "$(dirname "$0")" -rm -rf dist/ -# This is required for the first time build as node_modules is not present in the image -yarn install --immutable -yarn tsc && yarn tsc-alias -# Install only production dependencies -YARN_NM_HOISTING_LIMITS=workspaces yarn workspaces focus --production appsmith-rts -# Copying node_modules directory into dist as rts server requires production dependencies to run server build properly. -# This was previously being done in dockerfile which was copying the symlinks to image rather than the whole directory of shared modules (e.g. AST) -# Also, we copy node_modules with -L flag in order to follow the symlinks for @shared folder and copy the contents instead of just the symlink -cp -RL node_modules ./dist -# Delete production dependencies -rm -rf node_modules -# Restore all dependencies +root="$(git rev-parse --show-toplevel)" + yarn install --immutable +yarn run tsc --noEmit + +rm -rf dist +exec "$root/app/client/node_modules/.bin/esbuild" src/server.ts \ + --bundle \ + --minify \ + --sourcemap \ + --platform=node \ + --target="$(node --version | sed s/v/node/)" \ + --outdir=dist/bundle \ + --external:dtrace-provider diff --git a/app/client/packages/rts/src/server.ts b/app/client/packages/rts/src/server.ts index cd2802c9ca..0674d9b81f 100644 --- a/app/client/packages/rts/src/server.ts +++ b/app/client/packages/rts/src/server.ts @@ -1,5 +1,4 @@ import http from "http"; -import path from "path"; import express from "express"; import { Server } from "socket.io"; import type { LogLevelDesc } from "loglevel"; @@ -35,16 +34,10 @@ const io = new Server(server, { path: RTS_BASE_PATH, }); -// Initializing Sockets initializeSockets(io); // parse incoming json requests app.use(express.json({ limit: "5mb" })); -// Initializing Routes -app.use(express.static(path.join(__dirname, "static"))); -app.get("/", (_, res) => { - res.redirect("/index.html"); -}); app.use(`${RTS_BASE_API_PATH}/ast`, ast_routes); app.use(`${RTS_BASE_API_PATH}`, health_check_routes); diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf index c25b0b353f..9f94487204 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf @@ -1,5 +1,5 @@ [program:rts] -directory=/opt/appsmith/rts +directory=/opt/appsmith/rts/bundle command=/opt/appsmith/run-with-env.sh node server.js priority=15 autostart=true