fix: update Dockerfile to use Start.dev.sh for development environment

This commit is contained in:
Nawaz Dhandala
2026-04-03 20:24:41 +01:00
parent 720399c8b8
commit 4bad603db2
2 changed files with 60 additions and 2 deletions

View File

@@ -84,7 +84,7 @@ ENTRYPOINT ["/usr/bin/tini", "--"]
{{ if eq .Env.ENVIRONMENT "development" }} {{ if eq .Env.ENVIRONMENT "development" }}
#Run the app #Run the app
CMD [ "npm", "run", "dev" ] CMD [ "bash", "/usr/src/app/Start.dev.sh" ]
{{ else }} {{ else }}
# Copy app source # Copy app source
COPY ./Probe /usr/src/app COPY ./Probe /usr/src/app
@@ -95,4 +95,3 @@ RUN chown -R 1000:1000 "/tmp/npm" && chmod -R 2777 "/tmp/npm"
#Run the app #Run the app
CMD [ "npm", "start" ] CMD [ "npm", "start" ]
{{ end }} {{ end }}

59
Probe/Start.dev.sh Normal file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail
COMMON_DIR="/usr/src/Common"
ISOLATED_VM_DIR="${COMMON_DIR}/node_modules/isolated-vm"
log() {
echo "[probe bootstrap] $*"
}
isolated_vm_can_load() {
node -e 'require(process.argv[1])' "${ISOLATED_VM_DIR}" >/dev/null 2>&1
}
ensure_common_dependencies() {
if [ ! -d "${COMMON_DIR}/node_modules" ]; then
log "Common node_modules is missing. Installing dependencies."
(
cd "${COMMON_DIR}"
npm install
)
return
fi
if [ ! -d "${ISOLATED_VM_DIR}" ]; then
log "isolated-vm is missing from Common node_modules. Reinstalling Common dependencies."
(
cd "${COMMON_DIR}"
npm install
)
return
fi
if isolated_vm_can_load; then
return
fi
log "Repairing isolated-vm for the current container runtime."
if ! (
cd "${COMMON_DIR}"
npm rebuild isolated-vm
); then
log "isolated-vm rebuild failed. Reinstalling Common dependencies."
rm -rf "${ISOLATED_VM_DIR}"
(
cd "${COMMON_DIR}"
npm install
)
fi
isolated_vm_can_load
}
ensure_common_dependencies
exec npm run dev