From c5b32620fd46faeb1a0265a7343dc0f687dbae3f Mon Sep 17 00:00:00 2001 From: Kamoltat Sirivadhna Date: Fri, 2 Feb 2024 16:38:57 -0500 Subject: [PATCH] src: Add hot reload option for development Allow hot reload in Development mode for pulpito-ng. This saves a lot more time when developing with other tech stacks. Signed-off-by: Kamoltat Sirivadhna --- Dockerfile | 5 +---- README.md | 11 +++++++++++ start_container.sh | 14 ++++++++++++++ vite.config.js | 4 ++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 start_container.sh diff --git a/Dockerfile b/Dockerfile index 530258a..1c55907 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,4 @@ RUN \ mkdir -p /app/node_modules/.vite && \ npm install COPY . . -RUN chown -R node:node /app && \ - npm run build -USER node -CMD ["npm", "run", "serve", "--", "--host"] \ No newline at end of file +CMD sh /app/start_container.sh \ No newline at end of file diff --git a/README.md b/README.md index f778ab6..02342ab 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,14 @@ In [teuthology's docker-compose](https://github.com/ceph/teuthology/blob/main/do ports: - 8081:8081 ``` +[recommended] For developement purposes: +Add the following to `pulpito-ng` container: + +``` +pulpito-ng: + environment: + DEPLOYMENT: development + volumes: + - ../../../pulpito-ng:/app/:rw + - /app/node_modules +``` \ No newline at end of file diff --git a/start_container.sh b/start_container.sh new file mode 100644 index 0000000..ce02674 --- /dev/null +++ b/start_container.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +set -ex +trap exit TERM + +cd /app/ + +if [ "$DEPLOYMENT" = "development" ]; then + echo "DEVELOPMENT MODE" + npm run start +else + chown -R node:node /app + npm run build + npm run serve -- --host +fi \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index c7a3294..198adef 100644 --- a/vite.config.js +++ b/vite.config.js @@ -20,6 +20,10 @@ export default defineConfig(() => { ], server: { port: 8081, + host: true, + watch: { + usePolling: true, + }, }, preview: { port: 8081,