From 74b82594716e4ffed94c871c2c223be8c8aa3ff6 Mon Sep 17 00:00:00 2001
From: Carlos Santos <4a.santos@gmail.com>
Date: Thu, 26 Sep 2024 11:09:24 +0200
Subject: [PATCH] Updated build script

---
 backend/package.json  | 2 +-
 docker/Dockerfile     | 4 ++--
 frontend/package.json | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/backend/package.json b/backend/package.json
index 285986d0..0cb1150e 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -21,7 +21,7 @@
 	"types": "dist/index.d.ts",
 	"type": "module",
 	"scripts": {
-		"build": "rm -rf dist && tsc",
+		"build": "tsc",
 		"start": "node dist/src/server.js",
 		"dev:start": "cross-env USE_HTTPS=false TESTING_MODE=ENABLED nodemon -I --exec node --experimental-specifier-resolution=node --loader ts-node/esm ./src/server.ts",
 		"lint": "eslint src --fix",
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 93b13950..b2c979f7 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -25,11 +25,11 @@ RUN npm install
 
 COPY --chown=node:node backend/ ./
 
-RUN npm run build
-
 # Copy static files from the frontend build
 COPY --from=build-frontend /app/frontend/dist/openvidu-call /app/backend/dist/public
 
+RUN npm run build
+
 
 ### Stage 3: Final production image
 FROM node:20-alpine as production
diff --git a/frontend/package.json b/frontend/package.json
index 1c051f12..0d86aba5 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -54,6 +54,7 @@
     "dev:start": "ng serve --configuration development --port=5080 --host=0.0.0.0",
     "dev:build": "./node_modules/@angular/cli/bin/ng.js build --output-path ../backend/public/",
     "build": "func() { ./node_modules/@angular/cli/bin/ng.js build --configuration production --base-href=\"${1:-/}\"; }; func",
+    "build-and-copy": "npm run build && mkdir -p ../backend/dist/public && cp -r dist/openvidu-call/* ../backend/dist/public",
     "e2e:all": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/**/*.test.js",
     "e2e:home": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/home.test.js",
     "e2e:room": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/room.test.js",