Skip to content

Commit

Permalink
src: Add hot reload option for development
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kamoltat committed Feb 6, 2024
1 parent 8bd6699 commit a6f8888
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
CMD sh /app/start_container.sh
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
14 changes: 14 additions & 0 deletions start_container.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 16 additions & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { sentryVitePlugin } from "@sentry/vite-plugin";

const DEPLOYMENT = process.env.DEPLOYMENT;
export default defineConfig(() => {
return {
let config = {
build: {
outDir: "build",
sourcemap: true, // for Sentry
Expand All @@ -18,11 +18,22 @@ export default defineConfig(() => {
url: "https://sentry.ceph.com/",
}),
],
server: {
port: 8081,
},
preview: {
port: 8081,
}
};
if (DEPLOYMENT == "development") {
config['server'] = {
port: 8081,
host: true,
watch: {
usePolling: true,
},
}
} else {
config['server'] = {
port: 8081,
}
}
return config;
});

0 comments on commit a6f8888

Please sign in to comment.